Skip to content

Commit b1cd5ac

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into timfish/feat/orchestrion-stats
2 parents e038103 + 943b866 commit b1cd5ac

25 files changed

Lines changed: 233 additions & 105 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
66

7-
Work in this release was contributed by @dobladov. Thank you for your contribution!
7+
Work in this release was contributed by @dobladov and @PeterWadie. Thank you for your contributions!
88

99
## 10.65.0
1010

packages/astro/test/server/middleware.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ describe('sentryMiddleware', () => {
6666
queryParams: true,
6767
graphQL: { document: true, variables: true },
6868
genAI: { inputs: false, outputs: false },
69+
databaseQueryData: true,
6970
stackFrameVariables: true,
7071
frameContextLines: 5,
7172
}),

packages/bun/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"access": "public"
5050
},
5151
"dependencies": {
52-
"@apm-js-collab/code-transformer-bundler-plugins": "^0.5.0",
52+
"@apm-js-collab/code-transformer-bundler-plugins": "^0.6.0",
5353
"@sentry/core": "10.65.0",
5454
"@sentry/node": "10.65.0",
5555
"@sentry/server-utils": "10.65.0"

packages/bun/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,12 @@ export type { BunOptions } from './types';
198198

199199
// eslint-disable-next-line typescript/no-deprecated
200200
export { BunClient } from './client';
201-
export { getDefaultIntegrations, init } from './sdk';
201+
export {
202+
getDefaultIntegrations,
203+
getDefaultIntegrationsWithoutPerformance,
204+
init,
205+
initWithoutDefaultIntegrations,
206+
} from './sdk';
202207
export { bunServerIntegration } from './integrations/bunserver';
203208
export { bunRuntimeMetricsIntegration, type BunRuntimeMetricsOptions } from './integrations/bunRuntimeMetrics';
204209
export { makeFetchTransport } from './transports';

packages/bun/src/sdk.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ function getPerformanceIntegrations(options: Options): Integration[] {
6363
];
6464
}
6565

