Skip to content

ensureIsWrapped emits false "not instrumented" warnings for channel-based Express/Koa/Hapi #22555

Description

@andreiborza

Problem

With channel-based (orchestrion diagnostics-channel) instrumentation now the default (#22345 / #22345), the default Express, Koa, and Hapi integrations no longer monkey-patch the app object via OpenTelemetry/shimmer. They subscribe to diagnostics channels instead.

However, setupExpressErrorHandler, setupKoaErrorHandler, and setupHapiErrorHandler still call ensureIsWrapped(app.use, '<framework>'), and ensureIsWrapped (packages/node/src/utils/ensureIsWrapped.ts) only detects OTel-style wrapping:

isWrapped(maybeWrappedFunction) || typeof getOriginalFunction(...) === 'function'

Under channel-based instrumentation the app object is not wrapped, so for a correctly-instrumented app this check is false and the SDK:

  • logs a misleading "[Sentry] <framework> is not instrumented..." console warning, and
  • sets a missing_instrumentation context on the global scope.

Spans are still recorded correctly (E2E is green) — this is cosmetic/misleading, not a functional break. disableInstrumentationWarnings: true silences it as a workaround.

Fix direction

Teach ensureIsWrapped to recognize channel-based instrumentation (e.g. detect that channel injection/subscribers are active for the framework), or skip the OTel-wrapping check when the integration is running in channel mode, so the warning and missing_instrumentation context only fire when instrumentation is genuinely absent.

Affected

  • packages/node/src/utils/ensureIsWrapped.ts
  • setupExpressErrorHandler / setupKoaErrorHandler / setupHapiErrorHandler call sites (Express: packages/node/src/integrations/tracing/express.ts)

Found by Cursor Bugbot on PR #22501 (Low severity).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions