From 7b1fca8b4bfceca1c37f8ef0d68fe5078777b9bc Mon Sep 17 00:00:00 2001 From: haddasb Date: Thu, 15 Sep 2022 16:20:34 +0300 Subject: [PATCH 1/3] fix(aws-sdk): set soanKind to CLIENT by default --- .../node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts index d32cfad4b7..ff119f449c 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/src/aws-sdk.ts @@ -213,7 +213,7 @@ export class AwsInstrumentation extends InstrumentationBase { metadata.spanName ?? `${normalizedRequest.serviceName}.${normalizedRequest.commandName}`; const newSpan = this.tracer.startSpan(name, { - kind: metadata.spanKind, + kind: metadata.spanKind ?? SpanKind.CLIENT, attributes: { ...extractAttributesFromNormalizedRequest(normalizedRequest), ...metadata.spanAttributes, From c7144ee08ade1753af8bb45e5c00c55276688201 Mon Sep 17 00:00:00 2001 From: haddasb Date: Thu, 15 Sep 2022 16:52:39 +0300 Subject: [PATCH 2/3] fix(aws-sdk): assert in v2 and v3 test the spanKind is CLIENT --- .../test/aws-sdk-v2.test.ts | 4 ++-- .../test/aws-sdk-v3.test.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts index d8c2fd09be..3b6ab5a169 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts @@ -28,7 +28,7 @@ const instrumentation = registerInstrumentationTesting( import * as AWS from 'aws-sdk'; import { ReadableSpan } from '@opentelemetry/sdk-trace-base'; -import { SpanStatusCode, Span } from '@opentelemetry/api'; +import { SpanStatusCode, Span, SpanKind } from '@opentelemetry/api'; import { AttributeNames } from '../src/enums'; import { mockV2AwsSend } from './testing-utils'; import * as expect from 'expect'; @@ -123,7 +123,7 @@ describe('instrumentation-aws-sdk-v2', () => { ).toBe(200); expect(spanCreateBucket.name).toBe('S3.CreateBucket'); - + expect(spanCreateBucket.kind).toEqual(SpanKind.CLIENT) expect(spanPutObject.attributes[AttributeNames.AWS_OPERATION]).toBe( 'putObject' ); diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts index f1539905b7..e3ccd9ebbb 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts @@ -32,6 +32,7 @@ import { S3Client, } from '@aws-sdk/client-s3'; import { SQS } from '@aws-sdk/client-sqs'; +import { SpanKind } from '@opentelemetry/api'; // set aws environment variables, so tests in non aws environment are able to run process.env.AWS_ACCESS_KEY_ID = 'testing'; @@ -78,6 +79,7 @@ describe('instrumentation-aws-sdk-v3', () => { expect(span.attributes[SemanticAttributes.RPC_SERVICE]).toEqual('S3'); expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region); expect(span.name).toEqual('S3.PutObject'); + expect(span.kind).toEqual(SpanKind.CLIENT) expect(span.attributes[SemanticAttributes.HTTP_STATUS_CODE]).toEqual(200); }); From 9f694e2d547803a26c648f8cdab3d08979fdd4d4 Mon Sep 17 00:00:00 2001 From: haddasb Date: Sun, 18 Sep 2022 09:11:53 +0300 Subject: [PATCH 3/3] fix(aws-sdk): lint --- .../test/aws-sdk-v2.test.ts | 2 +- .../test/aws-sdk-v3.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts index 3b6ab5a169..f40f80903b 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v2.test.ts @@ -123,7 +123,7 @@ describe('instrumentation-aws-sdk-v2', () => { ).toBe(200); expect(spanCreateBucket.name).toBe('S3.CreateBucket'); - expect(spanCreateBucket.kind).toEqual(SpanKind.CLIENT) + expect(spanCreateBucket.kind).toEqual(SpanKind.CLIENT); expect(spanPutObject.attributes[AttributeNames.AWS_OPERATION]).toBe( 'putObject' ); diff --git a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts index e3ccd9ebbb..8623b6e873 100644 --- a/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts +++ b/plugins/node/opentelemetry-instrumentation-aws-sdk/test/aws-sdk-v3.test.ts @@ -79,7 +79,7 @@ describe('instrumentation-aws-sdk-v3', () => { expect(span.attributes[SemanticAttributes.RPC_SERVICE]).toEqual('S3'); expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region); expect(span.name).toEqual('S3.PutObject'); - expect(span.kind).toEqual(SpanKind.CLIENT) + expect(span.kind).toEqual(SpanKind.CLIENT); expect(span.attributes[SemanticAttributes.HTTP_STATUS_CODE]).toEqual(200); });