Header background

Capture any request attributes using OneAgent SDK

We recently announced the beta releases of the Dynatrace OneAgent SDK for C/C++ and other native applications, Java, and Node.js, as well as the start of the early access program for the Python SDK. The OneAgent SDK enables you to extend AI-based root cause analysis to additional languages, technologies, and frameworks.

We’ve now added another use case to the OneAgent SDK: the capture of custom request attributes.

What are request attributes?

Request attributes are key/value pairs that are associated with a particular service request. For example, if you have a travel website that tracks customer booking destinations, you can set up a destination and a revenue attribute for each service request. The specific values of the destination and revenue attributes of each request are populated automatically on all calls that include those attributes. This makes request attributes a powerful feature when combined with Dynatrace advanced filtering and charting.

Request attributes can be defined based on web request dataJava method arguments.NET method arguments, and now, for even more flexibility, directly from the OneAgent SDK. Let’s take a look at how this works.

How to capture request attributes via OneAgent SDK

Here is a code example based on the Node.js implementation of the OneAgent SDK. While the API may differ slightly for the other language implementations of the SDK, the concepts are the same.

Api.addCustomRequestAttribute("destination", "Tokyo");
Api.addCustomRequestAttribute("revenue", 534.07);

The method addCustomRequestAttribute() adds a custom request attribute to the currently traced service call. No reference to a tracer is needed as OneAgent SDK will select the current open trace. This may be a trace created by OneAgent SDK or a trace created by built-in sensors of OneAgent. This method can be called several times to add multiple attributes to the same request. If the same attribute key is set several times, all values will be recorded. The method addCustomRequestAttribute() takes two arguments:

  • key: a string specifying the name of the attribute
  • value: a string or number specifying the attribute value

Request attributes are available in the OneAgent SDK for Java, OneAgent SDK for Node.js and OneAgent SDK for C/C++. Stay tuned for the upcoming availability of this feature in the OneAgent SDK for Python.

Once you’ve configured capture of request attributes via the OneAgent SDK, it’s time to create the request attributes themselves via the web UI.

Configure request attributes in Dynatrace

To configure a request attribute in Dynatrace Web UI

  1. Go to Settings > Server-side monitoring > Request attributes.
  2. Click Create new request attribute.
  3. Provide a unique request Attribute name. You can set the Data type (Text, Integer, or Double) and specify additional settings.
  4. Click Add new data source.
  5. Select SDK custom attribute as the Request attribute source.
  6. Enter the name of the attribute you defined in your code (revenue in this example) in the Attribute name field.

Once you’ve defined your attribute, go to the overview page of any service that calls or receives calls from the related request. Have a look at the Top requests section (see image below). The Request attributes tab shows the new request attributes and the top values. Click any request attribute to filter the entire page view down to only those requests that carry the selected attribute.

Custom analysis charts

In addition to filtering, request attributes can also be used to define web-request naming rules, set up functional error detection, and to build your own custom analysis charts as shown in the two examples below.

Based on the destination request attribute, we can rank the popularity of the European destinations:

We can go a step further by tracking the total revenue for these destinations:

Requirements

What’s next?

Stay tuned for the following upcoming announcements:

  • Start of the Early Access Program (EAP) for OneAgent SDK for .NET
  • Continuous improvements and new features for the C/C++, Node.js, Java, and Python SDKs
  • General availability (GA) of the OneAgent SDK by early next year

We’d love to hear your feedback! The OneAgent SDK is an open source project, available on GitHub. All user contributions (from additional language bindings for the C/C++ SDK, to the reporting of minor defects, issues, or typos) are welcome. The best way for you to do this is via the GitHub repository issue tracker. You can also comment on our roadmap thread in AnswerHub.