-
Notifications
You must be signed in to change notification settings - Fork 254
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
Spec compliance for span and trace IDs #280
Conversation
@@ -99,7 +99,7 @@ def stub_response(options) | |||
_(easy.instance_eval { @otel_span }).must_be_nil | |||
_( | |||
easy.instance_eval { @otel_original_headers['traceparent'] } | |||
).must_equal "00-#{span.trace_id}-#{span.span_id}-01" | |||
).must_equal "00-#{span.trace_id.unpack1('H*')}-#{span.span_id.unpack1('H*')}-01" |
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.
This is a very common pattern in the adapter tests. It’s worth thinking about extracting this to a helper in the API or SDK. It can be accomplished with something like:
OpenTelemetry::Trace::Propagation::TraceContext::TraceParent.from_context(span).to_s
but that’s pretty wordy, may not work exactly like this, and doesn’t really reveal the intent terribly well. Something like the following would be better:
OpenTelemetry::Trace.to_traceparent(trace_id: span.trace_id, span_id: span.span_id, sampled: true)
I guess that’s even longer, but I think it is clearer.
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.
+1 on wanting a helper. TBH, I like the first option better, because the second implicitly couples the Trace module to W3C trace context. Both are wordy, and I could see sticking it somewhere else altogether.
A related issue is that we don't have a good way to share a) test helpers, b) shared logic between adapters. We should think about how we want to solve that moving forward.
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.
LGTM. Ideally we'd introduce a helper for conversions and for the tests. I talk about this a little bit in a comment, but do not have concrete suggestion as of yet. We could decide go with this as is and make an issue to improve this later.
@@ -99,7 +99,7 @@ def stub_response(options) | |||
_(easy.instance_eval { @otel_span }).must_be_nil | |||
_( | |||
easy.instance_eval { @otel_original_headers['traceparent'] } | |||
).must_equal "00-#{span.trace_id}-#{span.span_id}-01" | |||
).must_equal "00-#{span.trace_id.unpack1('H*')}-#{span.span_id.unpack1('H*')}-01" |
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.
+1 on wanting a helper. TBH, I like the first option better, because the second implicitly couples the Trace module to W3C trace context. Both are wordy, and I could see sticking it somewhere else altogether.
A related issue is that we don't have a good way to share a) test helpers, b) shared logic between adapters. We should think about how we want to solve that moving forward.
👍 I created open-telemetry/opentelemetry-ruby-contrib#18 to track this. |
Fixes #232