Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changeset/cli-sentry-bun-warning.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tigrisdata/cli": patch
---

Stop the standalone binary from printing a Sentry "No diagnostics-channel injection detected" warning on every command. Telemetry now enables only the Sentry integrations error reporting needs, instead of every default minus a denylist.
34 changes: 19 additions & 15 deletions packages/cli/src/utils/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export function invocationCommand(argv: string[]): string | undefined {
return first && !first.startsWith('-') ? first : undefined;
}

// Sentry default integrations we deliberately drop:
// The Sentry default integrations we keep. An allowlist, because each SDK
// release adds defaults for servers, databases and AI libraries that a CLI
// never loads, and some of them print a warning on every run in the Bun
// binary ("No diagnostics-channel injection detected").
//
// Defaults we deliberately leave out, besides those:
// - OnUncaughtException / OnUnhandledRejection: we own process exit ourselves.
// - LocalVariables(Async): captures local variable values (e.g. credentials)
// into stack frames, which beforeSend does not scrub.
Expand All @@ -91,23 +96,23 @@ export function invocationCommand(argv: string[]): string | undefined {
// processed when the process ended. Without them capture is synchronous; the
// OS release is set in configure() instead, and source lines of the minified
// bundle say little.
export const DISABLED_INTEGRATIONS: ReadonlySet<string> = new Set([
'OnUncaughtException',
'OnUnhandledRejection',
'LocalVariables',
'LocalVariablesAsync',
'Console',
'ChildProcess',
'ProcessSession',
'Context',
'ContextLines',
export const ENABLED_INTEGRATIONS: ReadonlySet<string> = new Set([
'EventFilters',
'FunctionToString',
'LinkedErrors',
'Dedupe',
'NodeSystemError',
'Http',
'NodeFetch',
'WorkerThreads',
'Modules',
]);

/** The SDK's default integrations minus DISABLED_INTEGRATIONS. */
/** The SDK's default integrations that are in ENABLED_INTEGRATIONS. */
export function selectIntegrations<T extends { name: string }>(
defaults: T[]
): T[] {
return defaults.filter((i) => !DISABLED_INTEGRATIONS.has(i.name));
return defaults.filter((i) => ENABLED_INTEGRATIONS.has(i.name));
}

/**
Expand Down Expand Up @@ -235,8 +240,7 @@ function configure(sdk: SentryModule, dsn: string): void {
// Error reporting only — no performance tracing.
tracesSampleRate: 0,
dataCollection: DATA_COLLECTION,
// Drop integrations that fight our exit handling, delay capture, or
// capture user data we don't scrub. See DISABLED_INTEGRATIONS.
// Only the integrations error reporting needs. See ENABLED_INTEGRATIONS.
integrations: selectIntegrations,
beforeSend,
// Delivered by the detached sender; see makeQueuedTransport.
Expand Down
57 changes: 31 additions & 26 deletions packages/cli/test/utils/telemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,54 @@ import { describe, expect, it } from 'vitest';

import {
beforeSend,
DISABLED_INTEGRATIONS,
ENABLED_INTEGRATIONS,
invocationCommand,
redactSecrets,
scrubArgv,
selectIntegrations,
} from '../../src/utils/telemetry.js';

describe('selectIntegrations', () => {
// The filter works by name, so a rename upstream would silently stop
// dropping an integration. Pin the ones that carry user data.
const guarded = [
'OnUncaughtException',
'OnUnhandledRejection',
'LocalVariablesAsync',
'Console',
'ChildProcess',
// Not user data, but they delay exit or make capture asynchronous, which
// the detached sender depends on not happening.
'ProcessSession',
'Context',
'ContextLines',
];
const kept = () =>
selectIntegrations(getDefaultIntegrations({})).map((i) => i.name);

it('still finds every guarded integration among the defaults', () => {
// The filter works by name, so a rename upstream would silently drop an
// integration we rely on.
it('still finds every enabled integration among the defaults', () => {
const names = getDefaultIntegrations({}).map((i) => i.name);
for (const name of guarded) {
for (const name of ENABLED_INTEGRATIONS) {
expect(
names,
`${name} is no longer a default integration name`
).toContain(name);
}
expect(kept()).toEqual(
names.filter((name) => ENABLED_INTEGRATIONS.has(name))
);
});

it('drops them and keeps the rest', () => {
const defaults = getDefaultIntegrations({});
const kept = selectIntegrations(defaults).map((i) => i.name);
for (const name of DISABLED_INTEGRATIONS) {
expect(kept).not.toContain(name);
it('drops integrations that carry user data or delay exit', () => {
for (const name of [
'OnUncaughtException',
'OnUnhandledRejection',
'LocalVariables',
'LocalVariablesAsync',
'Console',
'ChildProcess',
'ProcessSession',
'Context',
'ContextLines',
]) {
expect(kept()).not.toContain(name);
}
});

// These instrument libraries through diagnostics channels, which the Bun
// binary cannot inject, so Sentry warns on every run when they are on.
it('drops server framework integrations', () => {
for (const name of ['Express', 'Fastify', 'Hapi', 'Hono', 'Koa', 'Nitro']) {
expect(kept()).not.toContain(name);
}
expect(kept.length).toBe(
defaults.filter((i) => !DISABLED_INTEGRATIONS.has(i.name)).length
);
expect(kept).toContain('LinkedErrors');
});
});

Expand Down