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

Remove dependency on opentelemetry-go #267

Merged
merged 3 commits into from
Aug 27, 2021
Merged

Conversation

paulosman
Copy link
Contributor

@paulosman paulosman commented Aug 25, 2021

The beeline currently has dependencies on multiple OpenTelemetry packages. These were introduced to provide support for parsing and generating trace context headers using W3C Trace Context and B3 header formats. This PR breaks that dependency by adding the following types (taken from opentelemetry-go) to the propagation package in the beeline:

  • TraceFlags - also exposed in propagation.PropagationContext
    • IsSampled() bool
    • WithSampled(sampled bool) TraceFlags
    • MarshalJSON() ([]byte, error)
    • String() string
  • FlagsSampled - a constant used in the TraceFlags bit-mask

Additionally, the parsing and generating logic for B3 headers has been taken from the OTel B3 propagator.

@paulosman paulosman requested a review from a team August 25, 2021 19:56
Move necessary types and parsing logic from OpenTelemetry propagators
and tracestate implementation into beeline so we can break the
dependency on the OTel packages.
@paulosman paulosman marked this pull request as ready for review August 25, 2021 21:16
@paulosman paulosman added status: review needed Changes need review. dependencies Pull requests that update a dependency file type: dependencies version: bump minor A PR that adds behavior, but is backwards-compatible. labels Aug 25, 2021
@@ -285,9 +283,10 @@ func TestB3TraceContext(t *testing.T) {
ParentID: "b7ad6b7169203331",
}
ctx, headers := MarshalB3TraceContext(context.Background(), prop)
assert.Equal(t, 4, len(headers), "B3 Trace Context should have three headers")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The text says "three" but the test used to assert 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vreynolds so funny enough, this was a bug. Because of this section of code in b3.go:

for _, key := range propagator.Fields() {
		headerMap[key] = supp.Get(key)
}

We were always setting x-b3-flags with no value. This is technically incorrect, so we're fixing the bug in this PR. I can't think of any functionality that would depend on this bug, since the header value doesn't exist.

propagation/w3c.go Outdated Show resolved Hide resolved
@paulosman paulosman merged commit fd45bc2 into main Aug 27, 2021
@paulosman paulosman deleted the paul.remove_otel_dependency branch August 27, 2021 16:14
@bdarfler bdarfler removed dependencies Pull requests that update a dependency file status: review needed Changes need review. type: dependencies labels Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version: bump minor A PR that adds behavior, but is backwards-compatible.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants