Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
ref(node): Refactor orchestrion config into separate files#21957
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,11 @@ | ||
| import { mysqlChannels } from './config/mysql'; | ||
| import { lruMemoizerChannels } from './config/lru-memoizer'; | ||
| import { ioredisChannels } from './config/ioredis'; | ||
| import { pgChannels } from './config/pg'; | ||
| import { openaiChannels } from './config/openai'; | ||
| import { anthropicAiChannels } from './config/anthropic-ai'; | ||
| import { vercelAiChannels } from './config/vercel-ai'; | ||
| /** | ||
| * Fully-qualified `diagnostics_channel` names that orchestrion publishes to. | ||
| * | ||
| @@ -12,33 +20,13 @@ | ||
| * they don't drift apart and silently stop firing. | ||
| */ | ||
| export const CHANNELS = { | ||
| MYSQL_QUERY: 'orchestrion:mysql:query', | ||
| LRU_MEMOIZER_LOAD: 'orchestrion:lru-memoizer:load', | ||
| IOREDIS_COMMAND: 'orchestrion:ioredis:command', | ||
| IOREDIS_CONNECT: 'orchestrion:ioredis:connect', | ||
| PG_QUERY: 'orchestrion:pg:query', | ||
| PG_CONNECT: 'orchestrion:pg:connect', | ||
| PGPOOL_CONNECT: 'orchestrion:pg-pool:connect', | ||
| OPENAI_CHAT: 'orchestrion:openai:chat', | ||
| OPENAI_RESPONSES: 'orchestrion:openai:responses', | ||
| OPENAI_EMBEDDINGS: 'orchestrion:openai:embeddings', | ||
| OPENAI_CONVERSATIONS: 'orchestrion:openai:conversations', | ||
| ANTHROPIC_CHAT: 'orchestrion:@anthropic-ai/sdk:chat', | ||
| ANTHROPIC_MODELS: 'orchestrion:@anthropic-ai/sdk:models', | ||
| ANTHROPIC_MESSAGES_STREAM: 'orchestrion:@anthropic-ai/sdk:messages-stream', | ||
| // Vercel AI (`ai`) v6: orchestrion injects these so the same channel-based | ||
| // integration that consumes `ai`'s native `ai:telemetry` channel (v7) can | ||
| // also instrument v6. Each maps to a top-level function in `ai`'s bundle. | ||
| VERCEL_AI_GENERATE_TEXT: 'orchestrion:ai:generateText', | ||
| VERCEL_AI_STREAM_TEXT: 'orchestrion:ai:streamText', | ||
| VERCEL_AI_EMBED: 'orchestrion:ai:embed', | ||
| VERCEL_AI_EMBED_MANY: 'orchestrion:ai:embedMany', | ||
| VERCEL_AI_EXECUTE_TOOL_CALL: 'orchestrion:ai:executeToolCall', | ||
| // `resolveLanguageModel` is the single chokepoint every model call flows | ||
| // through; we wrap it to monkey-patch `doGenerate`/`doStream` on the returned | ||
| // model (the model-call site itself is an inline call with no injectable | ||
| // definition). | ||
| VERCEL_AI_RESOLVE_LANGUAGE_MODEL: 'orchestrion:ai:resolveLanguageModel', | ||
| ...mysqlChannels, | ||
| ...lruMemoizerChannels, | ||
| ...ioredisChannels, | ||
| ...pgChannels, | ||
| ...openaiChannels, | ||
| ...anthropicAiChannels, | ||
| ...vercelAiChannels, | ||
Member 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. YES. 👏 | ||
| } as const; | ||
| export type ChannelName = (typeof CHANNELS)[keyof typeof CHANNELS]; | ||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import type { InstrumentationConfig } from '@apm-js-collab/code-transformer'; | ||
| export const anthropicAiConfig = [ | ||
| // One entry each for CJS/ESM | ||
| ...['resources/messages/messages.js', 'resources/messages/messages.mjs'].flatMap(filePath => | ||
| (['create', 'countTokens'] as const).map(methodName => ({ | ||
| channelName: 'chat', | ||
| module: { name: '@anthropic-ai/sdk', versionRange: '>=0.19.2 <1', filePath }, | ||
| functionQuery: { className: 'Messages', methodName, kind: 'Auto' as const }, | ||
| })), | ||
| ), | ||
| ...['resources/completions.js', 'resources/completions.mjs'].map(filePath => ({ | ||
| channelName: 'chat', | ||
| module: { name: '@anthropic-ai/sdk', versionRange: '>=0.19.2 <1', filePath }, | ||
| functionQuery: { className: 'Completions', methodName: 'create', kind: 'Auto' as const }, | ||
| })), | ||
| ...['resources/beta/messages/messages.js', 'resources/beta/messages/messages.mjs'].map(filePath => ({ | ||
| channelName: 'chat', | ||
| module: { name: '@anthropic-ai/sdk', versionRange: '>=0.19.2 <1', filePath }, | ||
| functionQuery: { className: 'Messages', methodName: 'create', kind: 'Auto' as const }, | ||
| })), | ||
| ...['resources/models.js', 'resources/models.mjs'].map(filePath => ({ | ||
| channelName: 'models', | ||
| module: { name: '@anthropic-ai/sdk', versionRange: '>=0.19.2 <1', filePath }, | ||
| functionQuery: { className: 'Models', methodName: 'retrieve', kind: 'Auto' as const }, | ||
| })), | ||
| // `messages.stream()` returns a synchronous emitter, not a promise, so `kind: 'Sync'` is required: | ||
| // `Auto`'s promise wrapper never publishes `end` for a non-thenable return, so the span would never end. | ||
| ...['resources/messages/messages.js', 'resources/messages/messages.mjs'].map(filePath => ({ | ||
| channelName: 'messages-stream', | ||
| module: { name: '@anthropic-ai/sdk', versionRange: '>=0.19.2 <1', filePath }, | ||
| functionQuery: { className: 'Messages', methodName: 'stream', kind: 'Sync' as const }, | ||
| })), | ||
| ] satisfies InstrumentationConfig[]; | ||
| export const anthropicAiChannels = { | ||
| ANTHROPIC_CHAT: 'orchestrion:@anthropic-ai/sdk:chat', | ||
| ANTHROPIC_MODELS: 'orchestrion:@anthropic-ai/sdk:models', | ||
| ANTHROPIC_MESSAGES_STREAM: 'orchestrion:@anthropic-ai/sdk:messages-stream', | ||
| } as const; |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.