cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the trace_id and span_id using the OneAgent SDK for Python?

AymericM
Participant

Hi,

I see in the OneAgent SDK documentation that there is a way to get a trace_i and span_id from the TraceContextInfo (https://github.com/Dynatrace/OneAgent-SDK/blob/master/README.md#trace-context)

I may be missing something but I can't find how to do it with the OneAgent SDK for Python.

Is there a way to enrich logs with trace_id and span_id dierctly from a Python script/app ?

3 REPLIES 3

Julius_Loman
DynaMight Legend
DynaMight Legend

Curious to know too - it seems the TraceContextInfo is implemented only in OneAgent SDK for .NET. OneAgent SDK for Python is based on the SDK for C/C++ which does not have the feature.

I suppose switching to OpenTelemetry is not a simple solution here as you likely already have your code dependent on OneAgent SDK. But in a long term I'd consider switching, since due to Otel being a vendor-angostic standard, OneAgent SDKs won't have much attention anymore.

FYI - @_Alexander_  - are they any plans to get the other SDKs on part with this feature (NodeJS/Java/C++)? 

Certified Dynatrace Master | Alanata a.s., Slovakia, Dynatrace Master Partner

Funny coincidence 🙂 we just did a POC using OpenTelemetry and decided we'll switch to it.

While searching the Dynatrace documentation we saw that a lot of it have changed toward pointing to Opentelemetry and tried  it.

arlindo
Dynatrace Advisor
Dynatrace Advisor

As @Julius_Loman mentioned - OpenTelemetry would be the immediate way to go. But the good news is that we're bringing TraceContextInfo to C/C++ and Python around the end of January. So, if you can wait until then, that's another way to go.

Featured Posts