Skip to content

Latest commit

 

History

History
110 lines (90 loc) · 3.67 KB

README.md

File metadata and controls

110 lines (90 loc) · 3.67 KB

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.28.0'
    }
  },
  instrumentationScope: {
    name: '@opentelemetry/instrumentation-aws-sdk',
    version: '0.47.0',
    schemaUrl: undefined
  },
  traceId: '5393756927067c7b6ca6dc30439c0c10',
  parentId: undefined,
  traceState: undefined,
  name: 'DynamoDB.ListTables',
  id: 'ae24760f494e5931',
  kind: 2,
  timestamp: 1731951374039000,
  duration: 129575.75,
  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': 'CQPLDQLNFP5AT4GGOMD199FC37VV4KQNSO5AEMVJF66Q9ASUAAJG',
    'http.status_code': 200,
    'aws.dynamodb.table_count': 16
  },
  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