Skip to content

Instantly share code, notes, and snippets.

View Lms24's full-sized avatar

Lukas Stracke Lms24

View GitHub Profile
@Lms24
Lms24 / sampling.js
Last active June 12, 2024 11:04
show the difference of storing a sampling decision on the client for subsequent trace propagations vs. not doing that
// Assumption for this script:
// All backend requests happen without an active client-side span. Meaning, depending on the values stored
// PropagationContext, server side transactions are either sampled with a server-side sample rate or
// force-sampled by continuing the trace from the client.
const serverSampleRate = 0.05;
const clientSampleRate = 0.2;
const serverTxnsPerPage = 10;
import type { HandleServerError, RequestEvent } from '@sveltejs/kit';
import * as SentryNode from '@sentry/node';
import type { Handle } from '@sveltejs/kit';
import '@sentry/tracing';
import type { Transaction } from '@sentry/types';
import {
baggageHeaderToDynamicSamplingContext,
dynamicSamplingContextToSentryBaggageHeader
} from '@sentry/utils';
import parse from 'node-html-parser';
@Lms24
Lms24 / sveltekit-routing-instrumentation.ts
Created March 10, 2023 15:14
SvelteKit Sentry Routing instrumentation PoC
export function svelteKitRoutingInstrumentation<T extends Transaction>(
customStartTransaction: (context: TransactionContext) => T | undefined,
startTransactionOnPageLoad?: boolean,
startTransactionOnLocationChange?: boolean
): void {
if (!browser) {
return;
}
function createPageloadTxn(): Transaction | undefined {