Skip to content

Commit 844301b

Browse files
committed
introduce how to configure environment variable for OTEL trace
1 parent 224572c commit 844301b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

content/en/docs/concepts/cluster-administration/system-traces.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ with the gRPC exporter and can be collected and routed to tracing backends using
2222

2323
## Trace Collection
2424

25+
Kubernetes components have built-in grpc exporters for OTLP to export traces, either with an OpenTelemetry Collector,
26+
or without an OpenTelemetry Collector.
27+
2528
For a complete guide to collecting traces and using the collector, see
2629
[Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/).
2730
However, there are a few things to note that are specific to Kubernetes components.
@@ -47,6 +50,44 @@ service:
4750
exporters: [logging]
4851
```
4952
53+
To directly emit traces to a backend without utilizing a collector,
54+
specify the endpoint field in the Kubernetes TracingConfiguration with the desired trace backend address.
55+
This method negates the need for a collector and simplifies the overall structure.
56+
57+
For trace backend header configuration, including authentication details, environment variables can be used with `OTEL_EXPORTER_OTLP_HEADERS`,
58+
see [OTLP Exporter Configuration](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/).
59+
60+
Additionally, for trace resource attribute configuration such as Kubernetes cluster name, namespace, Pod name, etc.,
61+
environment variables can also be used with `OTEL_RESOURCE_ATTRIBUTES`, see [OTLP Kubernetes Resource](https://opentelemetry.io/docs/specs/semconv/resource/k8s/).
62+
63+
Below is an example that shows how to configure to emit traces directly to a backend.
64+
```yaml
65+
apiVersion: apps/v1
66+
kind: Deployment
67+
metadata:
68+
name: apiserver
69+
labels:
70+
component: apiserver
71+
spec:
72+
selector:
73+
matchLabels:
74+
component: apiserver
75+
template:
76+
metadata:
77+
labels:
78+
component: apiserver
79+
spec:
80+
containers:
81+
- name: apiserver
82+
env:
83+
- name: OTEL_EXPORTER_OTLP_HEADERS
84+
value: "<header_key1>=<header_value1>,<header_key2>=<header_value2>"
85+
- name: OTEL_RESOURCE_ATTRIBUTES
86+
value: "<resource_key1>=<resource_value1>,<resource_key1>=<resource_value1>"
87+
```
88+
Note: Replace header_key, header_value, resource_key, resource_value with your actual keys and values.
89+
90+
5091
## Component traces
5192

5293
### kube-apiserver traces
@@ -125,4 +166,6 @@ there are no guarantees of backwards compatibility for tracing instrumentation.
125166
## {{% heading "whatsnext" %}}
126167

127168
* Read about [Getting Started with the OpenTelemetry Collector](https://opentelemetry.io/docs/collector/getting-started/)
169+
* Read about [OTLP Exporter Configuration](https://opentelemetry.io/docs/languages/sdk-configuration/otlp-exporter/)
170+
128171

0 commit comments

Comments
 (0)