Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(aws-sdk): set spanKind to CLIENT by default in v3 #1177

Merged
merged 10 commits into from
Sep 21, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class AwsInstrumentation extends InstrumentationBase<any> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});

Expand Down