feat(telemetry): auto detect google attributes (#12694)

# Which Problems Are Solved

We run multiple deployments (regions) under a single GCP project. Within
these deployments we scale containers. Currently all metrics target the
same time series in GCP, regardless or region or container. All metics
ended up in `generic_node` and Cloud Monitoring rejects the duplicate
and out-of-order points.

This can be fixed by setting vendor specific attributes such as
`faas.name` (K_SERVICE), `faas.version` (K_REVISION), `faas.instance`
(instance id from the metadata server), and `cloud.region` (metadata
instance/region).


# How the Problems Are Solved

Use `go.opentelemetry.io/contrib/detectors/gcp` to auto-detect values as
mentioned above. A new `Instrumentation.Detectors` config entry is
added, which accepts and array of enum for detecotrs. At the moment only
Google is accepted, other entries from
[contrib](https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/detectors)
can be added if deemed usefull.

I've considered using `autodetect` contrib package, identifiers and
constructor, but this pulls in the full AWS SDK, increasing zitadel's
binary size by 50MiB.

By default detection is switched off, as it relies on unauthenticated
link-local calls that are insecure anywhere outside of the
infrastructure it targets. It also prevents breaking existing
deployments that rely on detection being off already. (May break
existing trace and logging pipelines).

# Additional Changes

- none

# Additional Context

- (internal only): https://github.com/caos/infra/pull/1813

---------

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Co-authored-by: Claude Opus 5 <[email protected]>
This commit is contained in:
Tim Möhlmann
2026-09-07 12:14:09 +00:00
committed by GitHub
co-authored by Copilot Autofix powered by AI Claude Opus 5
parent 13948f2bcd
commit 8b87ca50d4
6 changed files with 336 additions and 10 deletions
+13
View File
@@ -1,5 +1,18 @@
Instrumentation:
ServiceName: "zitadel" # ZITADEL_INSTRUMENTATION_SERVICENAME
# Resource detectors describe the platform ZITADEL runs on. Their attributes
# are attached to every exported trace, metric and log, and telemetry backends
# use them to tell instances apart instead of merging them into one series.
# Detection is off by default: each detector probes its platform on startup and
# the attributes it finds identify the account and host to whichever backend
# you export to. Enable one or more of:
# "google": Detects Cloud Run, GKE, GCE, App Engine and Cloud Functions by
# querying the Google Cloud metadata server. Required when
# exporting to Google Cloud: without it every instance reports as
# the same empty generic_node and the series overlap.
# Leave the list empty to disable detection. An empty or unknown entry is a
# config error and fails startup.
Detectors: [] # ZITADEL_INSTRUMENTATION_DETECTORS (comma separated list)
Trace:
Fraction: 1.0 # ZITADEL_INSTRUMENTATION_TRACE_FRACTION
# Trust incoming trace context from remote services for distributed tracing.