Skip to content

Commit

Permalink
Renaming otcorrelations header to baggage (#1267)
Browse files Browse the repository at this point in the history
* Renaming otcorrelations header to baggage

* Update CHANGELOG.md

* cleanup comment
  • Loading branch information
alrex authored Oct 20, 2020
1 parent d6dd84f commit c9bc90b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- The function signature of the Span `AddEvent` method in `go.opentelemetry.io/otel` is updated to no longer take an unused context and instead take a required name and a variable number of `EventOption`s. (#1254)
- The function signature of the Span `RecordError` method in `go.opentelemetry.io/otel` is updated to no longer take an unused context and instead take a required error value and a variable number of `EventOption`s. (#1254)
- Move the `go.opentelemetry.io/otel/api/global` package to `go.opentelemetry.io/otel/global`. (#1262)
- Rename correlation context header from `"otcorrelations"` to `"baggage"` to match the OpenTelemetry specification. (#1267)

### Removed

Expand Down
4 changes: 1 addition & 3 deletions propagators/baggage.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (
"go.opentelemetry.io/otel/label"
)

// Temporary header name until W3C finalizes format.
// https://github.com/open-telemetry/opentelemetry-specification/blob/18b2752ebe6c7f0cdd8c7b2bcbdceb0ae3f5ad95/specification/correlationcontext/api.md#header-name
const baggageHeader = "otcorrelations"
const baggageHeader = "baggage"

// Baggage is a propagator that supports the W3C Baggage format.
//
Expand Down
12 changes: 6 additions & 6 deletions propagators/baggage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestExtractValidBaggageFromHTTPReq(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req.Header.Set("otcorrelations", tt.header)
req.Header.Set("baggage", tt.header)

ctx := context.Background()
ctx = prop.Extract(ctx, req.Header)
Expand Down Expand Up @@ -149,7 +149,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
req, _ := http.NewRequest("GET", "http://example.com", nil)
req.Header.Set("otcorrelations", tt.header)
req.Header.Set("baggage", tt.header)

ctx := baggage.NewContext(context.Background(), tt.hasKVs...)
wantBaggage := baggage.MapFromContext(ctx)
Expand Down Expand Up @@ -231,17 +231,17 @@ func TestInjectBaggageToHTTPReq(t *testing.T) {
ctx := baggage.ContextWithMap(context.Background(), baggage.NewMap(baggage.MapUpdate{MultiKV: tt.kvs}))
propagator.Inject(ctx, req.Header)

gotHeader := req.Header.Get("otcorrelations")
gotHeader := req.Header.Get("baggage")
wantedLen := len(strings.Join(tt.wantInHeader, ","))
if wantedLen != len(gotHeader) {
t.Errorf(
"%s: Inject otcorrelations incorrect length %d != %d.", tt.name, tt.wantedLen, len(gotHeader),
"%s: Inject baggage incorrect length %d != %d.", tt.name, tt.wantedLen, len(gotHeader),
)
}
for _, inHeader := range tt.wantInHeader {
if !strings.Contains(gotHeader, inHeader) {
t.Errorf(
"%s: Inject otcorrelations missing part of header: %s in %s", tt.name, inHeader, gotHeader,
"%s: Inject baggage missing part of header: %s in %s", tt.name, inHeader, gotHeader,
)
}
}
Expand All @@ -251,7 +251,7 @@ func TestInjectBaggageToHTTPReq(t *testing.T) {

func TestBaggagePropagatorGetAllKeys(t *testing.T) {
var propagator propagators.Baggage
want := []string{"otcorrelations"}
want := []string{"baggage"}
got := propagator.Fields()
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf("GetAllKeys: -got +want %s", diff)
Expand Down

0 comments on commit c9bc90b

Please sign in to comment.