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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ajbenjam
Copy link

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: ajbenjam / name: Adam Benjamin (ae16321)

@ajbenjam
Copy link
Author

/easycla

Copy link

codecov bot commented Apr 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.31%. Comparing base (4b51e60) to head (22b3ad3).
Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2755      +/-   ##
==========================================
- Coverage   91.53%   91.31%   -0.23%     
==========================================
  Files         171      166       -5     
  Lines        8172     7861     -311     
  Branches     1660     1619      -41     
==========================================
- Hits         7480     7178     -302     
+ Misses        692      683       -9     

see 7 files with indirect coverage changes

🚀 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.

…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 22b3ad3 to ae16321 Compare April 15, 2025 13:23
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.

3 participants