question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Instrumentation error in production - TypeError: parentTracer.getSpanLimits is not a function

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:4
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
SheaBelskycommented, Aug 22, 2022

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:

2022-08-22T15:56:13.052368931Z /build/node_modules/@prisma/client/runtime/index.js:21694
2022-08-22T15:56:13.052433833Z     this._spanLimits = parentTracer.getSpanLimits();
2022-08-22T15:56:13.052441634Z                                     ^
2022-08-22T15:56:13.052446134Z
2022-08-22T15:56:13.052450234Z TypeError: parentTracer.getSpanLimits is not a function
2022-08-22T15:56:13.052454434Z     at new Span (/build/node_modules/@prisma/client/runtime/index.js:21694:37)
2022-08-22T15:56:13.052458634Z     at /build/node_modules/@prisma/client/runtime/index.js:23527:18
2022-08-22T15:56:13.052462834Z     at Array.forEach (<anonymous>)
2022-08-22T15:56:13.052468335Z     at createSpan (/build/node_modules/@prisma/client/runtime/index.js:23511:25)
1reaction
danstarnscommented, Sep 1, 2022

Still getting the same error in Azure when using ConsoleSpanExporter, and I don’t see any emitted traces in the console @danstarns

2022-09-01T13:51:45.139071054Z TypeError: parentTracer.getSpanLimits is not a function
2022-09-01T13:51:45.139088555Z     at new Span (/build/node_modules/@prisma/client/runtime/index.js:21694:37)
2022-09-01T13:51:45.139100956Z     at /build/node_modules/@prisma/client/runtime/index.js:23527:18
2022-09-01T13:51:45.139105557Z     at Array.forEach (<anonymous>)
2022-09-01T13:51:45.139110157Z     at createSpan (/build/node_modules/@prisma/client/runtime/index.js:23511:25)
2022-09-01T13:51:45.139114257Z     at runNextTicks (node:internal/process/task_queues:61:5)
2022-09-01T13:51:45.139131858Z     at listOnTimeout (node:internal/timers:528:9)
2022-09-01T13:51:45.139136359Z     at processTimers (node:internal/timers:502:7)
2022-09-01T13:51:45.291346076Z This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:

Thank you for trying this, we are looking into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

instrumentation error on Fastify version 4 · Issue #2118 - GitHub
any request return an error 500 with erro message: '"next is not a function". Steps to reproduce add import import '.
Read more >
Uncaught TypeError | Is Not A Function | Solution - YouTube
Have you encountered an error like:- Uncaught TypeError - Some selector is not a function - jQuery is not a function - owlCarousel...
Read more >
Node.js Custom Instrumentation - Datadog Docs
Synchronous code can be traced with tracer.trace() which will automatically finish the span when its callback returns and capture any thrown error automatically ......
Read more >
Measurement Error - SERC - Carleton
Anytime data is presented in class, not only in an instrumentation course, it is important they understand the errors associated with that ...
Read more >
Uncaught TypeError: state.productDetails is not a function
As the error suggests. state.productDetails is not a function. This is because productDetails is a reducer object and Not a function created ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found