You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@prisma/instrumentation

Package Overview
Dependencies
Maintainers
3
Versions
5282
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@prisma/instrumentation

OpenTelemetry compliant instrumentation for Prisma Client

6.12.0
latest
Source
npmnpm
Version published
Weekly downloads
4.1M
7%
Maintainers
3
Weekly downloads
 
Created
Source

@prisma/instrumentation

npm version PRs Welcome GitHub license Discord

OTEL - OpenTelemetry compliant instrumentation for Prisma Client.

⚠️ Warning: This package is provided as part of the tracing Preview Feature Its release cycle does not follow SemVer, which means we might release breaking changes (change APIs, remove functionality) without any prior warning.

Installing

$ npm install @prisma/instrumentation

Usage

import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { PrismaInstrumentation } from '@prisma/instrumentation'

registerInstrumentations({
  instrumentations: [new PrismaInstrumentation()],
})

Don't forget to set previewFeatures:

generator client {
  provider = "prisma-client-js"
}

Jaeger

Exporting traces to Jaeger Tracing.

import { context } from '@opentelemetry/api'
import { AsyncLocalStorageContextManager } from '@opentelemetry/context-async-hooks'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'
import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { Resource } from '@opentelemetry/resources'
import { BasicTracerProvider, SimpleSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { SEMRESATTRS_SERVICE_NAME, SEMRESATTRS_SERVICE_VERSION } from '@opentelemetry/semantic-conventions'
import { PrismaInstrumentation } from '@prisma/instrumentation'

import { PrismaClient } from '.prisma/client'

const contextManager = new AsyncLocalStorageContextManager().enable()

context.setGlobalContextManager(contextManager)

const otlpTraceExporter = new OTLPTraceExporter()

const provider = new BasicTracerProvider({
  resource: new Resource({
    [SEMRESATTRS_SERVICE_NAME]: 'test-tracing-service',
    [SEMRESATTRS_SERVICE_VERSION]: '1.0.0',
  }),
})

provider.addSpanProcessor(new SimpleSpanProcessor(otlpTraceExporter))
provider.register()

registerInstrumentations({
  instrumentations: [new PrismaInstrumentation()],
})

async function main() {
  const prisma = new PrismaClient()

  const email = `user.${Date.now()}@prisma.io`

  await prisma.user.create({
    data: {
      email: email,
    },
  })
}

main()

Keywords

prisma

FAQs

Package last updated on 15 Jul 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts