opentelemetry-go-contrib icon indicating copy to clipboard operation
opentelemetry-go-contrib copied to clipboard

Request to Improve Namespace Detection in GKE Resource Detector

Open munagekar opened this issue 3 years ago • 3 comments
trafficstars

Background

  • I would like to request improved detection of namespace in the GKE resource detector. Currently it relies on the Namespace Environment Variable being available.

https://github.com/open-telemetry/opentelemetry-go-contrib/blob/1df0a9d437c51d6ee35a18dc9a02b33e4adbdf6f/detectors/gcp/gke.go#L52

However it is possible to detect this variable from inside the kubernetes pod. For example see the python implementation

https://github.com/GoogleCloudPlatform/opentelemetry-operations-python/blob/f66591e1362dd60982ee9ae511d4c36e63156e17/opentelemetry-resourcedetector-gcp/src/opentelemetry/resourcedetector/gcp_resource_detector/init.py#L78-L86

cc: @dashpole

munagekar avatar Jun 03 '22 05:06 munagekar

I can contribute to the efforts, if required, if you agree with the proposal.

munagekar avatar Jun 03 '22 05:06 munagekar

Previous iterations of GCP resource detection attempted to detect 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:

The Readme however asks users to set container.name,k8s.pod.name and k8s.namespace.name themselves. However k8s.pod.name and k8s.namespace.name can be detected automatically.

I would instead like to suggest that OTEL_RESOURCE_ATTRIBUTES be used as the primary source of attribute data if specified, but fallback to autodetection otherwise.

munagekar avatar Jun 03 '22 05:06 munagekar

Thats really neat. TIL. I think that makes sense to do, but I don't think it should be done in the GCP detector, since it isn't GCP-specific. Maybe we should integrate that idea into https://github.com/open-telemetry/oteps/pull/195

dashpole avatar Jun 03 '22 18:06 dashpole