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

fix(resources): wait for async attributes for detecting resources

Open ziolekjj opened this issue 9 months ago • 2 comments

Which problem is this PR solving?

Recently, HostDetector was added as default for detectors in NodeSDK, this produces the error message: Accessing resource attributes before async attributes settled, as detectResourcesSync is not waiting for async attributes to be resolved for HostDetector, what causes the lack of machine_id passed to it.

Fixes #4638

Short description of the changes

I've updated the test case for the issue and added an await statement to wait for async attributes to be resolved for the detectResourcesSync function.

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I've added unit tests, the configuration for reproducing is described in the linked issue #4638

  • [x] Updated a test to detect-resources.test.ts to reflect the behavior of the HostDetector with async attributes

ziolekjj avatar May 08 '24 17:05 ziolekjj

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: ziolekjj / name: Jakub Ziółkowski (a7044f3871389fdf3d692a98ab4e0173a1fa74bd, 56c21e9364bf4ced472986fdc20d1fd5477aa3ee, 7f4ed0859ecd7922f51aac50238176291cbda1ba, c64eee7e951448f88714e163772ecc422a670ec2)
  • :white_check_mark: login: david-luna / name: David Luna (daeb3f54235156e7d1cd1eae868527208adbb2ca)

Hey @pichlermarc, sorry for mentioning you; I'm not sure who would be the best person to ask for a review here, It still requires a code owner approval, is everything good here? I am happy to help with pushing this forward

ziolekjj avatar Jul 01 '24 16:07 ziolekjj

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Sep 09 '24 06:09 github-actions[bot]

any update for this MR?

today i'm using this workaround: https://github.com/open-telemetry/opentelemetry-js/issues/4638#issuecomment-2124030420

but after the merge of this change, i would like to remove them.

vNNi avatar Sep 25 '24 18:09 vNNi

Codecov Report

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

Project coverage is 93.27%. Comparing base (859c0ef) to head (c64eee7). Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4687      +/-   ##
==========================================
+ Coverage   93.26%   93.27%   +0.01%     
==========================================
  Files         317      317              
  Lines        8194     8195       +1     
  Branches     1640     1641       +1     
==========================================
+ Hits         7642     7644       +2     
+ Misses        552      551       -1     
Files with missing lines Coverage Δ
...es/opentelemetry-resources/src/detect-resources.ts 65.30% <100.00%> (+0.72%) :arrow_up:

... and 1 file with indirect coverage changes

codecov[bot] avatar Oct 03 '24 15:10 codecov[bot]

Failure on @opentelemetry/shim-opentracing tests which seems unrelated ref: https://github.com/open-telemetry/opentelemetry-js/actions/runs/11258351446/job/31405500619?pr=4687

 1 failing

  1) OpenTracing Shim
       TracerShim
         starting spans
           translates span options correctly:

      AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

+ 1728646076298.6538
- 1728646076298.6536
                   ^
      + expected - actual

      -1728646076298.6538
      +1728646076298.6536
      
      at Context.<anonymous> (test/Shim.test.ts:266:16)
      at processImmediate (node:internal/timers:483:21)

david-luna avatar Oct 11 '24 12:10 david-luna