elastic / elastic/apm

Baggage in APM Agents

Open
#757 1 comment 2 reactions 0 assignees View on GitHub
apm-agents meta
Dominant language
Gherkin
Stars
427
Forks
125
PR merge metrics
No merged PRs in 30d

Description

# Description

## Problem
The baggage concept allows users to propagate additional (custom) context downstream together with the tracing context. For example, when there are services
```
A -> B -> C
```
service A could propagate some information to B and C, that otherwise would be only available in the scope of A (e.g. user ID, device.id in case of mobile, some product ID, etc.). Such additional context can be extremely valuable when troubleshooting performance and reliability issues.

**_Example:_**
Let's assume in the scheme above, A is a mobile app that propagates a `device.id` (that is unique, but not attributable to a person, so no PII) through the baggage. C is some backend service on the downstream invocation path of A. Let's assume C has an increased error rate for the error group `XYZ`. With the baggage implementation, the `device.id` could be easily added as an additional label to all errors. Thus, just by counting the unique number of `device.id`s on `XYZ`, an SRE could easily answer the question on how many users (i.e. mobile devices) are affected by that error.

## Solution

- Create spec for APM agents
- Implement a baggage container as part of the tracing context. (Where / if possible reuse the implementation / SDK from OpenTelemetry).
- Propagate the baggage together with the tracing context ([see W3C SPEC](https://www.w3.org/TR/baggage/)) - in this iteration propagation should be implemented *only* for HTTP (in case propagation for other protocols implies additional work)
- We will use the OpenTelemetry API for baggage declaration. This requires bridging the OTel API Baggage Part to our internal implementation.
- Define config option(s) that would specify where to attach which baggage, something like:
- `baggage_to_attach_on_transactions = myBaggageKey_1, key_abc*`
- `baggage_to_attach_on_spans = [EMPTY]`
- `baggage_to_attach_on_errors = *`

## Spec Issue
- [ ] https://github.com/elastic/apm/issues/758 Milestone

## Agent Issues
- [ ] https://github.com/elastic/apm-agent-java/issues/3004 Milestone
- [ ] https://github.com/elastic/apm-agent-dotnet/issues/2001 Milestone
- [ ] https://github.com/elastic/apm-agent-nodejs/issues/3149 Milestone
- [ ] https://github.com/elastic/apm-agent-python/issues/1741 Milestone
- [ ] https://github.com/elastic/apm-agent-php/issues/859 Milestone

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.