-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
left-pad 64-bit B3 trace IDs #698
Conversation
sorry about the spam, editing from github web ui is annoying, but handy in a pinch |
@@ -88,8 +88,15 @@ func (b3 B3) Extract(ctx context.Context, supplier propagation.HTTPSupplier) con | |||
return ContextWithRemoteSpanContext(ctx, sc) | |||
} | |||
|
|||
func fixB3TID(in string) string { | |||
if len(in) == 16 { | |||
in = strings.Repeat("0", 16) + in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a const here instead of strings.Repeat
would be good for a future pass. There's a lot going on in Repeat
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I initially had strings.Repeat("0", 32-len(in))
but that failed the tests for invalid input IDs between 16 and 32 hex digits. I think it's more correct to only accept 16 or 32 hex digit values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary: OTel wants all trace ids to be 128bit. However b3 trace ids can be 64 bit. See https://github.com/openzipkin/b3-propagation#traceid-1 So we should also support propagating 64 bit trace IDs. To ensure compatibility with other OTel tooling, we left pad the trace IDs with zeroes and make it a 128 bit ID before passing it to the OTel endpoint. This mirrors the approach taken by open-telemetry/opentelemetry-go#698 Test Plan: Updated a test to use 64 bit trace ids and ensured that they get left padded with zeroes as expexted. Reviewers: nserrino, michelle, philkuz Reviewed By: philkuz JIRA Issues: PP-3407 Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D11450 GitOrigin-RevId: 9f09a7e
Summary: OTel wants all trace ids to be 128bit. However b3 trace ids can be 64 bit. See https://github.com/openzipkin/b3-propagation#traceid-1 So we should also support propagating 64 bit trace IDs. To ensure compatibility with other OTel tooling, we left pad the trace IDs with zeroes and make it a 128 bit ID before passing it to the OTel endpoint. This mirrors the approach taken by open-telemetry/opentelemetry-go#698 Test Plan: Updated a test to use 64 bit trace ids and ensured that they get left padded with zeroes as expexted. Reviewers: nserrino, michelle, philkuz Reviewed By: philkuz JIRA Issues: PP-3407 Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D11450 GitOrigin-RevId: 9f09a7e
Summary: OTel wants all trace ids to be 128bit. However b3 trace ids can be 64 bit. See https://github.com/openzipkin/b3-propagation#traceid-1 So we should also support propagating 64 bit trace IDs. To ensure compatibility with other OTel tooling, we left pad the trace IDs with zeroes and make it a 128 bit ID before passing it to the OTel endpoint. This mirrors the approach taken by open-telemetry/opentelemetry-go#698 Test Plan: Updated a test to use 64 bit trace ids and ensured that they get left padded with zeroes as expexted. Reviewers: nserrino, michelle, philkuz Reviewed By: philkuz JIRA Issues: PP-3407 Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D11450 GitOrigin-RevId: 9f09a7e
Summary: OTel wants all trace ids to be 128bit. However b3 trace ids can be 64 bit. See https://github.com/openzipkin/b3-propagation#traceid-1 So we should also support propagating 64 bit trace IDs. To ensure compatibility with other OTel tooling, we left pad the trace IDs with zeroes and make it a 128 bit ID before passing it to the OTel endpoint. This mirrors the approach taken by open-telemetry/opentelemetry-go#698 Test Plan: Updated a test to use 64 bit trace ids and ensured that they get left padded with zeroes as expexted. Reviewers: nserrino, michelle, philkuz Reviewed By: philkuz JIRA Issues: PP-3407 Signed-off-by: Vihang Mehta <[email protected]> Differential Revision: https://phab.corp.pixielabs.ai/D11450 GitOrigin-RevId: 9f09a7e
Fixes #686.