Skip to content
Open
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,25 +1,32 @@
import * as Sentry from '@sentry/node';
import { loggingTransport } from '@sentry-internal/node-integration-tests';

const requestHook = (span, sanitizedSqlQuery, connectionContext) => {
// Add custom attributes to demonstrate requestHook functionality
span.setAttribute('custom.requestHook', 'called');

// Set context information as extras for test validation
Sentry.setExtra('requestHookCalled', {
sanitizedQuery: sanitizedSqlQuery,
database: connectionContext?.ATTR_DB_NAMESPACE,
host: connectionContext?.ATTR_SERVER_ADDRESS,
port: connectionContext?.ATTR_SERVER_PORT,
});
};

// Under orchestrion (INJECT_ORCHESTRION), `experimentalUseDiagnosticsChannelInjection()` has already run
// and the default `PostgresJs` OTel integration is swapped for the channel one. Passing the OTel
// `postgresJsIntegration()` explicitly here would override that swap and silently re-test the old path,
// so use the channel integration instead — configured with the same requestHook.
const postgresJsIntegration =
process.env.INJECT_ORCHESTRION === 'true'
? Sentry.diagnosticsChannelInjectionIntegrations().postgresJsIntegration({ requestHook })
: Sentry.postgresJsIntegration({ requestHook });

Sentry.init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
release: '1.0',
tracesSampleRate: 1.0,
transport: loggingTransport,
integrations: [
Sentry.postgresJsIntegration({
requestHook: (span, sanitizedSqlQuery, connectionContext) => {
// Add custom attributes to demonstrate requestHook functionality
span.setAttribute('custom.requestHook', 'called');

// Set context information as extras for test validation
Sentry.setExtra('requestHookCalled', {
sanitizedQuery: sanitizedSqlQuery,
database: connectionContext?.ATTR_DB_NAMESPACE,
host: connectionContext?.ATTR_SERVER_ADDRESS,
port: connectionContext?.ATTR_SERVER_PORT,
});
},
}),
],
integrations: [postgresJsIntegration],
});
Loading
Loading