17 Apr 2024 04:52 PM - last edited on 18 Apr 2024 08:05 AM by MaciejNeumann
Sorry if this has been asked before but this is a hard topic to search for. Most of the results I got were about applications doing "background tasks" that don't need traced. That is not the case for me.
We have a LOT of apps that do a divide-and-conquer approach to request processing. Example:
We'd like to have distributed tracing properly group all the sub-requests into a single trace so Davis can properly root-cause issues with the sub-requests. Right now, we're in a state where the parent request can experience a "problem" and that is all the information we get. The actual issue is in one of the sub-requests but we can't drill down into it.
With OpenTracing/Zipkin, this is a super easy problem to solve. We can just propagate the trace context to the sub-thread and all is well. With Dynatrace, I can't seem to find how to do that propagation with the trace context automatically created by Dynatrace.
So, my ask is: how can I manually propagate the automatically created trace context to a child thread without re-inventing tracing using OpenTracing?
Solved! Go to Solution.
06 May 2024 06:09 PM
Usually this should happen by default.
It looks like you are either using a framework that cannot be instrumented automatically by the injected OneAgent code module or you haven't enabled the appropriate (opt-in) OneAgent feature for it (check "Settings -> Preferences -> OneAgent features").
If it's the former case and assuming this is for a technology like Java, NodeJS, Go, PHP or .NET and you have some internal knowledge about the source code (either first-hand or via analysis of stack-traces/thread-dumps): One solution you can try is to create a custom service detection config on a (common) method/interface that gets called early in the sub-component which will run in a separate thread of the same process.
This can be done via "Settings -> Service Detection -> Custom service detection" and might require a restart of the instrumented process/service depending on the technology and/or your settings for option "Settings -> Server-side service monitoring -> Deep monitoring -> Real-time updates to Java and PHP services".
HTH
06 May 2024 06:38 PM
This is for Java and I do have full access to the source (having instrumented it for Zipkin before). Is there a code-based solution for this? I don't seem to have the proper level of access to see "Service Detection" and would rather empower Devs to be able to address this kind of situation on their own, as-needed.
06 May 2024 09:36 PM - edited 06 May 2024 09:38 PM
If you're looking to propagate the context in your code and have more control over your traces, I'd recommend trying either:
or
Additional doc: https://docs.dynatrace.com/docs/shortlink/otel-getstarted-otlpexport#export-to-oneagent-traces-only
07 May 2024 04:57 PM
The OneAgent SDK looks like it'll suit my needs perfect. I don't know why I didn't stumble across that on Google. Thank you!
07 May 2024 05:54 PM
Glad, it was helpful.
You might not have as much freedom propagating the context with the OneAgent SDK. So, if you ever decide to use OpenTelemetry instead, just note that OTel is an open standard backed by the CNCF and Dynatrace is one of the top contributors to the project, so it's also a very valid alternative for this case.
Here's a blog post about this: https://www.dynatrace.com/news/blog/opentelemetry-observability-and-dynatrace-for-answers-at-scale/
07 May 2024 06:15 PM
I'll have to give that blog post a read. I love OTel but was under the impression that OTel traces and Dynatrace-agent traces couldn't interop? Meaning, I couldn't add a span to an existing Dynatrace trace using OTel. The only option for custom spans like that is the OneAgent SDK. Additionally, it incurred extra cost to report OTel traces to Dynatrace?