opentelemetry-operator icon indicating copy to clipboard operation
opentelemetry-operator copied to clipboard

Support adding custom labels to instrumented Pods

Open oncipriani opened this issue 2 months ago • 3 comments

Component(s)

auto-instrumentation

Is your feature request related to a problem? Please describe.

We need to identify all Pods that were auto-instrumented by the OpenTelemetry Operator.

Describe the solution you'd like

If during the instrumentation injection process a custom label was added to the Pod metadata, this would be trivial.

Suggestion:

apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
  name: my-instrumentation
spec:
  podMetadata:
    labels:
      custom-label-key: custom-label-value
  sampler:
    argument: "0.01"
    type: parentbased_traceidratio

Even a non-configurable static label like instrumentation.opentelemetry.io/injected: "true" or instrumentation.opentelemetry.io/name: "namespace/name of the injected instrumentation" would be of great value to us.

Describe alternatives you've considered

I tried selecting Pods with any of the instrumentation.opentelemetry.io/inject-* annotations, but labels are easier to filter by.

Also, having a single label to consider is much simpler and faster than checking for all the possible instrumentation.opentelemetry.io/inject-* annotations.

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

oncipriani avatar Oct 20 '25 21:10 oncipriani

This would be possible with https://github.com/open-telemetry/opentelemetry-operator/issues/821

pavolloffay avatar Oct 21 '25 10:10 pavolloffay

Is there an idiomatic mechanism to represent this kind of relationship in Kubernetes? I'm not sure labels are the right one. As Pavol noted, we do have plans to use labels to select Pods slated for instrumentation, but that's different from Pods which were actually instrumented. We could add a label or annotation containing the name(s) of Instrumentations used for a given Pod.

swiatekm avatar Oct 23 '25 15:10 swiatekm

This is related to https://github.com/open-telemetry/opentelemetry-operator/issues/1142

pavolloffay avatar Oct 23 '25 16:10 pavolloffay