Skip to content

test: convert remote/span-name tracing tests to in-memory span exporter; drop tracing-attributes profile (#478) - #490

Merged
sjvans merged 2 commits into
developfrom
test/478-group1-in-memory-spans
Aug 17, 2026
Merged

test: convert remote/span-name tracing tests to in-memory span exporter; drop tracing-attributes profile (#478)#490
sjvans merged 2 commits into
developfrom
test/478-group1-in-memory-spans

Conversation

@sjvans

@sjvans sjvans commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What

Group 1 of #478. Converts the three tracing tests that still spied on console.dir to read structured ReadableSpan objects directly from the in-memory span exporter:

  • test/tracing-remote-cloudsdk.test.js
  • test/tracing-remote-native.test.js
  • test/tracing-span-names.test.js

Each now uses --profile tracing-in-memory (which wires MyInMemorySpanExporter via .cdsrc.json) and reads over captured (the module-level array of ReadableSpans) instead of the console.dir spy. beforeEach(reset) clears the buffer per test. All existing assertions are preserved verbatim — instrumentationScope.name filters (@cap-js/telemetry, @opentelemetry/instrumentation-undici), span names, and attributes (code.function.name, db.query.text, sap.btp.destination, the no-raw-SQL / no-URL-in-span-name checks). captured holds full ReadableSpans with instrumentationScope, so the filters just point at captured.

No flush/poll was needed: the spans for these single request/DB ops appear synchronously in captured after the awaited call. In tracing-span-names.test.js, data.reset() is itself traced, so the buffer is cleared after reset (mirroring tracing-attributes.test.js).

Why

No more console.dir spying in the tracing tests. With all three files migrated, the [tracing-attributes] profile in test/bookshop/.cdsrc.json has no remaining consumers (verified: only these 3 used it; tracing-attributes.test.js despite its name already uses tracing-in-memory), so it is removed. This also resolves the deferred "rename tracing-attributes → tracing-console" note — the profile simply goes away.

Test-only change. No lib change, no CHANGELOG.

Refs #478 (group 1 only; group 2 done via #479, group 3 stays).

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

The following content is AI-generated and provides a summary of the pull request:


test: Convert Remote/Span-Name Tracing Tests to In-Memory Span Exporter; Drop tracing-attributes Profile

Refactor

♻️ Migrates three remaining tracing test files from console.dir spying to reading structured ReadableSpan objects directly from MyInMemorySpanExporter. With no remaining consumers, the [tracing-attributes] CDS profile is removed.

Changes

  • test/bookshop/.cdsrc.json: Removed the [tracing-attributes] profile (which wired @opentelemetry/sdk-trace-node console exporter), as it is no longer used by any test suite.
  • test/tracing-remote-cloudsdk.test.js: Switched from --profile tracing-attributes to --profile tracing-in-memory. Replaced vi.spyOn(console, 'dir') + log.mock.calls with { captured, reset } from MyInMemorySpanExporter. beforeEach now calls reset() to clear the buffer between tests.
  • test/tracing-remote-native.test.js: Same migration as above — dropped the console.dir spy, switched to the in-memory profile, and reads spans from captured.
  • test/tracing-span-names.test.js: Switched to --profile tracing-in-memory and reads from captured. beforeEach now awaits data.reset() first (since reset is itself traced), then clears captured.length = 0 so each test only sees its own spans.

All existing assertions are preserved: instrumentationScope.name filters, span names, and attributes (code.function.name, db.query.text, sap.btp.destination, no-raw-SQL / no-URL-in-span-name checks). This is a test-only change with no library or CHANGELOG modifications.

Jira Issues

Related GitHub Issues:

  • #478: Replace console spying in tests with in-memory exporters
  • #479: test: capture outbox+console metrics via in-memory reader & unit-test ConsoleMetricExporter

  • 🔄 Regenerate and Update Summary
  • ✏️ Insert as PR Description (deletes this comment)
  • 🗑️ Delete comment
PR Bot Information

Version: 1.29.30

@hyperspace-pr-bot hyperspace-pr-bot Bot left a comment

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.

The PR is a clean, well-motivated refactor. The only minor inconsistency is in tracing-span-names.test.js, which manually resets the span buffer via captured.length = 0 rather than calling the shared reset() helper that the other two migrated files use — comments have been left inline for that. Everything else looks correct: the profile removal is properly justified (no remaining consumers), the beforeEach/beforeAll ordering is sound, and the assertion logic is preserved faithfully.

PR Bot Information

Version: 1.29.30

  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened
  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: 2448efe0-9a35-11f1-8ec3-aaf7cc3158a5

Comment thread test/tracing-span-names.test.js Outdated
// The tracing-in-memory profile (see test/bookshop/.cdsrc.json) configures
// MyInMemorySpanExporter as the trace exporter. We read the captured ReadableSpan
// objects directly out of its shared buffer — no console spy.
const { captured } = require('./bookshop/lib/MyInMemorySpanExporter')

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.

Best Practices: reset is not imported, so the buffer is cleared manually with captured.length = 0 instead of calling the shared reset() helper.

The other two migrated files (tracing-remote-cloudsdk.test.js, tracing-remote-native.test.js) both import and call reset. Using captured.length = 0 directly duplicates the reset logic and will silently diverge if reset() in MyInMemorySpanExporter.js ever does anything beyond clearing the array. Consider importing reset here for consistency.

Suggested change
const { captured } = require('./bookshop/lib/MyInMemorySpanExporter')
const { captured, reset } = require('./bookshop/lib/MyInMemorySpanExporter')

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

Comment thread test/tracing-span-names.test.js Outdated
// data.reset is itself heavily traced (it runs DELETEs + INSERTs for the seed data) —
// run it first, THEN clear the buffer so the test only sees its own spans.
await data.reset()
captured.length = 0

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.

Best Practices: Buffer is cleared manually instead of using the imported reset() helper.

After importing reset (see sibling comment), replace captured.length = 0 with reset() to keep the teardown consistent with the other migrated test files and resilient to future changes in MyInMemorySpanExporter.

Suggested change
captured.length = 0
reset()

Double-check suggestion before committing. Edit this comment for amendments.


Please provide feedback on the review comment by checking the appropriate box:

  • 🌟 Awesome comment, a human might have missed that.
  • ✅ Helpful comment
  • 🤷 Neutral
  • ❌ This comment is not helpful

@sjvans
sjvans merged commit 0c28b57 into develop Aug 17, 2026
8 checks passed
@sjvans
sjvans deleted the test/478-group1-in-memory-spans branch August 17, 2026 19:47
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