You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2025-07-17 01:12:45 +02:00
Update correlation context header name
This commit is contained in:
@ -23,7 +23,9 @@ import (
|
|||||||
"go.opentelemetry.io/otel/api/propagation"
|
"go.opentelemetry.io/otel/api/propagation"
|
||||||
)
|
)
|
||||||
|
|
||||||
const correlationContextHeader = "Correlation-Context"
|
// Temporary header name until W3C finalizes format.
|
||||||
|
// https://github.com/open-telemetry/opentelemetry-specification/blob/18b2752ebe6c7f0cdd8c7b2bcbdceb0ae3f5ad95/specification/correlationcontext/api.md#header-name
|
||||||
|
const correlationContextHeader = "otcorrelations"
|
||||||
|
|
||||||
// CorrelationContext propagates Key:Values in W3C CorrelationContext
|
// CorrelationContext propagates Key:Values in W3C CorrelationContext
|
||||||
// format.
|
// format.
|
||||||
|
@ -89,7 +89,7 @@ func TestExtractValidDistributedContextFromHTTPReq(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
||||||
req.Header.Set("Correlation-Context", tt.header)
|
req.Header.Set("otcorrelations", tt.header)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = propagation.ExtractHTTP(ctx, props, req.Header)
|
ctx = propagation.ExtractHTTP(ctx, props, req.Header)
|
||||||
@ -133,7 +133,7 @@ func TestExtractInvalidDistributedContextFromHTTPReq(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
req, _ := http.NewRequest("GET", "http://example.com", nil)
|
||||||
req.Header.Set("Correlation-Context", tt.header)
|
req.Header.Set("otcorrelations", tt.header)
|
||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = propagation.ExtractHTTP(ctx, props, req.Header)
|
ctx = propagation.ExtractHTTP(ctx, props, req.Header)
|
||||||
@ -202,17 +202,17 @@ func TestInjectCorrelationContextToHTTPReq(t *testing.T) {
|
|||||||
ctx := correlation.ContextWithMap(context.Background(), correlation.NewMap(correlation.MapUpdate{MultiKV: tt.kvs}))
|
ctx := correlation.ContextWithMap(context.Background(), correlation.NewMap(correlation.MapUpdate{MultiKV: tt.kvs}))
|
||||||
propagation.InjectHTTP(ctx, props, req.Header)
|
propagation.InjectHTTP(ctx, props, req.Header)
|
||||||
|
|
||||||
gotHeader := req.Header.Get("Correlation-Context")
|
gotHeader := req.Header.Get("otcorrelations")
|
||||||
wantedLen := len(strings.Join(tt.wantInHeader, ","))
|
wantedLen := len(strings.Join(tt.wantInHeader, ","))
|
||||||
if wantedLen != len(gotHeader) {
|
if wantedLen != len(gotHeader) {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"%s: Inject Correlation-Context incorrect length %d != %d.", tt.name, tt.wantedLen, len(gotHeader),
|
"%s: Inject otcorrelations incorrect length %d != %d.", tt.name, tt.wantedLen, len(gotHeader),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
for _, inHeader := range tt.wantInHeader {
|
for _, inHeader := range tt.wantInHeader {
|
||||||
if !strings.Contains(gotHeader, inHeader) {
|
if !strings.Contains(gotHeader, inHeader) {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
"%s: Inject Correlation-Context missing part of header: %s in %s", tt.name, inHeader, gotHeader,
|
"%s: Inject otcorrelations missing part of header: %s in %s", tt.name, inHeader, gotHeader,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ func TestInjectCorrelationContextToHTTPReq(t *testing.T) {
|
|||||||
|
|
||||||
func TestTraceContextPropagator_GetAllKeys(t *testing.T) {
|
func TestTraceContextPropagator_GetAllKeys(t *testing.T) {
|
||||||
var propagator correlation.CorrelationContext
|
var propagator correlation.CorrelationContext
|
||||||
want := []string{"Correlation-Context"}
|
want := []string{"otcorrelations"}
|
||||||
got := propagator.GetAllKeys()
|
got := propagator.GetAllKeys()
|
||||||
if diff := cmp.Diff(got, want); diff != "" {
|
if diff := cmp.Diff(got, want); diff != "" {
|
||||||
t.Errorf("GetAllKeys: -got +want %s", diff)
|
t.Errorf("GetAllKeys: -got +want %s", diff)
|
||||||
|
Reference in New Issue
Block a user