Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'node:assert';
import { tracingChannel } from 'node:diagnostics_channel';
import { orchestrionModuleInjected } from '@sentry/server-utils/orchestrion';
import { orchestrionModuleInjected } from '@sentry/server-utils';

// Reproduces the force-bundled path (vite SSR, nextjs's bundle-safe packages):
// the module is transformed at BUILD time and inlined, so it is never loaded
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-serverless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export {
rewriteFramesIntegration,
} from '@sentry/core';

export { awsIntegration } from '@sentry/server-utils/orchestrion';
export { awsIntegration } from '@sentry/server-utils';
export { awsLambdaIntegration } from './integration/awslambda';

export { getDefaultIntegrations, init } from './init';
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-serverless/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Integration, Options } from '@sentry/core';
import { applySdkMetadata, debug, envToBool, getSDKSource } from '@sentry/core';
import type { NodeClient, NodeOptions } from '@sentry/node';
import { getDefaultIntegrationsWithoutPerformance, initWithoutDefaultIntegrations } from '@sentry/node';
import { awsIntegration } from '@sentry/server-utils/orchestrion';
import { awsIntegration } from '@sentry/server-utils';
import { DEBUG_BUILD } from './debug-build';
import { awsLambdaIntegration } from './integration/awslambda';

Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ export {
instrumentLangChainEmbeddings,
instrumentStateGraph,
instrumentCreateReactAgent,
vercelAIIntegration,
} from '@sentry/server-utils';
export { vercelAIIntegration } from '@sentry/server-utils/orchestrion';

export { instrumentWorkflowWithSentry } from './workflows';

Expand Down
2 changes: 1 addition & 1 deletion packages/cloudflare/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Integration } from '@sentry/core';
import { getBaseDefaultIntegrations, initWithDefaultIntegrations } from './baseSdk';
import type { CloudflareClient, CloudflareOptions } from './client';
import { vercelAIIntegration } from '@sentry/server-utils/orchestrion';
import { vercelAIIntegration } from '@sentry/server-utils';

/**
* Get the default integrations for the Cloudflare SDK.
Expand Down
5 changes: 2 additions & 3 deletions packages/cloudflare/test/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ describe('getDefaultIntegrations', () => {
// Mirror what the snippet the vite plugin injects into each instrumented
// module does at runtime: import its factory and `.set` it on the marker map,
// keyed by module name (so a package split across files registers once).
const { mysqlIntegration, postgresIntegration, lruMemoizerIntegration } =
await import('@sentry/server-utils/orchestrion');
const { mysqlIntegration, postgresIntegration, lruMemoizerIntegration } = await import('@sentry/server-utils');
globalThis.__SENTRY_ORCHESTRION__ = {
bundler: ['mysql', 'pg', 'lru-memoizer'],
integrations: new Map([
Expand All @@ -131,7 +130,7 @@ describe('getDefaultIntegrations', () => {
});

test('installs an integration registered after init via the module-injected event', async () => {
const { mysqlIntegration } = await import('@sentry/server-utils/orchestrion');
const { mysqlIntegration } = await import('@sentry/server-utils');
const client = init({});
expect(client?.getIntegrationByName('Mysql')).toBeUndefined();

Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export {
postgresIntegration,
postgresJsIntegration,
tediousIntegration,
} from '@sentry/server-utils/orchestrion';
} from '@sentry/server-utils';
export { otlpIntegration, getOtlpTracesEndpoint } from '@sentry/server-utils/no-diagnostic-channels';
// Deprecated aliases kept for back-compat. Each forwards to the shared
// integration above, so its name is the shared name (e.g. `Mysql`), not the old
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/amqplib.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { amqplibIntegration } from '@sentry/server-utils/orchestrion';
import { amqplibIntegration } from '@sentry/server-utils';

/**
* Create spans for `amqplib` publish/consume operations under Deno. Included in
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/dataloader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { dataloaderIntegration } from '@sentry/server-utils/orchestrion';
import { dataloaderIntegration } from '@sentry/server-utils';

/**
* Create spans for `dataloader` load/batch operations under Deno. Not a default;
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/knex.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { knexIntegration } from '@sentry/server-utils/orchestrion';
import { knexIntegration } from '@sentry/server-utils';

/**
* Create spans for `knex` queries under Deno. Not a default; add it to
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/koa.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { koaIntegration } from '@sentry/server-utils/orchestrion';
import { koaIntegration } from '@sentry/server-utils';

/**
* Create spans for `koa` middleware/router layers under Deno. Included in the
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/mongoose.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mongooseIntegration } from '@sentry/server-utils/orchestrion';
import { mongooseIntegration } from '@sentry/server-utils';

/**
* Create spans for `mongoose` queries under Deno. Included in the default
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/mysql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mysqlIntegration } from '@sentry/server-utils/orchestrion';
import { mysqlIntegration } from '@sentry/server-utils';

/**
* Create spans for `mysql` queries under Deno. Included in the default
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/postgres.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { postgresIntegration } from '@sentry/server-utils/orchestrion';
import { postgresIntegration } from '@sentry/server-utils';

/**
* Create spans for `pg` (node-postgres) queries under Deno. Included in the
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/redis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { redisIntegration } from '@sentry/server-utils/orchestrion';
import { redisIntegration } from '@sentry/server-utils';

/**
* @deprecated Use `redisIntegration` instead.
Expand Down
2 changes: 1 addition & 1 deletion packages/deno/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { vercelAIIntegration } from '@sentry/server-utils/orchestrion';
export { vercelAIIntegration } from '@sentry/server-utils';
2 changes: 1 addition & 1 deletion packages/deno/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
tediousIntegration,
vercelAIIntegration,
redisIntegration,
} from '@sentry/server-utils/orchestrion';
} from '@sentry/server-utils';
import { DenoClient } from './client';
import { breadcrumbsIntegration } from './integrations/breadcrumbs';
import { denoContextIntegration } from './integrations/context';
Expand Down
5 changes: 2 additions & 3 deletions packages/nestjs/src/integrations/orchestrion-subscriber.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as diagnosticsChannel from 'node:diagnostics_channel';
import { debug, startInactiveSpan, waitForTracingChannelBinding } from '@sentry/core';
import { bindTracingChannelToSpan } from '@sentry/server-utils';
import { nestjsChannels as CHANNELS } from '@sentry/server-utils/orchestrion';
import { nestjsChannels as CHANNELS } from '@sentry/server-utils/orchestrion/config';
import { DEBUG_BUILD } from '../debug-build';
import type { AnyFn } from './helpers';
import { isWrapped, markWrapped } from './helpers';
Expand Down Expand Up @@ -114,8 +114,7 @@ function subscribeFactoryDecorator(channelName: string, wrap: (decorator: AnyFn,
* Opens the same spans as the OTel `Nest` instrumentation, only with
* different origin.
*
* Called from `nestIntegration`'s `setupOnce` when orchestrion is active
* (`isOrchestrionInjected()`); requires the runtime hook or bundler plugin.
* Called from `nestIntegration`'s `setupOnce` when orchestrion is active.
*/
export function subscribeToNestChannels(): void {
if (!diagnosticsChannel.tracingChannel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
spanToJSON,
} from '@sentry/core';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { nestjsChannels as CHANNELS } from '@sentry/server-utils/orchestrion';
import { nestjsChannels as CHANNELS } from '@sentry/server-utils/orchestrion/config';
import { subscribeToNestChannels } from '../../src/integrations/orchestrion-subscriber';

// Mirrors harness in `tracing-channel.test.ts`: `bindTracingChannelToSpan`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,14 @@ function maybeAddOrchestrionRule(
return rules;
}

// The loader's transform splices an import of the `@sentry/server-utils/orchestrion` helper into
// each instrumented module. Turbopack rejects absolute-path imports ("server relative imports are
// not implemented yet"), and under isolated installs (pnpm) the bare specifier emitted inside a
// bundled package doesn't resolve from that package's location — so pass the helper's absolute
// on-disk path and let the loader derive a per-file RELATIVE specifier, which Turbopack resolves
// from the importing file and bundles at build time.
const importHelperPath = resolveOrchestrionRuntimeRequest('@sentry/server-utils/orchestrion');
// The loader's transform splices an import of `@sentry/server-utils` (the module-injected helper
// plus the module's subscriber factory) into each instrumented module. Turbopack rejects
// absolute-path imports ("server relative imports are not implemented yet"), and under isolated
// installs (pnpm) the bare specifier emitted inside a bundled package doesn't resolve from that
// package's location — so pass the entry's absolute on-disk path and let the loader derive a
// per-file RELATIVE specifier, which Turbopack resolves from the importing file and bundles at
// build time.
const importHelperPath = resolveOrchestrionRuntimeRequest('@sentry/server-utils');

