opentelemetry-js-contrib icon indicating copy to clipboard operation
opentelemetry-js-contrib copied to clipboard

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

Open ajbenjam opened this issue 9 months ago • 2 comments

Which problem is this PR solving?

  • This PR adds a unit test to prevent a regression in behavior that was present prior to commit 143a1f4f9d876e9d503937c1cd53391d3f771c05 (#2705)

Short description of the changes

  • Prior to commit 143a1f4f9d876e9d503937c1cd53391d3f771c05 (#2705), 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 avatar Mar 13 '25 20:03 ajbenjam

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: pichlermarc / name: Marc Pichler (0017b71344d2978876768a83dc158538b1a98358)
  • :white_check_mark: login: ajbenjam / name: Adam Benjamin (d5a0bd1f5cf4c5bca06e4059ec7d5ffb06315d3f)
  • :white_check_mark: login: david-luna / name: David Luna (078777bbdde5233c7f85eb5b989d6d2c50fc7548)

/easycla

ajbenjam avatar Mar 13 '25 20:03 ajbenjam

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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           
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Apr 08 '25 12:04 codecov[bot]