diff --git a/daprdocs/content/en/operations/observability/tracing/tracing-overview.md b/daprdocs/content/en/operations/observability/tracing/tracing-overview.md index a5194a73086..4cd25bec668 100644 --- a/daprdocs/content/en/operations/observability/tracing/tracing-overview.md +++ b/daprdocs/content/en/operations/observability/tracing/tracing-overview.md @@ -110,6 +110,44 @@ If you decide to generate trace headers yourself, there are three ways this can Read [the trace context overview]({{< ref w3c-tracing-overview >}}) for more background and examples on W3C trace context and headers. +### Baggage Support + +Dapr supports propagating W3C Baggage alongside trace context. For details on the W3C Baggage specification, format, and how it works, see the [W3C Trace Context Overview]({{< ref "w3c-tracing-overview.md#w3c-baggage" >}}). + +#### Using Baggage with Dapr + +You can add baggage from your application by setting the appropriate HTTP header or gRPC metadata when calling Dapr. Dapr automatically propagates this baggage across subsequent service calls. + +**Setting Baggage** + +Set the `baggage` header (HTTP) or metadata (gRPC) in your requests to Dapr: + - For HTTP: Add the `baggage` header to your request. + - For gRPC: Add `baggage` key-value pairs to the outgoing context metadata. + +*HTTP Example:* +```http +POST /v1.0/invoke/serviceB/method/hello HTTP/1.1 +Content-Type: application/json +baggage: key1=value1,key2=value2 + +{ + "message": "Hello service B" +} +``` + +*gRPC Example (Go):* +```go +ctx = grpcMetadata.AppendToOutgoingContext(ctx, + "baggage", "key1=value1,key2=value2", + ) +``` + +#### Common Use Cases + +Baggage is useful for: +- Propagating user IDs or correlation IDs across services +- Passing tenant or environment information + ## Related Links - [Observability concepts]({{< ref observability-concept.md >}}) diff --git a/daprdocs/content/en/operations/observability/tracing/w3c-tracing-overview.md b/daprdocs/content/en/operations/observability/tracing/w3c-tracing-overview.md index 52eccbef4d5..4f08b81c562 100644 --- a/daprdocs/content/en/operations/observability/tracing/w3c-tracing-overview.md +++ b/daprdocs/content/en/operations/observability/tracing/w3c-tracing-overview.md @@ -73,6 +73,18 @@ tracestate: congo=t61rcWkgMzE [Learn more about the tracestate fields details](https://www.w3.org/TR/trace-context/#tracestate-header). +**Baggage header** + +Dapr supports [W3C Baggage](https://www.w3.org/TR/baggage/) for propagating key-value pairs alongside trace context. The baggage header allows you to attach metadata to trace context that needs to be propagated throughout your distributed system, such as user IDs, tenant information, or environment details. + +The header value follows the W3C Baggage specification format: + +``` +baggage: userId=alice,serverNode=DF%2028,isVIP=true +``` + +Multiple baggage headers are supported and will be combined according to the W3C specification. Dapr automatically propagates baggage headers across service calls. + {{% /codetab %}} @@ -81,6 +93,18 @@ tracestate: congo=t61rcWkgMzE In the gRPC API calls, trace context is passed through `grpc-trace-bin` header. +**Baggage metadata** + +Dapr supports [W3C Baggage](https://www.w3.org/TR/baggage/) for propagating key-value pairs alongside trace context. The baggage metadata allows you to attach metadata to trace context that needs to be propagated throughout your distributed system, such as user IDs, tenant information, or environment details. + +The metadata value follows the W3C Baggage specification format: + +``` +baggage: userId=alice,serverNode=DF%2028,isVIP=true +``` + +Multiple baggage metadata entries are supported and will be combined according to the W3C specification. Dapr automatically propagates baggage metadata across service calls. + {{% /codetab %}} {{< /tabs >}}