Insturmentation.ts for otel/tracing

I’m trying to follow vercel’s docs to enable opentelemetry on a NON-NEXTJS node project (SvelteKit), where i’ve insturmented my application manually.

All the docs say “just throw an insturmentation.ts file in the root of your project and we’ll handle the rest” but nowhere in the build or svelte adapter build does this happen!

So, can i even inject insturmentation.ts (or .js) in the vercel build output somehow?

I’ve been banging my head for days on this.

Hey @zyther! It looks like you have spelling error in the file name. It should be instrumentation.ts. If you change the file name, does that work for you?

Don’t forget to create spans for each request since it’s not a Next.js project. The start tracing requests in your project step has some example code in case you need it. You can click over to the Other Frameworks tab to see it.

1 Like

Omfg. Thank you. I’ll try this.

Good lord thanks. XD

I come back to report that this did not solve the problem. I should be seeing smaller dns, tls, and http traces even if they’re not attached to a root span.

I see no telemetry coming in at all, nor do i see my application logging any otel messages when i deploy to vercel. (middleware.io)

I also know my instrumentation.ts file works if i import it directly

I have an instrumentation.ts, js in both root and src, and vercel still doesnt want to see it.
I could try placing it right in the output directory, but now i feel im doing too much for what the feature says it should do.

Do you have one of the prerequisite OTEL integrations connected? It sounds like you’re using Middleware.io, but I want to make sure that’s actually the integration used for this project. A custom OTEL exporter may be needed in that case.

Hi there Amy

I’ve cycled through every OTEL provider. I’ve now ditched middleware for NewRelic, and have implemented standard OTEL

this is my intrumentation.ts (and .js)

console.log("hello from tracer src/instrumentation.js");
import { config } from "dotenv";
config();
import "@opentelemetry/auto-instrumentations-node/register";

super simple. Works locally with node --import dotenv/config --import ./intrumentation.js build

it sits in the root of my repo (both .ts and .js) AND in /src

no dice

the only thing i can truly think of is to use the node adapter, build it for nodejs (not vercel specifically) and tell vercel to run the node built product instead of the serverless vercel-build product.

It sounds like the configuration of some part of this isn’t quite right, so I asked v0 for the recommended setup for SvelteKit projects.

If you already tried that exact setup and it didn’t work, please share a minimal reproducible example so we can investigate further :pray: