GCP Resource Detectors for OpenTelemetry

June 19, 2026 ยท View on GitHub

Maven

This module provides GCP resource detectors for OpenTelemetry.

The following OpenTelemetry semantic conventions will be detected:

Resource attributeGCEGKEGCRGCFGAE
cloud.platformgcp_compute_enginegcp_kubernetes_enginegcp_cloud_rungcp_cloud_functionsgcp_app_engine
cloud.providergcpgcpgcpgcpgcp
cloud.account.idautoautoautoautoauto
cloud.availability_zoneautoautoautoautoauto
cloud.regionautoautoautoautoauto
host.idautoauto
host.nameautoauto
host.typeautoauto
k8s.pod.namedownward API
k8s.namespace.namedownward API
k8s.container.namehardcoded (manual)
k8s.cluster.nameauto
faas.nameautoautoauto
faas.versionautoautoauto
faas.instanceautoautoauto

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 SDK autoconfiguration. 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

Learn more about component owners in component_owners.yml.