1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2026-06-03 18:35:08 +02:00
Files
opentelemetry-go/internal/global/util_test.go
T
Sam Xie aa1894e09e Comply with W3C Baggage specification limits (#7880)
Updates the baggage implementation to comply with
https://www.w3.org/TR/baggage/#limits:

- Changed maxMembers from 180 to 64 (the W3C compliance requirement)

  > The resulting baggage-string contains 64 list-members or less.

- Removed maxBytesPerMembers (4096) - this per-member limit was not part
of the W3C spec
- Added limit checking in extractMultiBaggage for multiple baggage
headers:
  - Checks combined byte size across all headers (max 8192 bytes)
  - Checks combined member count across all headers (max 64 members)

This uses non-deterministic truncation when handling baggage limits.
2026-02-28 20:15:17 +01:00

23 lines
534 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package global
import (
"sync"
"testing"
)
// ResetForTest configures the test to restores the initial global state during
// its Cleanup step.
func ResetForTest(t testing.TB) {
t.Cleanup(func() {
globalTracer = defaultTracerValue()
globalPropagators = defaultPropagatorsValue()
globalMeterProvider = defaultMeterProvider()
delegateTraceOnce = sync.Once{}
delegateTextMapPropagatorOnce = sync.Once{}
delegateMeterOnce = sync.Once{}
})
}