07 Jan 2025
08:31 PM
- last edited on
23 Jan 2026
10:39 AM
by
IzabelaRokita
Summary: This post explains how to configure Dynatrace so that request attributes added through the OneAgent SDK are captured and displayed. It clarifies required instrumentation, attribute settings, and verification steps.
I was kicking the tires on using OneAgent SDK in a Java (Jersey/Tomcat) application to enrich existing service request traces with additional computed attributes - fo,r example a boolean indicating whether the service chose to stream a response or not. Using code quite like the SDK's example on a Path-annotated method on a Resource class that corresponds to a Dynatrace-monitored service:
oneAgentSdk.addCustomRequestAttribute("pricing-streamed", Boolean.toString(isStreamed));
I'm now seeing this "pricing-streamed" value (and a couple others I also added in code this way) showing up in traces at code-level under a category "Metadata" on the Jersey AbstractJavaResourceMethodDispatcher dispatch call:
But I'm not seeing "pricing-streamed" as an option for the same traces when using the "Request attribute" filter for the service these traces show up under:
So, how would I be able to filter to requests using this "pricing-streamed" request attribute?
I suspect perhaps there's something we need to adjust administratively? It sounds like for OTEL, at least, some kind of promotion to request attribute is required? But I'm using OneAgent SDK alone, and documentation, and method name "addCustomRequestAttribute" make it sound about as simple as what I've done - I've added a custom request attribute, how do I get it visible as a request attribute?
What am I missing?
Solved! Go to Solution.
08 Jan 2025 09:39 AM
Hello! Everything is done correctly, except that on the Dynatrace side, this attribute needs to be added and the type SDK custom attrubute should be specified
More screenshots in blog.
Hope it helps.
Regards,
Alex Romanenkov
08 Jan 2025 03:53 PM - edited 08 Jan 2025 03:54 PM
Ah, excellent, thanks Alex. I knew I was missing something. (I can't access those screens, so I was relying on the documentation starting from the SDK documentation, and didn't find this blog post. It's pretty sparse linkage in that direction, only 4 results for https://www.google.com/search?q=dynatrace+%22SDK+custom+attribute%22+github, I'll submit a documentation PR to help with this.)
Featured Posts