Skip to content

Commit

Permalink
Merge branch 'main' into kubecon-china-blog
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffany76 authored Jun 26, 2024
2 parents d0519a7 + 2675bb4 commit 3fb6ac2
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 45 deletions.
83 changes: 44 additions & 39 deletions content/en/docs/concepts/signals/baggage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,52 @@ weight: 4
description: Contextual information that is passed between signals.
---

In OpenTelemetry, Baggage is contextual information that’s passed between spans.
It's a key-value store that resides alongside span context in a trace, making
values available to any span created within that trace.
In OpenTelemetry, Baggage is contextual information that resides next to
context. Baggage is a key-value store, which means it lets you
[propagate](/docs/concepts/context-propagation/#propagation) any data you like
alongside [context](/docs/concepts/context-propagation/#context).

For example, imagine you want to have a `ClientId` attribute on every span in
your trace, which involves multiple services; however, `ClientId` is only
available in one specific service. To accomplish your goal, you can use
OpenTelemetry Baggage to propagate this value across your system.
Baggage means you can pass data across services and processes, making it
available to add to [traces](/docs/concepts/signals/traces/),
[metrics](/docs/concepts/signals/metrics/), or
[logs](/docs/concepts/signals/logs/) in those services.

OpenTelemetry uses
[Context Propagation](/docs/concepts/signals/traces/#context-propagation) to
pass Baggage around, and each of the different library implementations has
propagators that parse and make that Baggage available without you needing to
explicitly implement it.
## Example

![OTel Baggage](/img/otel-baggage.svg)
Baggage is often used in tracing to propagate additional data across services.

For example, imagine you have a `clientId` at the start of a request, but you'd
like for that ID to be available on all spans in a trace, some metrics in
another service, and some logs along the way. Because the trace may span
multiple services, you need some way to propagate that data without copying the
`clientId` across many places in your codebase.

## Why does OTel Baggage exist?
By using
[Context Propagation](/docs/concepts/signals/traces/#context-propagation) to
pass baggage across these services, the `clientId` is available to add to any
additional spans, metrics, or logs. Additionally, instrumentations automatically
propagate baggage for you.

Baggage provides a uniform way to store and propagate information across a trace
and other signals. For example, you may want to attach information from your
application to a span and retrieve that information much later and use it later
on with another span. However, spans in OpenTelemetry are immutable once
created, and can be exported before you need information on them later on.
Baggage allows you to work around this problem by providing a place to store and
retrieve information.
![OTel Baggage](/img/otel-baggage.svg)

## What should OTel Baggage be used for?

Common use cases include information that’s only accessible further up a stack.
This can include things like Account Identification, User IDs, Product IDs, and
origin IPs, for example. Passing these down your stack allows you to then add
them to your Spans in downstream services to make it easier to filter when
you’re searching in your Observability backend.
Baggage is best used to include information typically available only at the
start of a request further downstream. This can include things like Account
Identification, User IDs, Product IDs, and origin IPs, for example.

Propagating this information using baggage allows for deeper analysis of
telemetry in a backend. For example, if you include information like a User ID
on a span that tracks a database call, you can much more easily answer questions
like "which users are experiencing the slowest database calls?" You can also log
information about a downstream operation and include that same User ID in the
log data.

![OTel Baggage](/img/otel-baggage-2.svg)

## Baggage security considerations

Sensitive Baggage items could be shared with unintended resources, like
Sensitive Baggage items can be shared with unintended resources, like
third-party APIs. This is because automatic instrumentation includes Baggage in
most of your service’s network requests. Specifically, Baggage and other parts
of trace context are sent in HTTP headers, making it visible to anyone
Expand All @@ -52,22 +58,21 @@ then this risk may not apply, but keep in mind that downstream services could
propagate Baggage outside your network.

Also, there are no built-in integrity checks to ensure that Baggage items are
yours, so exercise caution when retrieving them.
yours, so exercise caution when reading them.

## Baggage is not the same as Span attributes
## Baggage is not the same as attributes

One important thing to note about Baggage is that it is not a subset of the
[Span Attributes](/docs/concepts/signals/traces/#attributes). When you add
something as Baggage, it does not automatically end up on the Attributes of the
child system’s spans. You must explicitly take something out of Baggage and
append it as Attributes.
An important thing to note about baggage is that it is a separate key-value
store and is unassociated with attributes on spans, metrics, or logs without
explicitly adding them.

For example, in .NET you might do this:
To add baggage entries to attributes, you need to explicitly read the data from
baggage and add it as attributes to your spans, metrics, or logs.

```csharp
var accountId = Baggage.GetBaggage("AccountId");
Activity.Current?.SetTag("AccountId", accountId);
```
Because a common use cases for Baggage is to add data to
[Span Attributes](/docs/concepts/signals/traces/#attributes) across a whole
trace, several languages have Baggage Span Processors that add data from baggage
as attributes on span creation.

> For more information, see the [baggage specification][].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ Importing the `opentelemetry-bom` and `opentelemetry-instrumentation-bom-alpha`
BOMs when using the OpenTelemetry starter is important to ensure version
alignment across all OpenTelemetry dependencies.

The following example shows how to import both BOMs using Maven:
{{% alert title="Note" color="info" %}}

If you import the `spring-boot-dependencies` BOM, you have to declare it after
the OpenTelemetry BOMs.

{{% /alert %}}

The following example shows how to import the OpenTelemetry BOMs using Maven:

```xml
<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion data/registry/exporter-js-instana.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ createdAt: 2022-04-18
package:
registry: npm
name: '@instana/opentelemetry-exporter'
version: 3.13.0
version: 3.14.0
2 changes: 1 addition & 1 deletion data/registry/instrumentation-js-langchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ createdAt: 2024-06-05
package:
registry: npm
name: '@arizeai/openinference-instrumentation-langchain'
version: 0.0.6
version: 0.0.8
2 changes: 1 addition & 1 deletion data/registry/instrumentation-js-openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ createdAt: 2024-06-05
package:
registry: npm
name: '@arizeai/openinference-instrumentation-openai'
version: 0.3.1
version: 0.3.3
2 changes: 1 addition & 1 deletion data/registry/instrumentation-js-prisma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ createdAt: 2022-08-25
package:
registry: npm
name: '@prisma/instrumentation'
version: 5.15.1
version: 5.16.0
2 changes: 1 addition & 1 deletion data/registry/tools-ruby-sentry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ createdAt: 2023-01-31
package:
registry: gems
name: sentry-opentelemetry
version: 5.17.3
version: 5.18.0

0 comments on commit 3fb6ac2

Please sign in to comment.