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

Do not log detected resource #5546

Merged

Conversation

dyladan
Copy link
Member

@dyladan dyladan commented Mar 18, 2025

This removes the logResources call which was triggering a warning that asynchronous resources were accessed before being resolved. Alternative to #5545


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)

Originally posted by @trentm in #5545 (comment)

Verified

This commit was signed with the committer’s verified signature.
vladfrangu Vlad Frangu
@dyladan dyladan requested a review from a team as a code owner March 18, 2025 22:59

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

+1 to this option (rather than #5545)

@trentm trentm self-requested a review March 18, 2025 23:11
Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

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

Tests need to be updated to no longer expect the logged output.

@dyladan
Copy link
Member Author

dyladan commented Mar 18, 2025

Tests need to be updated to no longer expect the logged output.

Ah. I ran tests locally but only in the package I modified.

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 (7dbf271).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5546      +/-   ##
==========================================
- Coverage   94.95%   94.95%   -0.01%     
==========================================
  Files         308      308              
  Lines        7927     7921       -6     
  Branches     1604     1603       -1     
==========================================
- Hits         7527     7521       -6     
  Misses        400      400              
Files with missing lines Coverage Δ
...es/opentelemetry-resources/src/detect-resources.ts 78.57% <ø> (-6.43%) ⬇️
🚀 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
Member

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

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

The main difference between the two approaches is the extra log available when using verbose logging, which we're not sure is used anyway. So this just simplifies the code. Is that right?

@dyladan
Copy link
Member Author

dyladan commented Mar 19, 2025

Yes it removes the "feature" of verbosely logging the resource after detection, but actually it's a duplicate log anyway

@pichlermarc pichlermarc added this pull request to the merge queue Mar 19, 2025
Merged via the queue into open-telemetry:main with commit 378344a Mar 19, 2025
18 checks passed
@pichlermarc pichlermarc deleted the no-log-resource branch March 19, 2025 09:10
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.

None yet

4 participants