Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTSpanContex.toTraceId() truncates 128-bit TraceIds to 64-bit decimal. #7988

Open
LeifW opened this issue Nov 20, 2024 · 3 comments
Open

OTSpanContex.toTraceId() truncates 128-bit TraceIds to 64-bit decimal. #7988

LeifW opened this issue Nov 20, 2024 · 3 comments

Comments

@LeifW
Copy link

LeifW commented Nov 20, 2024

The toTraceId() method on OTSpanContext calls .toString() on the DDTraceId, which the Javadoc for says "Returns a 64-bit only decimal String representation of the DDTraceId".
So how do we get the original 128-bit hexadecimal TraceId?

@LeifW LeifW changed the title OTSpanContex.toTraceId() truncates 128-bit TraceIds. OTSpanContex.toTraceId() truncates 128-bit TraceIds to 64-bit decimal. Nov 20, 2024
@PerfectSlayer
Copy link
Contributor

Hello @LeifW

You cannot get the 128-bit trace identifier from the OpenTracing API. You will only have the 64 lower bits as an integer.
What is your use case that needs it?

@LeifW
Copy link
Author

LeifW commented Dec 3, 2024

We're using Datadog toTraceId wrapped in the Natchez library here: https://github.com/typelevel/natchez/blob/main/modules/datadog/src/main/scala/DDSpan.scala#L82
Would like to get that value as a string for correlating traceIds in our logs.

@PerfectSlayer
Copy link
Contributor

It seems you are using the dd-trace-api dependency too, right?
If so, you can call the static methods CorrelationIdentifier.getTraceId() and CorrelationIdentifier.getSpanId() to get the IDs to inject into logs.

OpenTelemetry API will also support the 128-bit trace IDs, but OpenTracing will only give you access to the first 64-bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants