Skip to content

Replace requiresParentSpan with onlyIfParent in tracing-channel integrations #25875

Closed

Description

@nicohrubec

Remove requiresParentSpan from bindTracingChannelToSpan and use startInactiveSpan({ onlyIfParent: true }) at every affected span factory, including both database and non-database integrations.

This ticket standardizes call sites on the existing onlyIfParent API and removes the redundant helper option. Changes to or alignment of onlyIfParent behavior are tracked separately.

The helper currently skips getSpan entirely without an active parent, bypassing core's no_parent_span client reporting. Reporting directly in the early guard could overcount excluded payloads, such as MongoDB handshakes. Using onlyIfParent lets eligibility checks run before core handles parent resolution and reporting. No parent-detection mismatch was identified in current call sites.

The audit found 17 option assignments across 16 binding sites in 10 integrations; Postgres has two option branches for one binding. DataLoader already sets onlyIfParent. Preserve postgres-js's public requireParentSpan option using onlyIfParent: requireParentSpan !== false.

Scope (paths below are relative to packages/server-utils/src/integrations/, except Remix):

  • postgres.ts: shared query/connect/pool-connect binding, also covering Neon WebSocket queries.
  • postgres-js.ts: query binding; preserve configurable parent requirement.
  • mysql2/index.ts: Orchestrion query/execute binding.
  • mysql2/mysql2-dc-subscriber.ts: native query/execute and connect/pool-connect bindings.
  • mongodb/index.ts: v4+ command and v3 wire-protocol bindings; add onlyIfParent in shared mongodb/mongodb-span.ts::startMongoSpan, retaining payload exclusions.
  • redis/ioredis-channel-subscriber.ts: command and connect bindings.
  • dataloader.ts: load and shared simple-operation bindings; remove redundant helper guards.
  • prisma/orchestrion.ts: shared terminal binding, including lazy results.
  • neon.ts: HTTP query binding.
  • hono/honoIntegration.ts: internal-request binding; retain duplicate-instrumentation checks.
  • packages/remix/src/server/integrations/tracing-channel.ts: loader and action bindings; leave request-handler root creation unrestricted.
  • packages/server-utils/src/tracing-channel.ts: remove the option, guard, documentation, unused import, and options forwarding/parameter on bindSpanToChannelStore. Its other direct caller, Mastra, passes no options.

Without a parent, the replacement activates a non-recording placeholder and descendants inherit its unsampled state. Existing unsampled parents already produce non-recording spans on these paths. No call site was found that fundamentally requires retaining the helper option, but review these behavioral changes before making a mechanical replacement:

  • Prisma: lazy results created without a parent could suppress driver spans when consumed later inside a sampled request, because consumption restores the saved placeholder.
  • Postgres: deferred stream handlers attach error listeners on previously skipped operations, potentially changing unhandled-error behavior.
  • Remix: action form-data cloning/parsing now runs without a parent, adding work and possible synchronous failures if the body was consumed.
  • postgres-js: requestHook and settlement wrappers now run for parentless queries.
  • ioredis: parentless commands enter deduplication tracking, affecting later offline-queue resends.
  • Hono: the manual patchAppRequest proxy has a separate no-parent early return; consider parity with the automatic subscriber.

Update tests that currently expect startInactiveSpan never to be called without a parent, notably Postgres, Neon, Prisma, and Remix. Verify reporting occurs for eligible spans, excluded payloads remain excluded, and non-recording contexts behave as intended.

Original addition: #22113.

The initial audit was read-only; no changes or tests were run during that investigation.

Activity

  1. self-assigned this
    on Oct 29, 2026
  2. linear-code commented on Oct 29, 2026

    @linear-code
  3. changed the title [-]Replace requiresParentSpan with onlyIfParent in tracing-channel integrations[/-] [+]Replace requiresParentSpan with onlyIfParent in DataLoader, Hono, and Remix[/+] on Oct 29, 2026
  4. changed the title [-]Replace requiresParentSpan with onlyIfParent in DataLoader, Hono, and Remix[/-] [+]Replace requiresParentSpan with onlyIfParent in tracing-channel integrations[/+] on Oct 29, 2026
  5. added a commit that references this issue on Oct 30, 2026
    365e761
  6. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #25926, which was included in the 11.11.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions