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

Add baggage implementation based on the W3C and OpenTelemetry specification #1967

Merged
merged 24 commits into from Jun 8, 2021

Conversation

MrAlias
Copy link
Contributor

@MrAlias MrAlias commented Jun 3, 2021

Related Docs

Changes

Added

  • The Baggage, Member, and Property types are added to the go.opentelemetry.io/otel/baggage package along with their related functions.
  • The new ContextWithBaggage, ContextWithoutBaggage, and FromContext functions were added to the go.opentelemetry.io/otel/baggage package. These functions replace the Set, Value, ContextWithValue, ContextWithoutValue, and ContextWithEmpty functions from that package and directly work with the new Baggage type.

Changed

  • The internal baggage package is refactored to be the minimal types needed to work with baggage and context. This package was persisted to maintain the OpenTracing bridge's ability to synchronize state with any baggage updates using hooks.

Removed

  • The Set, Value, ContextWithValue, ContextWithoutValue, and ContextWithEmpty functions in the go.opentelemetry.io/otel/baggage package are removed. Handling of baggage is now done using the added Baggage type and related context functions (ContextWithBaggage, ContextWithoutBaggage, and FromContext) in that package.

Related Issues

Resolves #1539

@MrAlias MrAlias added release:1.0.0-rc.1 area:baggage Part of OpenTelemetry baggage labels Jun 3, 2021
@MrAlias MrAlias added this to the RC1 milestone Jun 3, 2021
@MrAlias MrAlias added this to In progress in OpenTelemetry Go RC via automation Jun 3, 2021
@MrAlias MrAlias requested a review from XSAM as a code owner June 3, 2021 19:22
@codecov
Copy link

codecov bot commented Jun 3, 2021

Codecov Report

Merging #1967 (aca26ac) into main (4949bf0) will increase coverage by 0.6%.
The diff coverage is 89.7%.

Impacted file tree graph

@@           Coverage Diff           @@
##            main   #1967     +/-   ##
=======================================
+ Coverage   76.5%   77.1%   +0.6%     
=======================================
  Files        160     161      +1     
  Lines       8495    8554     +59     
=======================================
+ Hits        6503    6602     +99     
+ Misses      1733    1696     -37     
+ Partials     259     256      -3     
Impacted Files Coverage Δ
bridge/opentracing/internal/mock.go 69.3% <31.5%> (-3.4%) ⬇️
bridge/opentracing/bridge.go 46.4% <45.4%> (-1.5%) ⬇️
baggage/baggage.go 98.9% <98.9%> (-1.1%) ⬇️
baggage/context.go 100.0% <100.0%> (ø)
internal/baggage/context.go 100.0% <100.0%> (ø)
propagation/baggage.go 100.0% <100.0%> (+13.6%) ⬆️
sdk/trace/batch_span_processor.go 87.1% <0.0%> (+1.5%) ⬆️

@MadVikingGod
Copy link
Contributor

This is a bikeshed comment, please feel free to disregard it.

The OTEL spec uses the language name/value pair for Member, and metadata for Property. I'm ok using the W3C names, but that won't be in line with otel.

CHANGELOG.md Outdated Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
@MrAlias
Copy link
Contributor Author

MrAlias commented Jun 3, 2021

This is a bikeshed comment, please feel free to disregard it.

The OTEL spec uses the language name/value pair for Member, and metadata for Property. I'm ok using the W3C names, but that won't be in line with otel.

I don't have strong feelings here. I'll rename.

@MrAlias
Copy link
Contributor Author

MrAlias commented Jun 3, 2021

This is a bikeshed comment, please feel free to disregard it.
The OTEL spec uses the language name/value pair for Member, and metadata for Property. I'm ok using the W3C names, but that won't be in line with otel.

I don't have strong feelings here. I'll rename.

Digging into this I might have stronger feelings.

The validation errors we return reference W3C terms. The OpenTelemetry specification says nothing about these kinds of errors other than the W3C specification needs to be implemented. It seems prudent to give error messages relevant to the error meaning they will be in terms of the W3C.

Additionally, the OpenTelemetry specification terms are only partially prescriptive in the areas it does specify. The name/value paradigm is not specified for Metadata meaning that we would provide an interface with assumed names. This will be confusing if we are saying the name passed does not match the W3C specification, but the specification calls it a key.

There have been prior discussions in the specification SIG about name choices, and the guidance has been to follow it when it makes sense. I don't think it makes sense here, and there are examples of other SIGs making similar choices and the inconsistency of introducing the terms in some places and not others will lead to confusion. For these reasons I'm going to stick with the current naming.

Copy link
Contributor

@MadVikingGod MadVikingGod left a comment

Choose a reason for hiding this comment

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

Just some minor notes.

Like I said that is a bikeshed comment. I personally think that we should try to keep to W3C, but that might put us at odds eventually.

baggage/baggage_test.go Outdated Show resolved Hide resolved
baggage/baggage_test.go Outdated Show resolved Hide resolved
baggage/baggage_test.go Outdated Show resolved Hide resolved
Comment on lines +48 to +54
errInvalidKey = errors.New("invalid key")
errInvalidValue = errors.New("invalid value")
errInvalidProperty = errors.New("invalid baggage list-member property")
errInvalidMember = errors.New("invalid baggage list-member")
errMemberNumber = errors.New("too many list-members in baggage-string")
errMemberBytes = errors.New("list-member too large")
errBaggageBytes = errors.New("baggage-string too large")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, If these are unexported we can't match against them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm fine exporting if we see a need from users here. I didn't want to pollute the API and would prefer to have user need before doing so. As for matching, I figured only the local unit tests would need to do this, but do you think there is already a need that motivate these being exported?

baggage/baggage.go Show resolved Hide resolved
OpenTelemetry Go RC automation moved this from In progress to Reviewer approved Jun 5, 2021
baggage/baggage.go Show resolved Hide resolved
baggage/baggage.go Show resolved Hide resolved
baggage/baggage.go Outdated Show resolved Hide resolved
@MrAlias MrAlias merged commit 4bf6150 into open-telemetry:main Jun 8, 2021
OpenTelemetry Go RC automation moved this from Reviewer approved to Done Jun 8, 2021
@MrAlias MrAlias deleted the baggage-str branch June 8, 2021 15:06
@Aneurysm9 Aneurysm9 mentioned this pull request Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:baggage Part of OpenTelemetry baggage
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

TraceState/Baggage fields currently should only accept string-string pairs
3 participants