Skip to content
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

Log detected resources without triggering unresolved check #5545

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Mar 18, 2025

Fixes an issue where logging the detected resources triggered a warning that unresolved attributes have been accessed:

@dyladan dyladan requested a review from a team as a code owner March 18, 2025 21:03
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.95%. Comparing base (f4dd2a1) to head (8895e20).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5545   +/-   ##
=======================================
  Coverage   94.95%   94.95%           
=======================================
  Files         308      308           
  Lines        7927     7932    +5     
  Branches     1604     1605    +1     
=======================================
+ Hits         7527     7532    +5     
  Misses        400      400           
Files with missing lines Coverage Δ
...es/opentelemetry-resources/src/detect-resources.ts 88.00% <100.00%> (+3.00%) ⬆️
🚀 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.

Copy link
Contributor

Choose a reason for hiding this comment

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

This solves the issue, so I'm approving.

However, from offline discussion, I'd vote for just dropping the logResources call.

% cd metapackages/auto-instrumentation-node
% OTEL_LOG_LEVEL=debug node -r ./build/src/register.js test/test-app/app.js
...
ContainerDetector found resource. ResourceImpl {
  _rawAttributes: [ [ 'container.id', [Promise] ] ],
  _asyncAttributesPending: true,
  _memoizedAttributes: undefined
}
EnvDetector found resource. ResourceImpl {
  _rawAttributes: [],
  _asyncAttributesPending: false,
  _memoizedAttributes: undefined
}
HostDetector found resource. ResourceImpl {
  _rawAttributes: [
    [ 'host.name', 'peach.local' ],
    [ 'host.arch', 'arm64' ],
    [ 'host.id', [Promise] ]
  ],
  _asyncAttributesPending: true,
  _memoizedAttributes: undefined
}
...

Setting to OTEL_LOG_LEVEL=verbose then adds a second diag output for the detectors:

Trace: {
    "os.type": "darwin",
    "os.version": "24.3.0"
}
    at DiagConsoleLogger.verbose (/Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/api/build/src/diag/consoleLogger.js:46:40)
    at DiagAPI.verbose (/Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/api/build/src/api/diag.js:40:40)
    at /Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/resources/build/src/detect-resources.js:53:24
    at Array.forEach (<anonymous>)
    at logResources (/Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/resources/build/src/detect-resources.js:49:15)
    at detectResources (/Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/resources/build/src/detect-resources.js:39:5)
    at NodeSDK.start (/Users/trentm/src/opentelemetry-js-contrib/node_modules/@opentelemetry/sdk-node/build/src/sdk.js:225:83)
    at Object.<anonymous> (/Users/trentm/src/opentelemetry-js-contrib/metapackages/auto-instrumentations-node/build/src/register.js:27:9)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for putting the details here. I've approved both PRs as I think either one is fine. If we're still getting the main debug output then that's the important bit.

@dyladan
Copy link
Member Author

dyladan commented Mar 18, 2025

Created alternative #5546

@pichlermarc
Copy link
Member

closing in favor of #5546

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants