-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(node): Add getInstrumentedModuleNames()
#24254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import type { InstrumentationConfig } from '@apm-js-collab/code-transformer-bundler-plugins/core'; | ||
| import { describe, expect, it } from 'vitest'; | ||
| import { | ||
| getInstrumentedModuleNames, | ||
| INSTRUMENTED_MODULE_NAMES, | ||
| instrumentedModuleNames, | ||
| SENTRY_INSTRUMENTATIONS, | ||
|
|
@@ -21,6 +22,32 @@ describe('orchestrion config — scoped @hapi/hapi module', () => { | |
| }); | ||
| }); | ||
|
|
||
| describe('getInstrumentedModuleNames', () => { | ||
| it('returns the instrumented package names', () => { | ||
| const names = getInstrumentedModuleNames(); | ||
|
|
||
| for (const name of ['dataloader', 'ai', 'express', 'pg', 'redis']) { | ||
| expect(names).toContain(name); | ||
| } | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test loop covers multiple casesLow Severity This test loops over several package names and asserts each one is present. The review guidelines ask for Triggered by project rule: PR Review Guidelines for Cursor Bot Reviewed by Cursor Bugbot for commit 1036b89. Configure here. |
||
|
|
||
| it('has no duplicates', () => { | ||
| const names = getInstrumentedModuleNames(); | ||
|
|
||
| expect(names.length).toBe(new Set(names).size); | ||
| }); | ||
|
|
||
| it('is the plain instrumented set, without the bundler-only additions in INSTRUMENTED_MODULE_NAMES', () => { | ||
| // `INSTRUMENTED_MODULE_NAMES` adds packages that must be force-bundled (e.g. `@remix-run/node`), | ||
| // which is the opposite of what a "keep external" caller wants. | ||
| expect(getInstrumentedModuleNames()).not.toContain('@remix-run/node'); | ||
| expect(INSTRUMENTED_MODULE_NAMES).toContain('@remix-run/node'); | ||
| expect(new Set(getInstrumentedModuleNames())).toEqual( | ||
| new Set(SENTRY_INSTRUMENTATIONS.map(instrumentation => instrumentation.module.name)), | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe('orchestrion config — channel-subscriber coverage', () => { | ||
| // The subscribe injection rides the real channel configs (the `tracingChannelImport` | ||
| // override only runs on instrumented files), so a subscriber definition whose module is | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we expect users to actually use this in a setup I feel we should make this more comprehensible wdyt? Just an idea could we just add a wrapper for
defineAgentwhere we set these things ourselves?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I discussed this with @RulaKhaled , @andreiborza and @nicohrubec and the general consensus was that it was preferred to do an explicit thing like here - personally I have no strong opinion on this. Although, if we ship this here, nothing stops us from also shipping a define agent wrapper later?