Skip to content

Testing OpenTelemetry instrumentation for AWS SDK for JavaScript

License

Notifications You must be signed in to change notification settings

trivikr/aws-sdk-js-otel-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-sdk-js-otel-test

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.

Prerequisites

Complete the following tasks:

  • Install Node.js by following these steps:
    1. Install nvm.
    2. Use node v22.x.x by running nvm use or nvm use 22 in a terminal window.
    3. Verify that node is installed by running node -v in a terminal window and confirm that it shows the latest version of v22, such as v22.10.0).
  • Run npm install to install the dependencies.
  • 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.
  • 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
      
  • (Optional) Setup Jaeger Tracing: needs to be running on localhost port 16686.

Setup

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.

node --run instrument
$ node --run instrument
{
  resource: {
    attributes: {
      'service.name': 'test-aws-sdk',
      'telemetry.sdk.language': 'nodejs',
      'telemetry.sdk.name': 'opentelemetry',
      'telemetry.sdk.version': '1.26.0'
    }
  },
  instrumentationScope: {
    name: '@opentelemetry/instrumentation-aws-sdk',
    version: '0.44.0',
    schemaUrl: undefined
  },
  traceId: 'ff028d034969fc05c6e47ee1eaf2faca',
  parentId: undefined,
  traceState: undefined,
  name: 'DynamoDB.ListTables',
  id: 'ca2f4591b4b974d9',
  kind: 2,
  timestamp: 1729188000802000,
  duration: 116957.333,
  attributes: {
    'rpc.system': 'aws-api',
    'rpc.method': 'ListTables',
    'rpc.service': 'DynamoDB',
    'db.system': 'dynamodb',
    'db.operation': 'ListTables',
    'aws.region': 'us-west-2',
    'aws.request.id': 'NI9DR2PE921C79HS5U5QSOHM2VVV4KQNSO5AEMVJF66Q9ASUAAJG',
    'http.status_code': 200,
    'aws.dynamodb.table_count': 20
  },
  status: { code: 0 },
  events: [],
  links: []
}
Jaeger Span Screenshot

Jaeger Span for AWS SDK for JavaScript

For JS SDK v2, pleas refer to the v2 branch.

Screenshots

Jaeger Traces when operation is called multiple times

Jaeger Traces for AWS SDK for JavaScript

About

Testing OpenTelemetry instrumentation for AWS SDK for JavaScript

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published