From d7fe30d0b6c0afdd4ee3a9f2021ce83cb64b8f06 Mon Sep 17 00:00:00 2001 From: David Luna Date: Fri, 26 Apr 2024 14:16:59 +0200 Subject: [PATCH] fix(instr-knex): set correct SpanKind for traces --- .../opentelemetry-instrumentation-knex/src/instrumentation.ts | 1 + .../node/opentelemetry-instrumentation-knex/test/index.test.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts index ce45403efc..40577aa886 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/src/instrumentation.ts @@ -160,6 +160,7 @@ export class KnexInstrumentation extends InstrumentationBase { const span = instrumentation.tracer.startSpan( utils.getName(name, operation, table), { + kind: api.SpanKind.CLIENT, attributes, }, parent diff --git a/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts b/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts index 1f660cf273..9072465c47 100644 --- a/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts +++ b/plugins/node/opentelemetry-instrumentation-knex/test/index.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { context, trace } from '@opentelemetry/api'; +import { SpanKind, context, trace } from '@opentelemetry/api'; import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { @@ -471,6 +471,7 @@ const assertSpans = (actualSpans: any[], expectedSpans: any[]) => { try { assert.notStrictEqual(span, undefined); assert.notStrictEqual(expected, undefined); + assert.strictEqual(span.kind, SpanKind.CLIENT); assertMatch(span.name, new RegExp(expected.op)); assertMatch(span.name, new RegExp(':memory:')); assert.strictEqual(span.attributes['db.system'], 'sqlite');