Skip to content

chore(gcp-resource-detector): unit test to prevent a regression and ensure previously set attributes are not overwritten with blank values. #2755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ajbenjam
Copy link
Contributor

Which problem is this PR solving?

Short description of the changes

The GcpDetector should only set 'k8s.namespace.name' if the source environment variable is defined.

@ajbenjam ajbenjam requested a review from a team as a code owner March 13, 2025 20:18
Copy link

linux-foundation-easycla bot commented Mar 13, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: pichlermarc / name: Marc Pichler (0017b71)
  • ✅ login: ajbenjam / name: Adam Benjamin (d5a0bd1)
  • ✅ login: david-luna / name: David Luna (078777b)

@ajbenjam
Copy link
Contributor Author

/easycla

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.65%. Comparing base (19a2ad5) to head (078777b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2755   +/-   ##
=======================================
  Coverage   89.65%   89.65%           
=======================================
  Files         185      185           
  Lines        9034     9034           
  Branches     1852     1852           
=======================================
  Hits         8099     8099           
  Misses        935      935           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ajbenjam ajbenjam force-pushed the gcp-resource-detector-unit-test branch from 22b3ad3 to ae16321 Compare April 15, 2025 13:23
@ajbenjam ajbenjam force-pushed the gcp-resource-detector-unit-test branch from ae16321 to 64b3255 Compare April 22, 2025 13:41
Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Looks like this PR is approved but tests are failing as the merge from main included the update from @opentelemetry/resources@1.x to @opentelemetry/resources@2.x - please update the tests, then we can get this merged (see comment below) 🙂

…nsure previously set attributes are not overwritten with blank values.

When attributes have already been set by other detectors, such as the EnvDetector, when the GcpDetector is run, it should not overwrite an existing attribute with a blank value if the source environment variable doesn't exist.

Prior to commit 143a1f4, the behavior was as follows:
- OTEL_RESOURCE_ATTRIBUTES = 'k8s.namespace.name=my-namespace'
- NAMESPACE is undefined
- EnvDetector runs and adds 'k8s.namespace.name=my-namespace' to attributes list
- GcpDetector runs and sets 'k8s.namespace.name=' (blank)

The GcpDetector should only set 'k8s.namespace.name' if the source environment variable is defined.
@ajbenjam ajbenjam force-pushed the gcp-resource-detector-unit-test branch from 0763b98 to d5a0bd1 Compare May 15, 2025 14:58
@david-luna david-luna enabled auto-merge (squash) May 28, 2025 18:33
@david-luna david-luna merged commit 33337d4 into open-telemetry:main May 28, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants