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

X-B3-TraceId support for 8 bytes size as well as 16 bytes size #783

Open
rodmeneses opened this issue Jul 19, 2022 · 1 comment
Open

X-B3-TraceId support for 8 bytes size as well as 16 bytes size #783

rodmeneses opened this issue Jul 19, 2022 · 1 comment

Comments

@rodmeneses
Copy link

When trying to use ToHeaders.B3 , which is based on the X-B3-TraceId headers, the code is assuming that the traceId size must be 16 bytes.

The current X-B3-TraceId spec, clearly says that both 8 bytes and 16 bytes size are valid: https://github.com/openzipkin/b3-propagation#traceid

As a workaround, I tried creating my own ToHeaders but I was unable to do so, as the TraceId case class constructor is private. There's an apply Method: apply: Option[TraceId] that will give you None if the size is not 16

def apply(array: Array[Byte]): Option[TraceId] =
    if (array.length == size) Some(new TraceId(array)) else None

where size is initialized at 16 on the TraceId object

I think that

private[trace4cats] class B3ToHeaders extends ToHeaders {

implementation should allow using TraceId of 8 bytes as well of 16 bytes

@janstenpickle
Copy link
Collaborator

Thanks @rodmeneses, I think we may still need to make this 16 bytes for some of the downstream exporter implementations. I can check after the 0.14 release.

In the meantime could you try padding the remaining 8bytes? Hopefully that doesn't break the rest of your tracing sytem

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

No branches or pull requests

2 participants