Skip to content
New issue

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

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

Already on GitHub? # to your account

Spec compliance for span and trace IDs #280

Merged
merged 20 commits into from
Jun 25, 2020
Merged

Spec compliance for span and trace IDs #280

merged 20 commits into from
Jun 25, 2020

Conversation

fbogsany
Copy link
Contributor

Fixes #232

@@ -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"
Copy link
Contributor Author

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.

Copy link
Member

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.

@fbogsany fbogsany marked this pull request as ready for review June 23, 2020 01:16
Copy link
Member

@mwear mwear left a 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"
Copy link
Member

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.

@fbogsany
Copy link
Contributor Author

👍 I created open-telemetry/opentelemetry-ruby-contrib#18 to track this.

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

Successfully merging this pull request may close these issues.

Spec compliance for in-memory representation of span and trace IDs
2 participants