Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The instrumentations are collecting the following attributes:
| `rpc.system` | string | Always equals "aws-api" | |
| `rpc.method` | string | he name of the operation corresponding to the request, as returned by the AWS SDK. If the SDK does not provide a way to retrieve a name, the name of the command SHOULD be used, removing the suffix `Command` if present, resulting in a PascalCase name with no spaces. | `PutObject` |
| `rpc.service` | string | The name of the service to which a request is made, as returned by the AWS SDK. If the SDK does not provide a away to retrieve a name, the name of the SDK's client interface for a service SHOULD be used, removing the suffix `Client` if present, resulting in a PascalCase name with no spaces. | `S3`, `DynamoDB`, `Route53` |
| `aws.region` | string | Region name for the request | "eu-west-1" |
| `cloud.region` | string | Region name for the request | "eu-west-1" |

### Custom User Attributes

Expand Down Expand Up @@ -112,6 +112,7 @@ Attributes collected:
| `rpc.method` | The name of the (logical) method being called. | |
| `rpc.service` | The full (logical) name of the service being called. | |
| `rpc.system` | A string identifying the remoting system. | |
| `cloud.region` | The AWS Region where the requested service is being accessed. | |
| `aws.dynamodb.attribute_definitions` | The JSON-serialized value of each item in the `AttributeDefinitions` request field. | dynamodb |
| `aws.dynamodb.consistent_read` | The value of the `ConsistentRead` request parameter. | dynamodb |
| `aws.dynamodb.consumed_capacity` | The JSON-serialized value of each item in the `ConsumedCapacity` response field. | dynamodb |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export class AwsInstrumentation extends InstrumentationBase<AwsSdkInstrumentatio
Promise.resolve(regionPromise)
.then(resolvedRegion => {
normalizedRequest.region = resolvedRegion;
span.setAttribute(AttributeNames.AWS_REGION, resolvedRegion);
span.setAttribute(AttributeNames.CLOUD_REGION, resolvedRegion);
})
.catch(e => {
// there is nothing much we can do in this case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
export enum AttributeNames {
AWS_OPERATION = 'aws.operation',
AWS_REGION = 'aws.region',
CLOUD_REGION = 'cloud.region',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud.region does have a constant in @opentelemetry/semantic-conventions. However, we can defer using that constant (and the others in this instrumentation) to #2377

The current constant using the old, deprecated naming (SEMRESATTRS_CLOUD_REGION) is/was intended for use as a Resource attribute. That was before open-telemetry/semantic-conventions#2238 expanded the use of cloud.region beyond resource attributes. That's why I'm not suggesting this PR use SEMRESATTRS_CLOUD_REGION.

AWS_SERVICE_API = 'aws.service.api',
AWS_SERVICE_NAME = 'aws.service.name',
AWS_SERVICE_IDENTIFIER = 'aws.service.identifier',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const extractAttributesFromNormalizedRequest = (
[SEMATTRS_RPC_SYSTEM]: 'aws-api',
[SEMATTRS_RPC_METHOD]: normalizedRequest.commandName,
[SEMATTRS_RPC_SERVICE]: normalizedRequest.serviceName,
[AttributeNames.AWS_REGION]: normalizedRequest.region,
[AttributeNames.CLOUD_REGION]: normalizedRequest.region,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('instrumentation-aws-sdk-v3 (client-s3)', () => {
expect(span.attributes[AttributeNames.AWS_S3_BUCKET]).toEqual(
'ot-demo-test'
);
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);
expect(span.name).toEqual('S3.PutObject');
expect(span.kind).toEqual(SpanKind.CLIENT);
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
Expand All @@ -100,7 +100,7 @@ describe('instrumentation-aws-sdk-v3 (client-s3)', () => {
expect(span.attributes[AttributeNames.AWS_S3_BUCKET]).toEqual(
'ot-demo-test'
);
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);
expect(span.name).toEqual('S3.PutObject');
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
done();
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('instrumentation-aws-sdk-v3 (client-s3)', () => {
expect(span.attributes[AttributeNames.AWS_S3_BUCKET]).toEqual(
'ot-demo-test'
);
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);
expect(span.name).toEqual('S3.PutObject');
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
});
Expand Down Expand Up @@ -166,7 +166,7 @@ describe('instrumentation-aws-sdk-v3 (client-s3)', () => {
'invalid-bucket-name'
);
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(403);
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.AWS_REQUEST_ID]).toEqual(
'MS95GTS7KXQ34X2S'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('instrumentation-aws-sdk-v3 (client-sqs)', () => {
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual('SendMessage');
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);

// custom messaging attributes
expect(span.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual('aws.sqs');
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('instrumentation-aws-sdk-v3 (client-sqs)', () => {
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual('SendMessageBatch');
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);

// messaging semantic attributes
expect(span.attributes[SEMATTRS_MESSAGING_SYSTEM]).toEqual('aws.sqs');
Expand Down Expand Up @@ -183,7 +183,7 @@ describe('instrumentation-aws-sdk-v3 (client-sqs)', () => {
expect(span.attributes[SEMATTRS_RPC_SYSTEM]).toEqual('aws-api');
expect(span.attributes[SEMATTRS_RPC_METHOD]).toEqual('ReceiveMessage');
expect(span.attributes[SEMATTRS_RPC_SERVICE]).toEqual('SQS');
expect(span.attributes[AttributeNames.AWS_REGION]).toEqual(region);
expect(span.attributes[AttributeNames.CLOUD_REGION]).toEqual(region);
expect(span.attributes[SEMATTRS_HTTP_STATUS_CODE]).toEqual(200);
done();
});
Expand Down