Skip to content

Commit aa35416

Browse files
authored
chore(client): remove tracing preview feature usage (#25865)
Closes: prisma/team-orm#1279
1 parent fdb69a2 commit aa35416

File tree

12 files changed

+26
-38
lines changed

12 files changed

+26
-38
lines changed

packages/client/src/runtime/core/engines/common/types/QueryEngine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export type QueryEngineConfig = {
4848
datasourceOverrides: Record<string, string>
4949
env: Record<string, string | undefined>
5050
logLevel: QueryEngineLogLevel
51-
telemetry?: QueryEngineTelemetry
5251
engineProtocol: EngineProtocol
52+
enableTracing: boolean
5353
}
5454

5555
export type QueryEngineTelemetry = {

packages/client/src/runtime/core/engines/library/LibraryEngine.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Debug from '@prisma/debug'
22
import { ErrorRecord } from '@prisma/driver-adapter-utils'
33
import type { BinaryTarget } from '@prisma/get-platform'
44
import { assertNodeAPISupported, binaryTargets, getBinaryTargetForCurrentPlatform } from '@prisma/get-platform'
5-
import { assertAlways, EngineTrace } from '@prisma/internals'
5+
import { assertAlways, EngineTrace, TracingHelper } from '@prisma/internals'
66
import { bold, green, red } from 'kleur/colors'
77

88
import { PrismaClientInitializationError } from '../../errors/PrismaClientInitializationError'
@@ -81,6 +81,7 @@ export class LibraryEngine implements Engine<undefined> {
8181
logLevel: QueryEngineLogLevel
8282
lastQuery?: string
8383
loggerRustPanic?: any
84+
tracingHelper: TracingHelper
8485

8586
versionInfo?: {
8687
commit: string
@@ -109,6 +110,7 @@ export class LibraryEngine implements Engine<undefined> {
109110
this.logLevel = config.logLevel ?? 'error'
110111
this.logEmitter = config.logEmitter
111112
this.datamodel = config.inlineSchema
113+
this.tracingHelper = config.tracingHelper
112114

113115
if (config.enableDebugLogs) {
114116
this.logLevel = 'debug'
@@ -147,11 +149,11 @@ export class LibraryEngine implements Engine<undefined> {
147149
try {
148150
return await fn(...args, requestId)
149151
} finally {
150-
if (this.config.tracingHelper.isEnabled()) {
152+
if (this.tracingHelper.isEnabled()) {
151153
const traceJson = await this.engine?.trace(requestId)
152154
if (traceJson) {
153155
const trace = JSON.parse(traceJson) as EngineTrace
154-
this.config.tracingHelper.dispatchEngineSpans(trace.spans)
156+
this.tracingHelper.dispatchEngineSpans(trace.spans)
155157
}
156158
}
157159
}
@@ -231,15 +233,15 @@ export class LibraryEngine implements Engine<undefined> {
231233

232234
this.binaryTarget = await this.getCurrentBinaryTarget()
233235

234-
await this.config.tracingHelper.runInChildSpan('load_engine', () => this.loadEngine())
236+
await this.tracingHelper.runInChildSpan('load_engine', () => this.loadEngine())
235237

236238
this.version()
237239
}
238240

239241
private async getCurrentBinaryTarget() {
240242
if (TARGET_BUILD_TYPE === 'library') {
241243
if (this.binaryTarget) return this.binaryTarget
242-
const binaryTarget = await this.config.tracingHelper.runInChildSpan('detect_platform', () =>
244+
const binaryTarget = await this.tracingHelper.runInChildSpan('detect_platform', () =>
243245
getBinaryTargetForCurrentPlatform(),
244246
)
245247
if (!knownBinaryTargets.includes(binaryTarget)) {
@@ -306,6 +308,7 @@ You may have to run ${green('prisma generate')} for your changes to take effect.
306308
logLevel: this.logLevel,
307309
configDir: this.config.cwd,
308310
engineProtocol: 'json',
311+
enableTracing: this.tracingHelper.isEnabled(),
309312
},
310313
(log) => {
311314
weakThis.deref()?.logger(log)
@@ -399,7 +402,7 @@ You may have to run ${green('prisma generate')} for your changes to take effect.
399402

400403
try {
401404
const headers = {
402-
traceparent: this.config.tracingHelper.getTraceParent(),
405+
traceparent: this.tracingHelper.getTraceParent(),
403406
}
404407

405408
await this.engine?.connect(JSON.stringify(headers))
@@ -422,7 +425,7 @@ You may have to run ${green('prisma generate')} for your changes to take effect.
422425
}
423426
}
424427

425-
this.libraryStartingPromise = this.config.tracingHelper.runInChildSpan('connect', startFn)
428+
this.libraryStartingPromise = this.tracingHelper.runInChildSpan('connect', startFn)
426429

427430
return this.libraryStartingPromise
428431
}
@@ -446,7 +449,7 @@ You may have to run ${green('prisma generate')} for your changes to take effect.
446449
debug('library stopping')
447450

448451
const headers = {
449-
traceparent: this.config.tracingHelper.getTraceParent(),
452+
traceparent: this.tracingHelper.getTraceParent(),
450453
}
451454

452455
await this.engine?.disconnect(JSON.stringify(headers))
@@ -457,7 +460,7 @@ You may have to run ${green('prisma generate')} for your changes to take effect.
457460
debug('library stopped')
458461
}
459462

460-
this.libraryStoppingPromise = this.config.tracingHelper.runInChildSpan('disconnect', stopFn)
463+
this.libraryStoppingPromise = this.tracingHelper.runInChildSpan('disconnect', stopFn)
461464

462465
return this.libraryStoppingPromise
463466
}

packages/client/src/runtime/core/engines/library/ReactNativeLibraryLoader.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type PrismaCreateOptions = {
1212
ignoreEnvVarErrors: boolean
1313
datasourceOverrides: object | string
1414
env: object | string
15+
enableTracing: boolean
1516
}
1617

1718
type QueryEngineObject = object
@@ -46,6 +47,7 @@ class ReactNativeQueryEngine implements QueryEngineInstance {
4647
logLevel: config.logLevel,
4748
logQueries: config.logQueries ?? false,
4849
logCallback: logger,
50+
enableTracing: config.enableTracing,
4951
})
5052
}
5153

packages/client/src/runtime/core/tracing/TracingHelper.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,6 @@ class DynamicTracingHelper implements TracingHelper {
5252
}
5353
}
5454

55-
export function getTracingHelper(previewFeatures: string[]): TracingHelper {
56-
if (!previewFeatures.includes('tracing')) {
57-
// no preview feature - tracing is disabled and can never be enabled
58-
return disabledTracingHelper
59-
}
60-
// preview feature is enabled - tracing is enabled if PRISMA_INSTRUMENTATION global is set
55+
export function getTracingHelper(): TracingHelper {
6156
return new DynamicTracingHelper()
6257
}

packages/client/src/runtime/core/tracing/getTraceParent.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getTracingHelper } from './TracingHelper'
22

33
it('should return 00 traceparent when tracing is disabled', () => {
4-
const helper = getTracingHelper([])
4+
const helper = getTracingHelper()
55

66
const result = helper.getTraceParent()
77

packages/client/src/runtime/getPrismaClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ export function getPrismaClient(config: GetPrismaClientConfig) {
358358
this._clientVersion = config.clientVersion ?? clientVersion
359359
this._activeProvider = config.activeProvider
360360
this._globalOmit = optionsArg?.omit
361-
this._tracingHelper = getTracingHelper(this._previewFeatures)
361+
this._tracingHelper = getTracingHelper()
362362
const envPaths = {
363363
rootEnvPath:
364364
config.relativeEnvPaths.rootEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.rootEnvPath),

packages/client/tests/functional/_example/_matrix.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default defineMatrix(() => [
3636
],
3737
[
3838
{
39-
previewFeatures: '"tracing"',
39+
previewFeatures: '"relationJoins"',
4040
},
4141
{
4242
previewFeatures: '"referentialIntegrity"',
@@ -52,13 +52,13 @@ export default defineMatrix(() => [
5252
'provider': 'sqlite',
5353
'id': 'Int @id @default(autoincrement())',
5454
'randomString': 'foo',
55-
'previewFeatures': '"tracing"',
55+
'previewFeatures': '"relationJoins"',
5656
},
5757
{
5858
'provider': 'mongodb',
5959
'id': 'String @id @default(auto()) @map("_id") @db.ObjectId',
6060
'randomString': '"book", ',
61-
'previewFeatures': '"tracing"',
61+
'previewFeatures': '"relationJoins"',
6262
},
6363
{
6464
'provider': 'sqlite',

packages/client/tests/functional/_example/tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ testMatrix.setupTestSuite(
2121
provider: Providers.SQLITE
2222
id: 'Int @id @default(autoincrement())',
2323
randomString: 'foo',
24-
previewFeatures: '"tracing"'
24+
previewFeatures: '"relationJoins"'
2525
}
2626
*/
2727

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
import { defineMatrix } from '../_utils/defineMatrix'
22
import { allProviders } from '../_utils/providers'
33

4-
export default defineMatrix(() => [
5-
allProviders,
6-
[
7-
{
8-
previewFeatures: '"tracing"',
9-
},
10-
{
11-
previewFeatures: '',
12-
},
13-
],
14-
])
4+
export default defineMatrix(() => [allProviders])

packages/client/tests/functional/tracing/prisma/_schema.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export default testMatrix.setupSchema(({ provider }) => {
55
return /* Prisma */ `
66
generator client {
77
provider = "prisma-client-js"
8-
previewFeatures = ["tracing"]
98
}
109
1110
datasource db {

0 commit comments

Comments
 (0)