From 0b96a627f35c87c56a9e6b80d446b1efd6a5cd3e Mon Sep 17 00:00:00 2001 From: haddasb Date: Tue, 6 Dec 2022 17:42:32 +0200 Subject: [PATCH] chore(mongo): add condition in case cmd=unknown --- .../src/instrumentation.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts index 5b46a2feb0..0d3d6079dd 100644 --- a/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-mongodb/src/instrumentation.ts @@ -256,7 +256,13 @@ export class MongoDBInstrumentation extends InstrumentationBase { const span = instrumentation.tracer.startSpan(`mongodb.${type}`, { kind: SpanKind.CLIENT, }); - instrumentation._populateV3Attributes(span, ns, server, cmd, type); + instrumentation._populateV3Attributes( + span, + ns, + server, + cmd, + commandType === MongodbCommandType.UNKNOWN ? undefined : commandType + ); const patchedCallback = instrumentation._patchEnd(span, resultHandler); // handle when options is the callback to send the correct number of args if (typeof options === 'function') { @@ -521,7 +527,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { ns: string, topology: MongoInternalTopology, command?: MongoInternalCommand, - operation?: string + operation?: string | undefined ) { // add network attributes to determine the remote server let host: undefined | string; @@ -565,7 +571,7 @@ export class MongoDBInstrumentation extends InstrumentationBase { host?: undefined | string, port?: undefined | string, commandObj?: any, - operation?: string + operation?: string | undefined ) { // add database related attributes span.setAttributes({