Skip to main content

Overview

Baggage is a mechanism for propagating name-value pairs across service boundaries. It allows you to attach custom attributes to telemetry context that can be accessed by any service in the call chain.
Baggage is not automatically added to spans, metrics, or logs. You must explicitly read baggage entries and add them to your telemetry.

What is baggage?

Baggage is a set of key-value pairs that:
  • Travels with the context across process boundaries
  • Can be read and modified by any service
  • Follows the W3C Baggage specification
  • Has size and count limits for safety

Limits

  • Maximum entries: 64 key-value pairs
  • Maximum size: 8192 bytes total

Basic usage

Creating baggage

Reading baggage

Baggage with metadata

BaggageExt trait

The BaggageExt trait extends Context with baggage management:

Propagation

Baggage automatically propagates when using the BaggagePropagator:

Complete example

Service A (upstream)

Service B (downstream)

Common use cases

1. User identification

2. Request tracking

3. Feature flags

4. Multi-tenancy

Iterating over baggage

Adding baggage to telemetry

Add to spans

Add to metrics

Best practices

Keep baggage small - Baggage is sent with every request. Keep the size minimal to avoid network overhead.
No sensitive data - Baggage propagates across all services and may be logged. Never put passwords, tokens, or PII in baggage.
Explicit attachment - Remember that baggage values don’t automatically appear in telemetry. You must explicitly read and attach them.
Validation - Baggage keys must follow RFC2616 token format. Invalid keys are rejected.

Baggage vs span attributes

Propagators

Configure context propagation

Context propagation

Learn about context flow