Skip to content

fix(api): Update DiagLogger to use original console methods#6395

Open
martinkuba wants to merge 3 commits intoopen-telemetry:mainfrom
martinkuba:diagnostics-logger-prevent-instrumentation
Open

fix(api): Update DiagLogger to use original console methods#6395
martinkuba wants to merge 3 commits intoopen-telemetry:mainfrom
martinkuba:diagnostics-logger-prevent-instrumentation

Conversation

@martinkuba
Copy link
Contributor

Which problem is this PR solving?

In the browser repo, we are introducing an instrumentation for capturing console logs. There is an issue with the diagnostics logger - capturing console logs triggers work by the SDK, which may generate console logs using the diagnostics logger, which creates more work by the SDK ... infinite loop.

The issue has been discussed here.

This is an alternative fix to #6355

Short description of the changes

The original console methods are saved at module load time in DiagConsoleLogger. This prevents diagnostic log calls
from being re-captured as telemetry.

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)

Checklist:

  • Followed the style guidelines of this project
  • Unit tests have been added
  • Documentation has been updated

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.50%. Comparing base (fcafab5) to head (cc36318).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6395   +/-   ##
=======================================
  Coverage   95.50%   95.50%           
=======================================
  Files         365      365           
  Lines       11609    11618    +9     
  Branches     2677     2680    +3     
=======================================
+ Hits        11087    11096    +9     
  Misses        522      522           
Files with missing lines Coverage Δ
api/src/diag/consoleLogger.ts 100.00% <100.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.

if (typeof theFunc !== 'function') {
theFunc = _originalConsoleMethods['log'];
}
// Fall back in case console was not available at module load time but became available later.
Copy link
Contributor Author

@martinkuba martinkuba Feb 11, 2026

Choose a reason for hiding this comment

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

@pichlermarc This is related to the comment above about console available only when developer console is open. I think this would happen only in some very old browsers like IE. We only support modern browsers, so this is purely defensive. But the logic was already there before this change (comment on line 65).

@martinkuba martinkuba changed the title Update DiagLogger to use original console methods fix(api): Update DiagLogger to use original console methods Feb 11, 2026
@martinkuba martinkuba marked this pull request as ready for review February 11, 2026 17:43
@martinkuba martinkuba requested a review from a team as a code owner February 11, 2026 17:43
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.

1 participant

Comments