|
| 1 | +--- |
| 2 | +navigation_title: Collector doesn’t propagate metadata |
| 3 | +description: Learn why the Collector doesn’t extract custom attributes and how to propagate such values using EDOT SDKs. |
| 4 | +applies_to: |
| 5 | + stack: |
| 6 | + serverless: |
| 7 | + observability: |
| 8 | + product: |
| 9 | + edot_collector: ga |
| 10 | +products: |
| 11 | + - id: cloud-serverless |
| 12 | + - id: observability |
| 13 | + - id: edot-collector |
| 14 | +--- |
| 15 | + |
| 16 | +# EDOT Collector doesn’t propagate client metadata |
| 17 | + |
| 18 | +By default, the Collector only propagates transport-level metadata. If you want the EDOT Collector to propagate metadata like `project_id`, `tenant`, or `environment`, you need a specific SDK instrumentation. |
| 19 | + |
| 20 | +### What is client metadata |
| 21 | + |
| 22 | +In the context of the EDOT, client metadata refers to gRPC metadata or HTTP headers that accompany telemetry data sent by clients (usually SDKs) to the Collector. |
| 23 | + |
| 24 | +For example: |
| 25 | + |
| 26 | +- Authorization headers |
| 27 | +- Trace propagation headers |
| 28 | +- `user-agent` strings sent by HTTP clients or EDOT SDKs |
| 29 | + |
| 30 | +This is transport-level metadata, and not application-level context. |
| 31 | + |
| 32 | +### What isn’t client metadata |
| 33 | + |
| 34 | +In this context, client metadata does not include: |
| 35 | + |
| 36 | +- Custom attributes like `project_id`, `tenant`, or `environment` |
| 37 | +- Application business logic fields |
| 38 | +- Resource attributes |
| 39 | + |
| 40 | +## Symptoms |
| 41 | + |
| 42 | +Expected labels do not appear in Elastic APM or metric data. |
| 43 | + |
| 44 | +Your collector configuration file, for example `otel-config.yaml`, looks similar to this: |
| 45 | + |
| 46 | +```yaml |
| 47 | +receivers: |
| 48 | + otlp: |
| 49 | + protocols: |
| 50 | + http: |
| 51 | + endpoint: "0.0.0.0:4318" |
| 52 | + |
| 53 | +processors: |
| 54 | + resource: |
| 55 | + attributes: |
| 56 | + - key: project.id |
| 57 | + from_context: client_metadata |
| 58 | + action: insert |
| 59 | +``` |
| 60 | +
|
| 61 | +This will not work, as the Collector doesn't automatically extract such values from headers. |
| 62 | +
|
| 63 | +## Resolution |
| 64 | +
|
| 65 | +If you want to propagate customer IDs or project names into spans or metrics, you must instrument this in your code using one of the SDKs. |
| 66 | +
|
| 67 | +Use `span.set_attribute` in your application code, where OpenTelemetry spans are created. For example: |
| 68 | + |
| 69 | +```python |
| 70 | +from opentelemetry import trace |
| 71 | +
|
| 72 | +tracer = trace.get_tracer(__name__) |
| 73 | +
|
| 74 | +with tracer.start_as_current_span("handle_request") as span: |
| 75 | + span.set_attribute("project.id", get_project_id_from_context()) |
| 76 | +``` |
| 77 | + |
| 78 | +## Resources |
| 79 | + |
| 80 | +- [gRPC metadata documentation](https://grpc.io/docs/guides/concepts/#metadata) |
| 81 | +- [OpenTelemetry Protocol (OTLP) overview](https://opentelemetry.io/docs/specs/otlp/) |
0 commit comments