Skip to content

set service.instance.id and k8s.pod.uid on OTel metrics resource - #448

Open
jaylonmcshan19-x wants to merge 2 commits into
mainfrom
fix-otel-service-instance-id
Open

set service.instance.id and k8s.pod.uid on OTel metrics resource#448
jaylonmcshan19-x wants to merge 2 commits into
mainfrom
fix-otel-service-instance-id

Conversation

@jaylonmcshan19-x

Copy link
Copy Markdown
Contributor

PCI review checklist

This PR adds service.instance.id to the OTel metrics resource, and k8s.pod.uid when we're
running in k8s.

right now resource.NewSchemaless only sets service.name and service.version, so every
replica sends an identical resource and Instana collapses them into a single entity.
in prod all 6 pods show up as one entity id. we can't tell replicas apart, and the entity never links to a k8s pod,
which is why none of the kubernetes.* tags are available when attempting to build dashboard widgets.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@jaylonmcshan19-x
jaylonmcshan19-x requested a review from a team as a code owner August 5, 2026 16:30
Comment thread pkg/client/metrics.go
Comment on lines +21 to +22
ServiceInstanceID string // ServiceInstanceID uniquely identifies this running instance, so replicas don't collapse into one entity
K8sPodUID string // K8sPodUID links the instance to its Kubernetes pod. Empty when not running in Kubernetes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each of these does effectively the same thing: uniquely identify a replica of the server.

I don't think we need to be K8s specific with this. We can just have one env var OTEL_INSTANCE_ID which when running in K8s can be populated like this:

https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants