Dynatrace / OneAgent-SDK-for-Java

Enables custom tracing of Java applications in Dynatrace
https://www.dynatrace.com/support/help/extend-dynatrace/oneagent-sdk/what-is-oneagent-sdk/
Apache License 2.0
33 stars 9 forks source link

Support for TraceContextInfo #30

Closed ewsachse closed 1 year ago

ewsachse commented 1 year ago

The main documentation shows the Trace Context functionality, but this is not available in the Java API. It looks like this is available in the Python and .NET APIs. Can you add this feature to the Java API?

https://github.com/Dynatrace/OneAgent-SDK#trace-context

Trace Context

An instance of the OneAgentSDK provides access to TraceContextInfo which holds information about the Trace-Id and Span-Id of the current PurePath node. This information can then be used to provide e.g. additional context in log messages.

Please note that TraceContextInfo is not intended for tagging or context-propagation use cases. Dedicated APIs (e.g. remote calls or web requests) as well as built-in OneAgent sensors take care of linking services correctly.

TraceContextInfo traceContextInfo = oneAgentSDK.getTraceContextInfo();
String traceId = traceContextInfo.getTraceId();
String spanId = traceContextInfo.getSpanId();
logger.info("[!dt dt.trace_id={},dt.span_id={}] sending request ...", traceId, spanId);
Oberon00 commented 1 year ago

I have good news for you: a new release of the OneAgent SDK for Java is already planned that will include support for this. While I can't promise anything, tentatively it is expected to happen in the next few weeks.

ewsachse commented 1 year ago

Thank you for the update. I will keep an eye out for the new release.

Oberon00 commented 1 year ago

1.9 with support for TraceContextInfo is now out: https://github.com/Dynatrace/OneAgent-SDK-for-Java/releases/tag/v1.9.0

If you have any trouble with the feature, please go through Dynatrace support or open a new issue.