66-
/** Get the default integrations for the Bun SDK. */
67-
export function getDefaultIntegrations(options: Options): Integration[] {
68-
// We return a copy of the defaultIntegrations here to avoid mutating this
66+
/** Get the default integrations for the Bun SDK, excluding performance integrations. */
67+
export function getDefaultIntegrationsWithoutPerformance(): Integration[] {
68+
// Return a fresh array on each call so callers can safely mutate the result.
6969
return [
7070
// Common
7171
// TODO(v11): Replace with eventFiltersIntegration once we remove the deprecated `inboundFiltersIntegration`
@@ -88,10 +88,14 @@ export function getDefaultIntegrations(options: Options): Integration[] {
8888
processSessionIntegration(),
8989
// Bun Specific
9090
bunServerIntegration(),
91-
...getPerformanceIntegrations(options),
9291
];
9392
}
9493

94+
/** Get the default integrations for the Bun SDK. */
95+
export function getDefaultIntegrations(options: Options): Integration[] {
96+
return [...getDefaultIntegrationsWithoutPerformance(), ...getPerformanceIntegrations(options)];
97+
}
98+
9599
/**
96100
* The Sentry Bun SDK Client.
97101
*
@@ -137,6 +141,23 @@ export function getDefaultIntegrations(options: Options): Integration[] {
137141
* @see {@link BunOptions} for documentation on configuration options.
138142
*/
139143
export function init(userOptions: BunOptions = {}): NodeClient | undefined {
144+
return _init(userOptions, getDefaultIntegrations);
145+
}
146+
147+
/**
148+
* Initialize Sentry for Bun, without any integrations added by default.
149+
*/
150+
export function initWithoutDefaultIntegrations(userOptions: BunOptions = {}): NodeClient | undefined {
151+
return _init(userOptions, () => []);
152+
}
153+
154+
/**
155+
* Internal initialization function.
156+
*/
157+
function _init(
158+
userOptions: BunOptions = {},
159+
getDefaultIntegrationsImpl: (options: Options) => Integration[],
160+
): NodeClient | undefined {
140161
applySdkMetadata(userOptions, 'bun');
141162

142163
const options = {
@@ -149,7 +170,7 @@ export function init(userOptions: BunOptions = {}): NodeClient | undefined {
149170
options.transport = options.transport || makeFetchTransport;
150171

151172
if (options.defaultIntegrations === undefined) {
152-
options.defaultIntegrations = getDefaultIntegrations(options);
173+
options.defaultIntegrations = getDefaultIntegrationsImpl(options);
153174
}
154175

155176
return initNode(options);

packages/bun/test/init.test.ts

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { type Integration } from '@sentry/core';
22
import * as sentryNode from '@sentry/node';
33
import type { Mock } from 'bun:test';
44
import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
5-
import { getClient, init } from '../src';
5+
import {
6+
getClient,
7+
getDefaultIntegrations,
8+
getDefaultIntegrationsWithoutPerformance,
9+
init,
10+
initWithoutDefaultIntegrations,
11+
} from '../src';
612

713
const PUBLIC_DSN = 'https://username@domain/123';
814

@@ -123,4 +129,47 @@ describe('init()', () => {
123129
expect(integrations?.map(({ name }) => name)).toContain('Some mock integration 4.3');
124130
});
125131
});
132+
133+
describe('initWithoutDefaultIntegrations()', () => {
134+
it('installs no default integrations', () => {
135+
initWithoutDefaultIntegrations({ dsn: PUBLIC_DSN });
136+
137+
const client = getClient();
138+
139+
expect(client?.getOptions().integrations).toEqual([]);
140+
expect(mockAutoPerformanceIntegrations).toHaveBeenCalledTimes(0);
141+
});
142+
143+
it('still installs user-provided integrations', () => {
144+
const customIntegration = new MockIntegration('Custom integration');
145+
146+
initWithoutDefaultIntegrations({ dsn: PUBLIC_DSN, integrations: [customIntegration] });
147+
148+
const client = getClient();
149+
150+
expect(client?.getOptions().integrations.map(({ name }) => name)).toEqual(['Custom integration']);
151+
expect(customIntegration.setupOnce).toHaveBeenCalledTimes(1);
152+
});
153+
});
154+
155+
describe('getDefaultIntegrationsWithoutPerformance()', () => {
156+
it('matches the full default set when tracing is disabled (no performance integrations added)', () => {
157+
const withoutPerformance = getDefaultIntegrationsWithoutPerformance().map(({ name }) => name);
158+
const full = getDefaultIntegrations({}).map(({ name }) => name);
159+
160+
expect(withoutPerformance).toEqual(full);
161+
expect(mockAutoPerformanceIntegrations).toHaveBeenCalledTimes(0);
162+
});
163+
164+
it('omits the performance integrations that the full set adds when tracing is enabled', () => {
165+
const performanceIntegration = new MockIntegration('Performance integration');
166+
mockAutoPerformanceIntegrations.mockImplementation(() => [performanceIntegration]);
167+
168+
const withoutPerformance = getDefaultIntegrationsWithoutPerformance().map(({ name }) => name);
169+
const full = getDefaultIntegrations({ tracesSampleRate: 1 }).map(({ name }) => name);
170+
171+
expect(full).toContain('Performance integration');
172+
expect(withoutPerformance).not.toContain('Performance integration');
173+
});
174+
});
126175
});

packages/core/src/client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ export abstract class Client<O extends ClientOptions = ClientOptions> {
467467
*/
468468
// @ts-expect-error - PromiseLike is a subset of Promise
469469
public async close(timeout?: number): PromiseLike<boolean> {
470-
_INTERNAL_flushLogsBuffer(this);
471470
const result = await this.flush(timeout);
472471
this.getOptions().enabled = false;
473472
this.emit('close');

packages/core/src/integrations/http/client-subscriptions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import type { SpanStatus } from '../../types/spanStatus';
1717
import { addOutgoingRequestBreadcrumb } from './add-outgoing-request-breadcrumb';
1818
import {
19+
bindScopeToEmitter,
1920
getSpanStatusFromHttpCode,
2021
SPAN_STATUS_ERROR,
2122
SPAN_STATUS_UNSET,
@@ -156,6 +157,7 @@ export function getHttpClientSubscriptions(options: HttpInstrumentationOptions):
156157
response.resume();
157158
}
158159
setIncomingResponseSpanData(response, span);
160+
bindScopeToEmitter(response);
159161
options.outgoingResponseHook?.(span, response);
160162

161163
let finished = false;

packages/core/src/integrations/supabase.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ function instrumentPostgRESTFilterBuilder(
385385
}
386386

387387
const client = getClient();
388-
const shouldSendData = _options.sendOperationData ?? client?.getDataCollectionOptions().userInfo === true;
388+
const shouldSendData =
389+
_options.sendOperationData ?? client?.getDataCollectionOptions().databaseQueryData === true;
389390
const bodyPayload = getMutationBodyPayloadForTelemetry(typedThis.body, body);
390391

391392
// Adding operation to the beginning of the description if it's not a `select` operation
@@ -563,7 +564,7 @@ interface SupabaseIntegrationOptions {
563564
* Whether to attach PostgREST query filters and mutation body payloads
564565
* to Sentry telemetry.
565566
*
566-
* Falls back to `dataCollection.userInfo` when not set.
567+
* Falls back to `dataCollection.databaseQueryData` when not set.
567568
* @default undefined
568569
*/
569570
sendOperationData?: boolean;

packages/core/src/types/datacollection.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ export interface DataCollection {
7878
outputs?: boolean;
7979
};
8080

81+
/**
82+
* Include data associated with database queries. This controls collection of query parameters, inline literal values within query text, mutation/request bodies, and returned result data.
83+
*
84+
* Sanitized or parameterized DB statements (`db.query.text`) are **not** controlled by this property. Structural metadata such as the database system, query summary, operation name, or the table being acted upon is also **always** collected.
85+
* @default true
86+
*/
87+
databaseQueryData?: boolean;
88+
8189
/**
8290
* Capture local variable values in stack frames.
8391
* @default true

0 commit comments

Comments
 (0)