# OpenTelemetry for SvelteKit

Instrument your SvelteKit applications with OpenTelemetry using the the Baselime Node.js OpenTelemetry SDK and the SvelteKit OpenTelemetry Middleware.


# Instrumentation

# Step 1: Install the SDK

Install @baselime/node-opentelemetry in your project.

terminal
npm i @baselime/node-opentelemetry @baselime/sveltekit-opentelemetry-middleware

# Step 2: Initialise the tracer

Create a file instrumentation.ts in the root of your project and add the following code to configure and initialize OpenTelemetry.

instrumentation.ts
import { withOpenTelemetry } from '@baselime/sveltekit-opentelemetry-middleware'
import { BaselimeSDK } from '@baselime/node-opentelemetry';

new BaselimeSDK({}).start();

export const handle = withOpenTelemetry(async ({ event, resolve }) => resolve(event));

# Step 3: Set the Baselime environment variables

Set the BASELIME_KEY environment variable to your Baselime public API Key. Get your public API key from the Baselime console.