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
Expand Up @@ -7,6 +7,9 @@ interface ValidateProfileOptions {
isChunkFormat?: boolean;
}

/** Seconds — consecutive chunk timestamps can jitter slightly below float precision (see profiling flakes). */
const CHUNK_SAMPLE_TIMESTAMP_EPSILON_SEC = 1e-5;

/**
* Validates the metadata of a profile chunk envelope.
* https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/
Expand Down Expand Up @@ -66,9 +69,9 @@ export function validateProfile(
const ts = chunkProfileSample.timestamp;
expect(Number.isFinite(ts)).toBe(true);
expect(ts).toBeGreaterThan(0);
// Monotonic non-decreasing timestamps
expect(ts).toBeGreaterThanOrEqual(previousTimestamp);
previousTimestamp = ts;
// Monotonic non-decreasing timestamps (epsilon: jitter / IEEE754 around ~1e9 epoch seconds)
expect(ts).toBeGreaterThanOrEqual(previousTimestamp - CHUNK_SAMPLE_TIMESTAMP_EPSILON_SEC);
previousTimestamp = Math.max(previousTimestamp, ts);
} else {
// Legacy format uses elapsed_since_start_ns as a string
const legacyProfileSample = sample as ThreadCpuProfile['samples'][number];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,15 @@ sentryTest(
}

const url = await getLocalTestUrl({ testDir: __dirname, responseHeaders: { 'Document-Policy': 'js-profiling' } });
await page.goto(url);

const profileChunkEnvelopePromise = getMultipleSentryEnvelopeRequests<ProfileChunkEnvelope>(
const profileChunkEnvelopes = await getMultipleSentryEnvelopeRequests<ProfileChunkEnvelope>(
page,
1,
{ envelopeType: 'profile_chunk' },
Comment thread
mydea marked this conversation as resolved.
{ url, envelopeType: 'profile_chunk', timeout: 5000 },
properFullEnvelopeRequestParser,
);

const profileChunkEnvelopeItem = (await profileChunkEnvelopePromise)[0][1][0];
const profileChunkEnvelopeItem = profileChunkEnvelopes[0][1][0];
const envelopeItemHeader = profileChunkEnvelopeItem[0];
const envelopeItemPayload = profileChunkEnvelopeItem[1];

Expand Down
Loading