prisma: Instrumentation error in production: `TypeError: parentTracer.getSpanLimits is not a function`
Bug description
I am attempting to connect to honeycomb.io
with the new Prisma Telemetry options. In a dev environment this works just fine. But in production, I receive the following error:
TypeError: parentTracer.getSpanLimits is not a function
at new Span (/build/node_modules/@prisma/client/runtime/index.js:21694:37)
at /build/node_modules/@prisma/client/runtime/index.js:23527:18
at Array.forEach (<anonymous>)
at createSpan (/build/node_modules/@prisma/client/runtime/index.js:23511:25)
at runMicrotasks (<anonymous>)
at runNextTicks (node:internal/process/task_queues:61:5)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
How to reproduce
My code (after following these instructions: https://www.prisma.io/docs/concepts/components/prisma-client/opentelemetry-tracing#register-tracing-in-your-application)
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
import { PrismaInstrumentation } from "@prisma/instrumentation";
import { registerInstrumentations } from "@opentelemetry/instrumentation";
import { Resource } from "@opentelemetry/resources";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { SimpleSpanProcessor } from "@opentelemetry/sdk-trace-base";
function setupTelemetry() {
if (process.env.NODE_ENV !== "production") {
return;
}
const provider = new NodeTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: "SERVICE_NAME"
})
});
// Setup 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({
instrumentations: [new PrismaInstrumentation()],
tracerProvider: provider
});
provider.register();
// eslint-disable-next-line no-console
console.log("📈 Telemetry set up");
}
export default setupTelemetry;
I then import setupTelemetry
at the entrypoint for my application and execute it:
import setupTelemetry from './server/telemetry.ts';
// ....
setupTelemetry();
Expected behavior
In a production environment, I should not receive an error AND I should receive telemetry data to Honeycomb. Right now, I get the aforementioned error and receive no telemetry data.
In a development (local) environment, everything behaves as expected.
Prisma information
Packages:
"@prisma/client": "4.2.1",
"@prisma/instrumentation": "4.2.1",
"prisma": "4.2.1",
Environment & setup
- OS: macOS (local) and Linux (Azure App Services)
- Database: Azure PostgreSQL DB
- Node.js version: v16.14.2 (locally and in Azure)
Prisma Version
prisma : 4.2.1
@prisma/client : 4.2.1
Current platform : darwin-arm64
Query Engine (Node-API) : libquery-engine 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine : migration-engine-cli 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine : introspection-core 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary : prisma-fmt 2920a97877e12e055c1333079b8d19cee7f33826 (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Default Engines Hash : 2920a97877e12e055c1333079b8d19cee7f33826
Studio : 0.469.0
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 11
- Comments: 30 (11 by maintainers)
Not work:
Work fine:
Here’s a minimal representation of this error where I can reproduce the error:
https://github.com/SheaBelsky/prisma-instrumentation-test
Using the following Azure Services:
In this minimal environment locally, I can get Honeycomb data to work. But in production (Docker), I cannot and I get the following error:
On a second thought and a little bit more digging in, I think it is Prisma issue after all. We should not try to create the spans if there is no active tracer present.
I still get the issue even after having installed
@opentelemetry/api
:Simplest way to reproduce:
Update
Finally, I succeeded to have it work, by setting
@prisma/instrumentation
to version4.13.0
.I get the error with all the versions >=
4.14.0
So what worked for me is:
Update 2
Here is the diff between the 4.13.1 and 4.14.0 tags: https://github.com/prisma/prisma/compare/4.13.0...4.14.0
I’m also experiencing this deploying to ECS after upgrading @prisma/* from 5.2.0 to 5.4.1.
This problem appeared on my repo because of End to End testing with Playwright on a Github Action. I can’t reproduce it locally but with the last
Bump @prisma/instrumentation from 4.13.0 to 4.14.1
it exploded. OpenTelemetry is up to date but we can’t do the upgrade of @prisma/instrumentation because of that error.Thank you for trying this, we are looking into it.
@danstarns Got it! I was able to get tracing/instrumentation logs using the Console exporter locally. I’m going to confirm that behavior in Azure App Service now, I’ll let you know how that goes.
@SheaBelsky Thank you for the replication. I took your docker file and then run the application, sent an HTTP request to
/users
- No traces in honeycomb plus I don’t get any error.What I did find is that if I use the console exporter from open opentelemetry I do indeed see the Prisma traces. Here is what I changed to see the traces in the console:
Can you confirm that if you enable console logging, you see the Prisma traces in the console and you don’t get the described error?
@SheaBelsky thank you for the detailed help. We will look into it and see what the fix is.
@SheaBelsky one more thing. If you run the docker instance locally, do you still get the error or is it only docker running on Azure?
Will work on this today!
Can you maybe create a minimal Node project with Prisma and the tracing setup you are using, and see if that also causes the problem you are describing? That would make it a lot easier for us to maybe also try to deploy such a project to Azure App Services and see if that triggers the problem for us as well. Thanks @SheaBelsky.