Skip to content

test(instrumentation): add console instrumentation e2e test#353

Open
pjsny wants to merge 1 commit into
open-telemetry:mainfrom
pjsny:test/e2e-console-instrumentation
Open

test(instrumentation): add console instrumentation e2e test#353
pjsny wants to merge 1 commit into
open-telemetry:mainfrom
pjsny:test/e2e-console-instrumentation

Conversation

@pjsny

@pjsny pjsny commented Jul 16, 2026

Copy link
Copy Markdown

Which problem is this PR solving?

This adds end-to-end coverage for ConsoleInstrumentation, building on the e2e testing initiative from #332. This is test-only, no runtime/source changes.

Short description of the changes

  • Adds ConsoleInstrumentation e2e tests (e2e-tests/packages/instrumentation/console/)
    driving the real browser console through the SDK → OTLP/HTTP → MSW-mocked
    collector pipeline, covering:

    • body, severity number/text, browser.console event name, browser.console.method attribute
    • severity mapping across all five methods (debug/log/info/warn/error)
    • object-argument JSON serialization
    • logMethods config (only configured methods emit)
    • trace↔log correlation (a console.* call inside an active span yields a log
      carrying the span's traceId/spanId)
    • Extends shared test-collector.ts OTLP log type with body/eventName (already on the wire).
    • Adds a StackContextManager in test-otel-setup.ts so trace context propagates
      (needed for the correlation test); names its return type TestSdkHandle and
      migrates the errors e2e test onto it.
    • Adds the console source alias to e2e-tests/vitest.config.ts.

    Assertions match records by body, so any potential future unrelated logs emitted in the same window
    won't cause flakes.

Type of change

  • Test-only change (no runtime behavior change)

How Has This Been Tested?

npm run test:e2e

@pjsny
pjsny requested a review from a team as a code owner July 16, 2026 23:24
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 16, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: pjsny / name: Philip Snyder (22c6321)

Signed-off-by: Philip Snyder <57119461+pjsny@users.noreply.github.com>
@pjsny
pjsny force-pushed the test/e2e-console-instrumentation branch from 22c6321 to 37f33c1 Compare July 20, 2026 15:29
it('emits a log record with body, severity, and method attribute for console.error', async () => {
result = testSdkSetup([new ConsoleInstrumentation()]);

console.error('database connection failed');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know this is just for testing but can you use more browser-like error message just to avoid any kind of confusion on this running in node?

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.

2 participants