7.0 KiB
GCP Resource Detectors for OpenTelemetry
This module provides GCP resource detectors for OpenTelemetry.
The following OpenTelemetry semantic conventions will be detected:
Resource attribute | GCE | GKE | GCR | GCF | GAE |
---|---|---|---|---|---|
cloud.platform | gcp_compute_engine | gcp_kubernetes_engine | gcp_cloud_run | gcp_cloud_functions | gcp_app_engine |
cloud.provider | gcp | gcp | gcp | gcp | gcp |
cloud.account.id | auto | auto | auto | auto | auto |
cloud.availability_zone | auto | auto | auto | auto | auto |
cloud.region | auto | auto | auto | auto | auto |
host.id | auto | auto | |||
host.name | auto | auto | |||
host.type | auto | auto | |||
k8s.pod.name | downward API | ||||
k8s.namespace.name | downward API | ||||
k8s.container.name | hardcoded (manual) | ||||
k8s.cluster.name | auto | ||||
faas.name | auto | auto | auto | ||
faas.version | auto | auto | auto | ||
faas.instance | auto | auto | auto |
Setting Kubernetes attributes
This resource detector does not detect the following resource attributes
container.name
, k8s.pod.name
and k8s.namespace.name
. When using this detector,
you should use this in your Pod Spec to set these using
OTEL_RESOURCE_ATTRIBUTES
:
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NAMESPACE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CONTAINER_NAME
value: my-container-name
- name: OTEL_RESOURCE_ATTRIBUTES
value: k8s.pod.name=$(POD_NAME),k8s.namespace.name=$(NAMESPACE_NAME),k8s.container.name=$(CONTAINER_NAME)
Usage with Manual Instrumentation
It is recommended to use this resource detector with the OpenTelemetry Autoconfiguration SPI. The GCP resource detector automatically provides the detected resources via the autoconfigure-spi SDK extension.
For a reference example showcasing the detected resource attributes and usage with autoconfigure-spi
, see the Resource detection example.
Usage with Auto-Instrumentation
With the release of v2.2.0 of the OpenTelemetry Java Instrumentation, the GCP resource detector is now included with the Java agent.
For users of Java Agent v2.2.0 and later, the GCP resource detectors can be enabled by following the instructions provided in the agent configuration documentation.
Component Owners
- Josh Suereth, Google
- Pranav Sharma, Google
Learn more about component owners in component_owners.yml.