Skip to content

Modify logic to ensure that the cloud_RoleInstance gets populated with the k8 pod name if specified#45884

Open
rads-1996 wants to merge 3 commits intoAzure:mainfrom
rads-1996:fix-cloudRoleInstance-population
Open

Modify logic to ensure that the cloud_RoleInstance gets populated with the k8 pod name if specified#45884
rads-1996 wants to merge 3 commits intoAzure:mainfrom
rads-1996:fix-cloudRoleInstance-population

Conversation

@rads-1996
Copy link
Member

@rads-1996 rads-1996 commented Mar 24, 2026

Description

Fixes - #45532

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@github-actions github-actions bot added the Monitor - Exporter Monitor OpenTelemetry Exporter label Mar 24, 2026
@rads-1996 rads-1996 force-pushed the fix-cloudRoleInstance-population branch from 8185850 to 12cf11f Compare March 24, 2026 22:55
@rads-1996
Copy link
Member Author

Since currently there is no resource detector logic available for AKS in Otel, the user will have to set the pod name in their configuration via the OTEL_RESOURCE_ATTRIBUTES and set that to dynamically pull the K8_POD_NAME -

Screenshot 2026-03-24 143150

The code has been modified so that the K8 pod name will have precedence and then the service instance id will be checked for.

BEFORE CHANGE -
image

AFTER CHANGE -
image

@rads-1996 rads-1996 marked this pull request as ready for review March 24, 2026 23:38
Copilot AI review requested due to automatic review settings March 24, 2026 23:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes cloud_RoleInstance resolution for Kubernetes/AKS by prioritizing the Kubernetes pod name when it is present, addressing inconsistent values caused by service.instance.id being set by resource detectors.

Changes:

  • Update role instance resolution order to prefer k8s.pod.name over service.instance.id.
  • Expand unit tests to cover the new precedence and fallback behaviors (pod name → service instance id → hostname).
  • Document the bug fix in the package changelog.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py Changes _get_cloud_role_instance() precedence to use Kubernetes pod name first.
sdk/monitor/azure-monitor-opentelemetry-exporter/tests/test_utils.py Updates/adds tests validating precedence and fallback behavior for role instance.
sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md Adds an unreleased bug-fix entry describing the precedence change.

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

Labels

Monitor - Exporter Monitor OpenTelemetry Exporter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants