Skip to content

Commit 239e6a8

Browse files
authored
Update documentation around detecting k8s resource attributes (open-telemetry#1621)
1 parent 6069c1d commit 239e6a8

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

gcp-resources/README.md

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,37 @@ The following OpenTelemetry semantic conventions will be detected:
1414
| host.id | auto | auto | | | |
1515
| host.name | auto | auto | | | |
1616
| host.type | auto | auto | | | |
17-
| k8s.pod.name | | downward API or auto | | | |
17+
| k8s.pod.name | | downward API | | | |
1818
| k8s.namespace.name | | downward API | | | |
1919
| k8s.container.name | | hardcoded (manual) | | | |
2020
| k8s.cluster.name | | auto | | | |
2121
| faas.name | | | auto | auto | auto |
2222
| faas.version | | | auto | auto | auto |
2323
| faas.instance | | | auto | auto | auto |
2424

25-
## Downward API
25+
## Setting Kubernetes attributes
2626

27-
For GKE applications, some values must be passed via the environment variable using k8s
28-
"downward API". For example, the following spec will ensure `k8s.namespace.name` and
29-
`k8s.pod.name` are correctly discovered:
27+
This resource detector does not detect the following resource attributes
28+
`container.name`, `k8s.pod.name` and `k8s.namespace.name`. When using this detector,
29+
you should use this in your Pod Spec to set these using
30+
[`OTEL_RESOURCE_ATTRIBUTES`](https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable):
3031

3132
```yaml
32-
spec:
33-
containers:
34-
- name: my-application
35-
image: gcr.io/my-project/my-image:latest
36-
env:
37-
- name: POD_NAME
38-
valueFrom:
39-
fieldRef:
40-
fieldPath: metadata.name
41-
- name: NAMESPACE
42-
valueFrom:
43-
fieldRef:
44-
fieldPath: metadata.namespace
45-
- name: CONTAINER_NAME
46-
value: my-application
33+
env:
34+
- name: POD_NAME
35+
valueFrom:
36+
fieldRef:
37+
fieldPath: metadata.name
38+
- name: NAMESPACE_NAME
39+
valueFrom:
40+
fieldRef:
41+
fieldPath: metadata.namespace
42+
- name: CONTAINER_NAME
43+
value: my-container-name
44+
- name: OTEL_RESOURCE_ATTRIBUTES
45+
value: k8s.pod.name=$(POD_NAME),k8s.namespace.name=$(NAMESPACE_NAME),k8s.container.name=$(CONTAINER_NAME)
4746
```
4847
49-
Additionally, the container name will only be discovered via the environment variable `CONTAINER_NAME`
50-
which much be included in the environment.
51-
5248
## Usage with Manual Instrumentation
5349
5450
It is recommended to use this resource detector with the [OpenTelemetry Autoconfiguration SPI](https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md#resource-provider-spi). The GCP resource detector automatically provides the detected resources via the [autoconfigure-spi](https://github.com/open-telemetry/opentelemetry-java/tree/main/sdk-extensions/autoconfigure-spi) SDK extension.

gcp-resources/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,4 @@ dependencies {
2828
testImplementation("com.google.guava:guava")
2929

3030
testImplementation("org.junit.jupiter:junit-jupiter-api")
31-
testImplementation("io.opentelemetry:opentelemetry-sdk-testing")
3231
}

0 commit comments

Comments
 (0)