
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
@prisma/instrumentation-contract
Advanced tools
This package provides the contract types and utilities for Prisma's instrumentation system. It defines the TracingHelper interface and provides functions to access the global tracing helper.
Note: This is an internal package with no API stability guarantees primarily intended for Prisma's own packages. However, it may be useful for third-party observability vendors whose solutions are not built on OpenTelemetry and who want to integrate with Prisma's tracing system.
npm install @prisma/instrumentation-contract
If you're building an observability integration that needs to read tracing information from Prisma:
import { getGlobalTracingHelper } from '@prisma/instrumentation-contract'
const helper = getGlobalTracingHelper()
if (helper && helper.isEnabled()) {
const traceParent = helper.getTraceParent()
// Use traceParent for correlation
}
If you're building a custom instrumentation solution (not based on OpenTelemetry), you can implement the TracingHelper interface and register it globally:
import { setGlobalTracingHelper, clearGlobalTracingHelper, type TracingHelper } from '@prisma/instrumentation-contract'
const myTracingHelper: TracingHelper = {
isEnabled() {
return true
},
getTraceParent(context) {
// Return W3C Trace Context traceparent header
return '00-traceId-spanId-01'
},
dispatchEngineSpans(spans) {
// Handle emulated remote spans. In Prisma 7, this is only used for Accelerate spans.
},
getActiveContext() {
// Return the active context, if any
return undefined
},
runInChildSpan(nameOrOptions, callback) {
// Execute callback within a child span
return callback()
},
}
// Register your tracing helper
setGlobalTracingHelper(myTracingHelper)
// Later, when shutting down
clearGlobalTracingHelper()
getGlobalTracingHelper(): TracingHelper | undefinedReturns the currently registered global tracing helper, or undefined if none is set.
setGlobalTracingHelper(helper: TracingHelper): voidRegisters a tracing helper globally. This is typically called by instrumentation packages when they are enabled.
clearGlobalTracingHelper(): voidClears the global tracing helper. This is typically called when instrumentation is disabled.
TracingHelperThe main interface for tracing integration:
interface TracingHelper {
isEnabled(): boolean
getTraceParent(context?: Context): string
dispatchEngineSpans(spans: EngineSpan[]): void
getActiveContext(): Context | undefined
runInChildSpan<R>(nameOrOptions: string | ExtendedSpanOptions, callback: SpanCallback<R>): R
}
See the TypeScript definitions for additional types like EngineSpan, ExtendedSpanOptions, and SpanCallback.
If you're using OpenTelemetry, you should use @prisma/instrumentation instead. It provides a complete OpenTelemetry-based instrumentation that automatically registers the appropriate tracing helper.
import { PrismaInstrumentation, registerInstrumentations } from '@prisma/instrumentation'
registerInstrumentations({
instrumentations: [new PrismaInstrumentation()],
})
FAQs
Shared types and utilities for Prisma instrumentation
The npm package @prisma/instrumentation-contract receives a total of 625 weekly downloads. As such, @prisma/instrumentation-contract popularity was classified as not popular.
We found that @prisma/instrumentation-contract demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?

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.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.