From a872c76b85bf2799e2c5ef68a689966876d2c902 Mon Sep 17 00:00:00 2001 From: Harminder Virk Date: Tue, 17 Sep 2024 14:09:02 +0530 Subject: [PATCH] refactor: rename remoteQuery to query and db instrumentation flag (#9159) --- packages/medusa/src/instrumentation/index.ts | 31 +++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/medusa/src/instrumentation/index.ts b/packages/medusa/src/instrumentation/index.ts index 2207cb91e2..6d7513d565 100644 --- a/packages/medusa/src/instrumentation/index.ts +++ b/packages/medusa/src/instrumentation/index.ts @@ -262,34 +262,37 @@ export function registerOtel(options: { exporter: SpanExporter instrument?: Partial<{ http: boolean - remoteQuery: boolean + query: boolean workflows: boolean + db: boolean }> instrumentations?: Instrumentation[] }) { - const sdk = new NodeSDK({ - serviceName: options.serviceName, - resource: new Resource({ - "service.name": options.serviceName, - }), - spanProcessor: new SimpleSpanProcessor(options.exporter), - instrumentations: [ - new PgInstrumentation(), - ...(options.instrumentations || []), - ], - }) - const instrument = options.instrument || {} + const instrumentations = options.instrumentations || [] + + if (instrument.db) { + instrumentations.push(new PgInstrumentation()) + } if (instrument.http) { instrumentHttpLayer() } - if (instrument.remoteQuery) { + if (instrument.query) { instrumentRemoteQuery() } if (instrument.workflows) { instrumentWorkflows() } + const sdk = new NodeSDK({ + serviceName: options.serviceName, + resource: new Resource({ + "service.name": options.serviceName, + }), + spanProcessor: new SimpleSpanProcessor(options.exporter), + instrumentations: instrumentations, + }) + sdk.start() return sdk }