Skip to content

Commit 3d63621

Browse files
authored
profiling: add platform to chunk envelope (#15758)
We need to send the platform as part of envelope headers as this is the item that relay is checking to manage rate limiting. We only care about backend (node) and in the future frontend. @AbhiPrasad please correct me here to use the correct convention, would `javascript.node` be more appropriate? The only requirement really is to have all nodejs platform types be of a single platform type, so we dont need to maintain the ever growing list in relay
1 parent 4bc89bd commit 3d63621

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

packages/profiling-node/src/integration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ class ContinuousProfiler {
516516
const metadata = this._client.getSdkMetadata();
517517
const tunnel = this._client.getOptions().tunnel;
518518

519-
const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);
519+
const envelope = makeProfileChunkEnvelope('node', chunk, metadata?.sdk, tunnel, dsn);
520520
transport.send(envelope).then(null, reason => {
521521
DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);
522522
});

packages/profiling-node/src/utils.ts

+2
Original file line numberDiff line numberDiff line change
@@ -400,13 +400,15 @@ export function createEventEnvelopeHeaders(
400400
* Creates a standalone profile_chunk envelope.
401401
*/
402402
export function makeProfileChunkEnvelope(
403+
platform: 'node',
403404
chunk: ProfileChunk,
404405
sdkInfo: SdkInfo | undefined,
405406
tunnel: string | undefined,
406407
dsn?: DsnComponents,
407408
): ProfileChunkEnvelope {
408409
const profileChunkHeader: ProfileChunkItem[0] = {
409410
type: 'profile_chunk',
411+
platform,
410412
};
411413

412414
return createEnvelope<ProfileChunkEnvelope>(createEventEnvelopeHeaders(sdkInfo, tunnel, dsn), [

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,9 @@ describe('ProfilingIntegration', () => {
643643
Sentry.profiler.stopProfiler();
644644
vi.advanceTimersByTime(1000);
645645

646-
expect(transportSpy.mock.calls?.[0]?.[0]?.[1]?.[0]?.[0]?.type).toBe('profile_chunk');
646+
const envelopeHeaders = transportSpy.mock.calls?.[0]?.[0]?.[1]?.[0]?.[0];
647+
expect(envelopeHeaders?.type).toBe('profile_chunk');
648+
expect(envelopeHeaders?.platform).toBe('node');
647649
});
648650

649651
it('sets global profile context', async () => {

0 commit comments

Comments
 (0)