return safelyAddTurbopackRule(rules, {
matcher: '*.{js,mjs,cjs}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('externalizeOrchestrionRuntimePackages', () => {
// An absolute path here breaks every deploy that relocates the output, so it has to stay bare.
it.each([
['@sentry/server-utils', '@sentry/nextjs/orchestrion-runtime/index'],
['@sentry/server-utils/orchestrion', '@sentry/nextjs/orchestrion-runtime/orchestrion'],
['@sentry/server-utils/orchestrion/config', '@sentry/nextjs/orchestrion-runtime/orchestrion/config'],
['@sentry/server-utils/orchestrion/register', '@sentry/nextjs/orchestrion-runtime/orchestrion/register'],
['@sentry/server-utils/orchestrion/webpack', '@sentry/nextjs/orchestrion-runtime/orchestrion/webpack'],
])('externalizes %s as the relocatable bare specifier %s', async (request, expected) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1481,7 +1481,7 @@ describe('orchestrion build-time instrumentation', () => {
expect(JSON.parse(JSON.stringify(firestore!.module.filePath))).not.toEqual({});
});

it('passes the helper module as an absolute importHelperPath', () => {
it('passes the snippet module as an absolute importHelperPath', () => {
const result = constructTurbopackConfig({
userNextConfig: {},
userSentryOptions: {},
Expand All @@ -1496,9 +1496,12 @@ describe('orchestrion build-time instrumentation', () => {
// The loader derives a per-file RELATIVE specifier from this path —
// Turbopack rejects absolute-path imports, and a bare specifier doesn't
// resolve from inside a transformed package under isolated installs (pnpm).
// The snippet imports the helper and the subscriber factory from
// `@sentry/server-utils` (the main entry), not the orchestrion subpath.
expect(importHelperPath).toBeDefined();
expect(path.isAbsolute(importHelperPath!)).toBe(true);
expect(importHelperPath).toContain('orchestrion');
expect(importHelperPath).toContain('server-utils');
expect(importHelperPath).not.toContain('orchestrion');
});

it('restricts the orchestrion rule to the node environment', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export {
redisIntegration,
tediousIntegration,
vercelAIIntegration,
} from '@sentry/server-utils/orchestrion';
} from '@sentry/server-utils';
export {
otlpIntegration,
getOtlpTracesEndpoint,
Expand Down
4 changes: 2 additions & 2 deletions packages/node/src/integrations/tracing/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Integration } from '@sentry/core';
import { prismaIntegration } from '@sentry/server-utils';
import {
prismaIntegration,
amqplibIntegration,
anthropicAIIntegration,
expressIntegration,
Expand All @@ -24,7 +24,7 @@ import {
redisIntegration,
tediousIntegration,
vercelAIIntegration,
} from '@sentry/server-utils/orchestrion';
} from '@sentry/server-utils';
import { fastifyIntegration } from './fastify';

export function getAutoPerformanceIntegrations(): Integration[] {
Expand Down
3 changes: 1 addition & 2 deletions packages/node/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import {
stackParserFromStackParserOptions,
} from '@sentry/core';
import { setOpenTelemetryContextAsyncContextStrategy } from '@sentry/opentelemetry';
import { setAsyncLocalStorageAsyncContextStrategy } from '@sentry/server-utils';
import { setAsyncLocalStorageAsyncContextStrategy, detectOrchestrionSetup } from '@sentry/server-utils';
import { isMainThread, parentPort } from 'node:worker_threads';
import { detectOrchestrionSetup } from '@sentry/server-utils/orchestrion';
import { registerDiagnosticsChannelInjection } from '@sentry/server-utils/orchestrion/register';
import { DEBUG_BUILD } from '../debug-build';
import { childProcessIntegration } from '../integrations/childProcess';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { registerDiagnosticsChannelInjection, detectOrchestrionSetup } = vi.hoist
vi.mock('@sentry/server-utils/orchestrion/register', () => ({
registerDiagnosticsChannelInjection,
}));
vi.mock('@sentry/server-utils/orchestrion', async importOriginal => {
vi.mock('@sentry/server-utils', async importOriginal => {
const actual = (await importOriginal()) as Record<string, unknown>;
return { ...actual, detectOrchestrionSetup };
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
HTTP_RESPONSE_STATUS_CODE,
} from '@sentry/conventions/attributes';
import { WEB_SERVER_FUNCTION_SPAN_OP } from '@sentry/conventions/op';
import { remixChannels } from '@sentry/server-utils/orchestrion';
import { remixChannels } from '@sentry/server-utils/orchestrion/config';
import type { FormDataCapture } from '../../utils/formData';
import { applyFormDataAttributes } from '../../utils/formData';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
setupRemixInstrumentation,
teardownTestAsyncContextStrategy,
} from './tracing-channel-test-utils';
import { remixChannels } from '@sentry/server-utils/orchestrion';
import { remixChannels } from '@sentry/server-utils/orchestrion/config';

// Runs in its own file so the channel subscriptions register with NO form-data capture configured -
// the default for most apps. `captureActionFormDataKeys` gates only the optional attribute
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/test/server/tracing-channel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
setupRemixInstrumentation,
teardownTestAsyncContextStrategy,
} from './tracing-channel-test-utils';
import { remixChannels } from '@sentry/server-utils/orchestrion';
import { remixChannels } from '@sentry/server-utils/orchestrion/config';

describe('remixIntegration (Orchestrion-based)', () => {
let startInactiveSpanSpy: MockInstance;
Expand Down
5 changes: 0 additions & 5 deletions packages/server-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
"import": "./build/esm/index.no-diagnostic-channels.js",
"require": "./build/cjs/index.no-diagnostic-channels.js"
},
"./orchestrion": {
"types": "./build/types/orchestrion/index.d.ts",
"import": "./build/esm/orchestrion/index.js",
"require": "./build/cjs/orchestrion/index.js"
},
"./orchestrion/config": {
"types": "./build/types/orchestrion/config/index.d.ts",
"import": "./build/esm/orchestrion/config/index.js",
Expand Down
4 changes: 1 addition & 3 deletions packages/server-utils/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ export default [
// plugins are loaded via dedicated subpath exports (`.../orchestrion/config`,
// `.../orchestrion/vite`, etc.) — none are reachable from `src/index.ts`, so
// we list them as separate entrypoints to guarantee they end up in build/esm
// and build/cjs. `src/orchestrion/index.ts` backs the `./orchestrion`
// subpath export.
// and build/cjs.
entrypoints: [
'src/index.ts',
'src/index.no-diagnostic-channels.ts',
'src/orchestrion/index.ts',
'src/orchestrion/config/index.ts',
// `src/orchestrion/runtime/register.ts` backs the `./orchestrion/register`
// subpath export; the Node SDK `require`s it synchronously from
Expand Down
39 changes: 36 additions & 3 deletions packages/server-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
export * from './exports';

// Exports using diagnostics channels
export { prismaIntegration } from './prisma';
export { detectOrchestrionSetup } from './orchestrion/detect';
export { bindTracingChannelToSpan } from './tracing-channel';
export type { TracingChannelPayloadWithSpan } from './tracing-channel';
export type { InstrumentationConfig } from './orchestrion';
export { vercelAIIntegration } from './vercel-ai';
export type { InstrumentationConfig } from './orchestrion/apmTypes';
// Runtime target of the bundler-injected module snippet. The snippet imports it
// from this entry alongside the module's subscriber factory (see
// `orchestrion/bundler/moduleInjectedTransform.ts`); it is a plain runtime
// helper with no orchestrion build-time dependency.
export { orchestrionModuleInjected } from './utils/moduleInjected';
export {
fastifyIntegration,
// oxlint-disable-next-line typescript/no-deprecated
handleFastifyError,
// oxlint-disable-next-line typescript/no-deprecated
instrumentFastify,
} from './integrations/fastify';

// Integrations
export { prismaIntegration } from './integrations/prisma';
export { amqplibIntegration } from './integrations/amqplib';
export { anthropicAIIntegration } from './integrations/anthropic';
export { awsIntegration } from './integrations/aws-sdk';
export { dataloaderIntegration } from './integrations/dataloader';
export { genericPoolIntegration } from './integrations/generic-pool';
export { googleGenAIIntegration } from './integrations/google-genai';
export { graphqlIntegration } from './integrations/graphql';
export { hapiIntegration } from './integrations/hapi';
export { koaIntegration } from './integrations/koa';
export { redisIntegration } from './integrations/redis';
export { kafkaIntegration } from './integrations/kafkajs';
export { knexIntegration } from './integrations/knex';
export { langChainIntegration } from './integrations/langchain';
export { langGraphIntegration } from './integrations/langgraph';
export { lruMemoizerIntegration } from './integrations/lru-memoizer';
export { mongoIntegration } from './integrations/mongodb';
export { mongooseIntegration } from './integrations/mongoose';
export { mysqlIntegration } from './integrations/mysql';
export { mysql2Integration } from './integrations/mysql2';
export { openAIIntegration } from './integrations/openai';
export { postgresIntegration } from './integrations/postgres';
export { postgresJsIntegration } from './integrations/postgres-js';
export { tediousIntegration } from './integrations/tedious';
export { vercelAIIntegration } from './integrations/vercel-ai';
export { expressIntegration } from './integrations/express';
export { firebaseIntegration } from './integrations/firebase';
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
startInactiveSpan,
startSpanManual,
} from '@sentry/core';
import { DEBUG_BUILD } from '../debug-build';
import { DEBUG_BUILD } from '../../debug-build';
import type { EngineSpan, ExtendedSpanOptions, SpanCallback, TracingHelper } from './types';
import { DB_STATEMENT, DB_SYSTEM, DB_SYSTEM_NAME, SENTRY_KIND, SENTRY_OP } from '@sentry/conventions/attributes';

Expand Down
Loading
Loading