Skip to content

test: enable HTTP instrumentation in tests; assert incoming SERVER spans + traceparent propagation (#475) - #491

Open
sjvans wants to merge 1 commit into
developfrom
test/475-http-instrumentation
Open

test: enable HTTP instrumentation in tests; assert incoming SERVER spans + traceparent propagation (#475)#491
sjvans wants to merge 1 commit into
developfrom
test/475-http-instrumentation

Conversation

@sjvans

@sjvans sjvans commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

What

Re-enables HTTP instrumentation in the test app (disabled by #474 to stay behavior-neutral under jest) and asserts the incoming-request tracing behavior it produces.

  • Test-app config (test/bookshop/package.json): removed disableIncomingRequestInstrumentation / disableOutgoingRequestInstrumentation so both default to on; kept ignoreIncomingRequestHook. Incoming HTTP requests now produce a SERVER span (the root of each request trace) and outgoing requests produce CLIENT spans.
  • GET with traceparent is traced (was xtest): asserts the incoming SERVER span adopts the W3C context from the traceparent header — trace id 0af7651916cd43dd8448eb211c80319c, parent span id b7ad6b7169203331.
  • instrumentation hooks (was empty xtest): asserts both suppression mechanisms — the sampler's ignoreIncomingPaths (/odata/v4/admin/Authors) and MyIgnoreIncomingRequestHook (/Books(252)) — produce NO incoming SERVER span, while a non-ignored path (/Books) does.
  • $batch is traced: updated for reparenting — the single $batch POST now yields ONE incoming SERVER root with both batch sub-operations (CREATE Genres draft, READ Genres) nested beneath it (was 2 roots).
  • tracing-messaging CHECKs (without-outbox, inboxed, persistent-outbox): the producer trace is now rooted at the incoming SERVER span (AdminService - tx nests under it), so the root assertion was updated from name AdminService - tx to SpanKind.SERVER while keeping the same nested-span assertions.

Why

The test's HTTP client runs in-process; with outgoing instrumentation now on, it would itself create a CLIENT span (an artificial extra root that also overwrites a manually-set traceparent). A shared asExternalClient helper runs client-side requests under suppressTracing to model a real external, un-instrumented caller — the outgoing CLIENT artifact is skipped and the genuine incoming SERVER span is the trace root.

No lib/ change (config + tests only). No CHANGELOG.

Verification (sqlite)

  • test/tracing.test.js — 11 passed / 2 skipped (the 2 formerly-xtest now real + passing; $batch fixed; Eliminate all test skips and CI test-subset exclusions (sqlite + HANA) #477 §3 stubs remain skipped)
  • test/tracing-remote-cloudsdk.test.js + test/tracing-remote-native.test.js — pass (outgoing CLIENT instrumentation didn't break them)
  • Full suite — 65 passed / 12 skipped (was 63 / 14; the 2 newly-enabled tests moved skipped→passed)
  • lint + oxfmt clean; lockfile untouched

HANA note

inboxed and persistent-outbox messaging tests are HANA-only (skipped on sqlite) but share the same reparented producer-root assertion, so they were updated too — HANA CI must be verified on this PR.

closes #475

@hyperspace-pr-bot

Copy link
Copy Markdown
Contributor

Summary

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


Enable HTTP Instrumentation in Tests and Assert Incoming SERVER Spans

Test

✨ Re-enables HTTP instrumentation in the test app and adds assertions for incoming HTTP SERVER spans and W3C traceparent propagation — converting two previously-skipped (xtest) tests into real passing tests.

Changes

The core change is removing disableIncomingRequestInstrumentation / disableOutgoingRequestInstrumentation from the test app config, then updating all affected test assertions to account for the resulting trace-tree reparenting (incoming HTTP requests now produce a SERVER span as the trace root).

A shared asExternalClient helper (using suppressTracing) is introduced across test files to model real external, un-instrumented callers — preventing the in-process HTTP client from generating artificial CLIENT spans that would otherwise pollute the trace roots.

  • test/bookshop/package.json: Removed disableIncomingRequestInstrumentation and disableOutgoingRequestInstrumentation; kept ignoreIncomingRequestHook. Both incoming and outgoing HTTP instrumentation now default to enabled.
  • test/tracing.test.js:
    • Added asExternalClient helper using suppressTracing.
    • Converted xtest('GET with traceparent is traced') → real test asserting the incoming SERVER span adopts the W3C trace context (traceparent header propagation).
    • Converted xtest('instrumentation hooks') → real test verifying that ignoreIncomingPaths (sampler) and MyIgnoreIncomingRequestHook suppress SERVER spans for ignored paths, while non-ignored paths produce one.
    • Updated $batch is traced: now expects exactly 1 SERVER root (was 2) containing both batch sub-operations.
    • Wrapped client calls in asExternalClient.
  • test/tracing-messaging.js: Added asExternalClient helper; wrapped the POST('/odata/v4/admin/test_emit', ...) call in it.
  • test/tracing-messaging-without-outbox.test.js: Updated producer root assertion from name === 'AdminService - tx' to kind === SpanKind.SERVER; updated span-hierarchy comments.
  • test/tracing-messaging-inboxed.test.js: Same producer root assertion update + added @opentelemetry/api import; updated comments.
  • test/tracing-messaging-persistent-outbox.test.js: Same producer root assertion update + added @opentelemetry/api import; updated comments.

Jira Issues (ONLY add this section if JIRA issues are available)

N/A

Images and Links

Related GitHub issues:

  • #474: jest → vitest migration (introduced the HTTP instrumentation disable)
  • #475: Enable HTTP instrumentation in tests and assert on incoming spans
  • #477: Eliminate all test skips and CI test-subset exclusions

  • 🔄 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 four review comments failed to post because the targeted lines were not part of the diff (they are unchanged context lines, not newly added lines). Since the review comment tool requires the original_code to match an added line from the diff, I cannot post those inline comments.

To summarize the overall quality of this PR: the changes are well-structured and clearly documented, with the asExternalClient / suppressTracing pattern consistently applied to the most critical assertions. However, several HTTP requests in tracing.test.js that were not changed by this PR — GET is traced, NonRecordingSpans are handled correctly, cds.spawn is traced, and emit is traced — still issue requests without asExternalClient. With outgoing HTTP instrumentation now enabled, the in-process test client will generate CLIENT spans for those calls too, which may introduce extra roots and cause the root-count assertions in cds.spawn is traced (lengthOf(2)) and emit is traced (lengthOf(1)) to become flaky or fail, and may also cause the /admin/Authors span-absence assertion in NonRecordingSpans to fail. Those four tests should be updated in a follow-up to wrap their HTTP calls in asExternalClient for consistency and correctness.

PR Bot Information

Version: 1.29.30

  • LLM: anthropic--claude-4.6-sonnet
  • Correlation ID: ed8b0340-9ad8-11f1-8077-1963f7225a67
  • File Content Strategy: Full file content
  • Event Trigger: pull_request.opened

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