feat(attribute): Add koa.type and (deprecated) koa.name - #472
Merged
Conversation
s1gr1d
requested review from
a team,
Lms24,
cleptric,
mjq and
nsdeschenes
as code owners
July 9, 2026 12:49
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Attributes
Other
Internal Changes 🔧
🤖 This preview updates automatically when you update the PR. |
Lms24
approved these changes
Jul 9, 2026
Member
There was a problem hiding this comment.
Thanks for adding!
RE: koa.name: We can still add it to conventions and mark it as deprecated. Add _status: null to the deprecation since there's no direct replacement. In this case, the SDK will decide which attributes replace it in which case. The benefit is still that the attribute is documented and that it's gonna be deprecated (i.e. signaling conventions consumers that it shouldn't be set anymore). But feel free to tackle later
s1gr1d
enabled auto-merge (squash)
July 13, 2026 08:27
s1gr1d
disabled auto-merge
July 13, 2026 08:28
koa.typekoa.type and koa.name
koa.type and koa.namekoa.type and (deprecated) koa.name
Lms24
enabled auto-merge (squash)
July 13, 2026 08:55
Lms24
disabled auto-merge
July 13, 2026 08:55
Lms24
enabled auto-merge (squash)
July 13, 2026 08:55
4 tasks
s1gr1d
added a commit
to getsentry/sentry-javascript
that referenced
this pull request
Jul 16, 2026
…n integration (#22146) Adds `koaChannelIntegration` in `@sentry/server-utils` for injecting orchestrion channels into `koa`. A subscriber wraps each registered layer in a span-creating proxy. Span-helpers are ported from the vendored instrumentation, preserving span names (but adapting to [new conventions](getsentry/sentry-conventions#472)). Also upgraded `@apm-js-collab/tracing-hooks` to get this: apm-js-collab/tracing-hooks#45 to be released (lets us actually patch `koa` - see 1. iteration below). <details> <summary>1. iteration</summary> One thing to know for review: **we instrument `koa-compose`, not `use` from koa.** koa's `use` lives in koa's main entry (`lib/application.js`), and transforming a package's main entry forces its top-level `require` chain through Node's `require(esm)` bridge, which throws on Node < 24.13. 1. Orchestrion instruments by rewriting a module's source at load time (via the ESM load hook). 2. `use` lives in koa's main entry (`lib/application.js`), so to instrument it we transform that file. But transforming a main entry pulls its whole top-level `require` chain into the loader's handling --> and that changes how those `require`s are loaded (through the ESM→CommonJS translator, not the normal sync require path). 3. `koa` is CJS (but support ESM). When `import`ing koa, it loads a shim that loads the CJS code: `import 'koa'` → `dist/koa.mjs` (a ESM shim) → `import '../lib/application.js'` (CJS). That CJS entry has a top-level `require('is-generator-function')`. 4. `is-generator-function` → `require('generator-function')`, and `generator-function` points at an `.mjs` file, which in turn imports `./index.js`. --> So the top-level `require` in koa's `application.js` (CJS) becomes `require(esm)` of an ESM file importing a CJS file. 5. On Node < 24.13 (we pin 20.19.5), the loader can't pre-link this dual-package shape into the `require(esm)` cache, so it throws `request for './index.js' is not in cache`. The failing chain: ``` koa/lib/application.js (CJS) └─ require('is-generator-function') (CJS) └─ require('generator-function') → require(esm) → require.mjs (ESM) └─ import './index.js' (ESM importing CJS) ``` `koa-compose` is koa's zero-dependency dispatch engine, so it's safe to transform, and `compose(app.middleware)` sees the same layers `use` would. Since `@koa/router` also calls `compose` per request, the subscriber uses `getActiveSpan()` to only wrap at app startup (no active span) and skip the per-request router composition.</details> Closes #20758 Linear: https://linear.app/getsentry/issue/JS-2409/rewrite-opentelemetryinstrumentation-koa-to-orchestrion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
koa.typewhich is used in the koa instrumentation: https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/packages/instrumentation-koa/src/enums/AttributeNames.tskoa.namecan be substituted with eitherhttp.route(for routes) orcode.function.name(for middleware) as middleware is named after the function name: https://github.com/koajs/koa/blob/master/docs/guide.md#named-middlewarePR Checklist
yarn testand verified that the tests pass.yarn generateto generate and format code and docs.If an attribute was added:
nextjs.function_id, notfunction_id)apply_scrubbing(i.e.manualorauto. Useneveronly for values that should never be scrubbed such as IDs)If an attribute was deprecated: