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
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 data, Java 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.
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
- Go to Settings > Server-side monitoring > Request attributes.
- Click Create new request attribute.
- Provide a unique request Attribute name. You can set the Data type (Text, Integer, or Double) and specify additional settings.
- Click Add new data source.
- Select SDK custom attribute as the Request attribute source.
- Enter the name of the attribute you defined in your code (
revenuein 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
- This feature requires Dynatrace SaaS or Dynatrace Managed cluster version 1.150 and Dynatrace OneAgent version 1.147 or higher.
- Request attributes are available in the OneAgent SDK for Java (1.2.0 or higher), OneAgent SDK for Node.js (1.2.0 or higher), and OneAgent SDK for C/C++ (1.2.0 or higher). Stay tuned for the upcoming availability of this feature in the OneAgent SDK for Python.
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.