Skip to content

Commit 84090bd

Browse files
committed
fix: ignore deprecations
1 parent 3b5564f commit 84090bd

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

packages/profiling-node/src/hubextensions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export function maybeProfileTransaction(
2727
// profilesSampleRate is multiplied with tracesSampleRate to get the final sampling rate. We dont perform
2828
// the actual multiplication to get the final rate, but we discard the profile if the transaction was sampled,
2929
// so anything after this block from here is based on the transaction sampling.
30+
// eslint-disable-next-line deprecation/deprecation
3031
if (!transaction.sampled) {
3132
return;
3233
}
@@ -52,6 +53,7 @@ export function maybeProfileTransaction(
5253

5354
// Prefer sampler to sample rate if both are provided.
5455
if (typeof profilesSampler === 'function') {
56+
// eslint-disable-next-line deprecation/deprecation
5557
profilesSampleRate = profilesSampler({ transactionContext: transaction.toContext(), ...customSamplingContext });
5658
}
5759

@@ -96,6 +98,7 @@ export function maybeProfileTransaction(
9698
const profile_id = uuid4();
9799
CpuProfilerBindings.startProfiling(profile_id);
98100
if (isDebugBuild()) {
101+
// eslint-disable-next-line deprecation/deprecation
99102
logger.log(`[Profiling] started profiling transaction: ${transaction.name}`);
100103
}
101104

@@ -122,13 +125,15 @@ export function stopTransactionProfile(
122125
const profile = CpuProfilerBindings.stopProfiling(profile_id);
123126

124127
if (isDebugBuild()) {
128+
// eslint-disable-next-line deprecation/deprecation
125129
logger.log(`[Profiling] stopped profiling of transaction: ${transaction.name}`);
126130
}
127131

128132
// In case of an overlapping transaction, stopProfiling may return null and silently ignore the overlapping profile.
129133
if (!profile) {
130134
if (isDebugBuild()) {
131135
logger.log(
136+
// eslint-disable-next-line deprecation/deprecation
132137
`[Profiling] profiler returned null profile for: ${transaction.name}`,
133138
'this may indicate an overlapping transaction or a call to stopProfiling with a profile title that was never started',
134139
);
@@ -184,6 +189,7 @@ export function __PRIVATE__wrapStartTransactionWithProfiling(startTransaction: S
184189
// Enqueue a timeout to prevent profiles from running over max duration.
185190
let maxDurationTimeoutID: NodeJS.Timeout | void = global.setTimeout(() => {
186191
if (isDebugBuild()) {
192+
// eslint-disable-next-line deprecation/deprecation
187193
logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', transaction.name);
188194
}
189195
profile = stopTransactionProfile(transaction, profile_id);
@@ -211,6 +217,7 @@ export function __PRIVATE__wrapStartTransactionWithProfiling(startTransaction: S
211217
}
212218

213219
// @ts-expect-error profile is not part of metadata
220+
// eslint-disable-next-line deprecation/deprecation
214221
transaction.setMetadata({ profile });
215222
return originalFinish();
216223
}

packages/profiling-node/src/integration.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export class ProfilingIntegration implements Integration {
7878
// Enqueue a timeout to prevent profiles from running over max duration.
7979
PROFILE_TIMEOUTS[profile_id] = global.setTimeout(() => {
8080
if (isDebugBuild()) {
81+
// eslint-disable-next-line deprecation/deprecation
8182
logger.log('[Profiling] max profile duration elapsed, stopping profiling for:', transaction.name);
8283
}
8384

@@ -87,14 +88,17 @@ export class ProfilingIntegration implements Integration {
8788
}
8889
}, maxProfileDurationMs);
8990

91+
// eslint-disable-next-line deprecation/deprecation
9092
transaction.setContext('profile', { profile_id });
9193
// @ts-expect-error profile_id is not part of the metadata type
94+
// eslint-disable-next-line deprecation/deprecation
9295
transaction.setMetadata({ profile_id: profile_id });
9396
}
9497
});
9598

9699
client.on('finishTransaction', transaction => {
97100
// @ts-expect-error profile_id is not part of the metadata type
101+
// eslint-disable-next-line deprecation/deprecation
98102
const profile_id = transaction.metadata.profile_id;
99103
if (profile_id && typeof profile_id === 'string') {
100104
if (PROFILE_TIMEOUTS[profile_id]) {

packages/profiling-node/test/hubextensions.hub.test.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ describe('hubextensions', () => {
9393

9494
const transportSpy = jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
9595

96+
// eslint-disable-next-line deprecation/deprecation
9697
const transaction = Sentry.getCurrentHub().startTransaction({ name: 'profile_hub' });
9798
await wait(500);
9899
transaction.finish();
@@ -127,11 +128,12 @@ describe('hubextensions', () => {
127128

128129
jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
129130

131+
// eslint-disable-next-line deprecation/deprecation
130132
const transaction = Sentry.getCurrentHub().startTransaction({ name: 'profile_hub' });
131133
transaction.finish();
132134

133135
await Sentry.flush(1000);
134-
expect(logSpy.mock?.lastCall?.[0]).toBe('[Profiling] Discarding profile because it contains less than 2 samples');
136+
expect(logSpy.mock?.[logSpy.mock.calls.length-1]?.[0]).toBe('[Profiling] Discarding profile because it contains less than 2 samples');
135137

136138
expect((transport.send as any).mock.calls[0][0][1][0][0].type).toBe('transaction');
137139
// eslint-disable-next-line @typescript-eslint/unbound-method
@@ -169,6 +171,7 @@ describe('hubextensions', () => {
169171

170172
jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
171173

174+
// eslint-disable-next-line deprecation/deprecation
172175
const transaction = Sentry.getCurrentHub().startTransaction({ name: 'profile_hub', traceId: 'boop' });
173176
await wait(500);
174177
transaction.finish();
@@ -188,14 +191,15 @@ describe('hubextensions', () => {
188191

189192
jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
190193

194+
// eslint-disable-next-line deprecation/deprecation
191195
const transaction = hub.startTransaction({ name: 'profile_hub' });
192196
await wait(500);
193197
transaction.finish();
194198

195199
await Sentry.flush(1000);
196200

197201
expect(startProfilingSpy).toHaveBeenCalledTimes(1);
198-
expect((stopProfilingSpy.mock.lastCall?.[0] as string).length).toBe(32);
202+
expect((stopProfilingSpy.mock[stopProfilingSpy.mock.calls.length-1]?.[0] as string).length).toBe(32);
199203
});
200204

201205
it('sends profile in the same envelope as transaction', async () => {
@@ -205,6 +209,7 @@ describe('hubextensions', () => {
205209

206210
const transportSpy = jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
207211

212+
// eslint-disable-next-line deprecation/deprecation
208213
const transaction = hub.startTransaction({ name: 'profile_hub' });
209214
await wait(500);
210215
transaction.finish();
@@ -252,6 +257,7 @@ describe('hubextensions', () => {
252257
return Promise.resolve();
253258
});
254259

260+
// eslint-disable-next-line deprecation/deprecation
255261
const transaction = hub.startTransaction({ name: 'profile_hub' });
256262
await wait(500);
257263
transaction.finish();
@@ -271,6 +277,7 @@ describe('hubextensions', () => {
271277

272278
client.on('preprocessEvent', onPreprocessEvent);
273279

280+
// eslint-disable-next-line deprecation/deprecation
274281
const transaction = hub.startTransaction({ name: 'profile_hub' });
275282
await wait(500);
276283
transaction.finish();
@@ -295,14 +302,15 @@ describe('hubextensions', () => {
295302
const startProfilingSpy = jest.spyOn(CpuProfilerBindings, 'startProfiling');
296303
const stopProfilingSpy = jest.spyOn(CpuProfilerBindings, 'stopProfiling');
297304

305+
// eslint-disable-next-line deprecation/deprecation
298306
const transaction = hub.startTransaction({ name: 'profile_hub' });
299307
await wait(500);
300308
transaction.finish();
301309

302310
await Sentry.flush(1000);
303311

304312
expect(startProfilingSpy).toHaveBeenCalledTimes(1);
305-
expect((stopProfilingSpy.mock.lastCall?.[0] as string).length).toBe(32);
313+
expect((stopProfilingSpy.mock[startProfilingSpy.mock.calls.length-1]?.[0] as string).length).toBe(32);
306314
});
307315

308316
it('sends profile in separate envelope', async () => {
@@ -315,6 +323,7 @@ describe('hubextensions', () => {
315323
return Promise.resolve();
316324
});
317325

326+
// eslint-disable-next-line deprecation/deprecation
318327
const transaction = hub.startTransaction({ name: 'profile_hub' });
319328
await wait(500);
320329
transaction.finish();
@@ -330,20 +339,21 @@ describe('hubextensions', () => {
330339
// it seems that in node 19 globals (or least part of them) are a readonly object
331340
// so when useFakeTimers is called it throws an error because it cannot override
332341
// a readonly property of performance on global object. Use legacyFakeTimers for now
333-
jest.useFakeTimers({ legacyFakeTimers: true });
342+
jest.useFakeTimers('legacy');
334343
const startProfilingSpy = jest.spyOn(CpuProfilerBindings, 'startProfiling');
335344
const stopProfilingSpy = jest.spyOn(CpuProfilerBindings, 'stopProfiling');
336345

337346
const [client] = makeClientWithoutHooks();
338347
const hub = Sentry.getCurrentHub();
339348
hub.bindClient(client);
340349

350+
// eslint-disable-next-line deprecation/deprecation
341351
const transaction = Sentry.getCurrentHub().startTransaction({ name: 'timeout_transaction' });
342352
expect(startProfilingSpy).toHaveBeenCalledTimes(1);
343353
jest.advanceTimersByTime(30001);
344354

345355
expect(stopProfilingSpy).toHaveBeenCalledTimes(1);
346-
expect((stopProfilingSpy.mock.lastCall?.[0] as string).length).toBe(32);
356+
expect((stopProfilingSpy.mock.calls[startProfilingSpy.mock.calls.length-1]?.[0] as string).length).toBe(32);
347357

348358
transaction.finish();
349359
expect(stopProfilingSpy).toHaveBeenCalledTimes(1);
@@ -357,6 +367,7 @@ describe('hubextensions', () => {
357367
const hub = Sentry.getCurrentHub();
358368
hub.bindClient(client);
359369

370+
// eslint-disable-next-line deprecation/deprecation
360371
const transaction = Sentry.getCurrentHub().startTransaction({ name: 'txn' });
361372
transaction.finish();
362373
transaction.finish();
@@ -398,6 +409,7 @@ describe('hubextensions', () => {
398409

399410
const transportSpy = jest.spyOn(transport, 'send').mockReturnValue(Promise.resolve());
400411

412+
// eslint-disable-next-line deprecation/deprecation
401413
const transaction = hub.startTransaction({ name: 'profile_hub' });
402414
await wait(500);
403415
transaction.finish();

packages/profiling-node/test/hubextensions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ function makeTransactionMock(options = {}): Transaction {
3030
this.contexts[key] = context;
3131
},
3232
setTag(this: Transaction, key: string, value: any) {
33+
// eslint-disable-next-line deprecation/deprecation
3334
this.tags[key] = value;
3435
},
3536
setMetadata(this: Transaction, metadata: Partial<TransactionMetadata>) {
37+
// eslint-disable-next-line deprecation/deprecation
3638
this.metadata = { ...metadata } as TransactionMetadata;
3739
},
3840
...options,

packages/profiling-node/test/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ describe('Sentry - Profiling', () => {
8282
const hub = Sentry.getCurrentHub();
8383
hub.bindClient(client);
8484

85+
// eslint-disable-next-line deprecation/deprecation
8586
const transaction = Sentry.startTransaction({ name: 'title' });
8687
await wait(500);
8788
transaction.finish();
@@ -95,7 +96,9 @@ describe('Sentry - Profiling', () => {
9596
const hub = Sentry.getCurrentHub();
9697
hub.bindClient(client);
9798

99+
// eslint-disable-next-line deprecation/deprecation
98100
const t1 = Sentry.startTransaction({ name: 'outer' });
101+
// eslint-disable-next-line deprecation/deprecation
99102
const t2 = Sentry.startTransaction({ name: 'inner' });
100103
await wait(500);
101104

@@ -115,7 +118,9 @@ describe('Sentry - Profiling', () => {
115118
const hub = Sentry.getCurrentHub();
116119
hub.bindClient(client);
117120

121+
// eslint-disable-next-line deprecation/deprecation
118122
const t1 = Sentry.startTransaction({ name: 'same-title' });
123+
// eslint-disable-next-line deprecation/deprecation
119124
const t2 = Sentry.startTransaction({ name: 'same-title' });
120125
await wait(500);
121126
t2.finish();
@@ -131,6 +136,7 @@ describe('Sentry - Profiling', () => {
131136
const hub = Sentry.getCurrentHub();
132137
hub.bindClient(client);
133138

139+
// eslint-disable-next-line deprecation/deprecation
134140
const transaction = Sentry.startTransaction({ name: 'title' });
135141
await wait(500);
136142
transaction.finish();

0 commit comments

Comments
 (0)