Tracing / OTEL only works with manual active spans.

I have just spent a few hours pulling my hair out to no avail. I tried to boil things down simply: Ths code does not submit any traces to the console nor Jaeger UI:
import { OTLPTraceExporter } from "
// Configure the trace provider
const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: "example application",
[SEMRESATTRS_SERVICE_VERSION]: "0.0.1",
}),
});

// Configure how spans are processed and exported. In this case we're sending spans
// as we receive them to an OTLP-compatible collector (e.g. Jaeger).
provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));

// Register your auto-instrumentors
registerInstrumentations({
tracerProvider: provider,
instrumentations: [new PrismaInstrumentation({ middleware: true })],
});

// Register the provider globally
provider.register();

import { PrismaClient } from "@prisma/client";

async function main() {
const data = await new PrismaClient().user.findFirst();
console.log("data", data);
}
main();
import { OTLPTraceExporter } from "
// Configure the trace provider
const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: "example application",
[SEMRESATTRS_SERVICE_VERSION]: "0.0.1",
}),
});

// Configure how spans are processed and exported. In this case we're sending spans
// as we receive them to an OTLP-compatible collector (e.g. Jaeger).
provider.addSpanProcessor(new SimpleSpanProcessor(new OTLPTraceExporter()));

// Register your auto-instrumentors
registerInstrumentations({
tracerProvider: provider,
instrumentations: [new PrismaInstrumentation({ middleware: true })],
});

// Register the provider globally
provider.register();

import { PrismaClient } from "@prisma/client";

async function main() {
const data = await new PrismaClient().user.findFirst();
console.log("data", data);
}
main();
Confusingly, if I send a manual trace, it shows up in the Jager UI. This indicates to me that something about the Prisma configuration is not working (I have followed the steps in the documentation... (1) enabled tracing (2) placed init before any code (3) run npx prisma generate`)
const tracer = trace.getTracer("Application");

tracer.startActiveSpan("testSpan", async (span) => {
const data = await new PrismaClient().user.findFirst();
console.log("data", data);
span.end();
});
const tracer = trace.getTracer("Application");

tracer.startActiveSpan("testSpan", async (span) => {
const data = await new PrismaClient().user.findFirst();
console.log("data", data);
span.end();
});
5 Replies
RaphaelEtim
RaphaelEtim3d ago
Hi @Julian IncrEdelman What version of Prisma are you using? We recently released version 5.22.0 which fixed some of the bugs associated with tracing.
GitHub
Releases · prisma/prisma
Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB - prisma/prisma
Julian IncrEdelman
5.22
RaphaelEtim
RaphaelEtim3d ago
Thanks for confirming, do you have a reproducible example you can share?
Julian IncrEdelman
No. Let me see if I can get one. This is low pri but wanted to flag since I invested hours in this without avail and assume other ppl are running into it n
RaphaelEtim
RaphaelEtim2d ago
Thanks for raising this. The reproduction will be helpful for me to share with the engineering team so that they can take steps to fix it.
Want results from more Discord servers?
Add your server