This sample shows how to use @opentelemetry/instrumentation-aws-sdk to instrument listTables call on DynamoDB client in AWS SDK for JavaScript.
The example exports spans data to Console
. You can also export it to Jaeger
by setting JAEGER_ENABLED
environment variable.
Complete the following tasks:
- Install Node.js by following these steps:
- Install nvm.
- Use node v16.x.x by running
nvm use
ornvm use 16
in a terminal window. - Verify that node is installed by running
node -v
in a terminal window and confirm that it shows the latest version ofv16
, such asv16.15.0
).
- Enable corepack by running
corepack enable
. - Install dependencies by running
yarn
. - If you don't have an AWS account, create one.
- If you're an Amazon employee, see the internal wiki for creating an AWS account.
- Install the AWS CLI.
- Verify that the AWS CLI is installed by running
aws
in a terminal window.
- Verify that the AWS CLI is installed by running
- Set up AWS Shared Credential File.
- Your
~/.aws/credentials
(%UserProfile%\.aws\credentials
on Windows) should look like the following:[default] aws_access_key_id = <ACCESS_KEY> aws_secret_access_key = <SECRET_ACCESS_KEY>
- Your
~/.aws/config
(%UserProfile%\.aws\config
on Windows) should look like the following:[default] region = us-west-2
- Your
- (Optional) Setup Jaeger Tracing: needs to be running on
localhost
port16686
.
The test code from this package uses AwsInstrumentation
from @opentelemetry/instrumentation-aws-sdk
to instrument listTables call on DynamoDB client.
Refer to the npm package for custom instrumentation options which can be passed.
yarn instrument:v2
$ yarn instrument:v2
{
traceId: '5cdc3ef6df6feafd083ee31780eaf2af',
parentId: undefined,
name: 'DynamoDB.ListTables',
id: 'daebdb25fd06eebd',
kind: 2,
timestamp: 1652398876357628,
duration: 165648,
attributes: {
'aws.operation': 'listTables',
'aws.signature.version': 'v4',
'aws.service.api': 'DynamoDB',
'aws.service.identifier': 'dynamodb',
'aws.service.name': 'DynamoDB',
'rpc.system': 'aws-api',
'rpc.method': 'ListTables',
'rpc.service': 'DynamoDB',
'aws.region': 'us-west-2',
'db.system': 'dynamodb',
'db.operation': 'ListTables',
'db.statement': '{}',
'aws.request.id': 'M76TSMKB4MKBEAPTS5SAG2552FVV4KQNSO5AEMVJF66Q9ASUAAJG',
'http.status_code': 200
},
status: { code: 0 },
events: [],
links: []
}
yarn instrument:v3
$ yarn instrument:v3
{
traceId: '8667843daae9aa29ee07d5853d234ef3',
parentId: undefined,
name: 'DynamoDB.ListTables',
id: 'a0de3f91383e0d71',
kind: 2,
timestamp: 1652398963098096,
duration: 166117,
attributes: {
'rpc.system': 'aws-api',
'rpc.method': 'ListTables',
'rpc.service': 'DynamoDB',
'db.system': 'dynamodb',
'db.operation': 'ListTables',
'db.statement': '{}',
'aws.region': 'us-west-2',
'aws.request.id': 'S7HO96KJSTPJVCCCA6UMB1DU13VV4KQNSO5AEMVJF66Q9ASUAAJG',
'http.status_code': 200
},
status: { code: 0 },
events: [],
links: []
}