To use the plugin, you need to download and install it, and then register it with your tracer.

See Lightstep’s GitHub for a full example.

Download and Install the Plugin

The packages are available from npm.

From a shell, run the following.

1
$ npm install --save opentelemetry-plugin-aws-sdk --save

Initialize the Plugin

In your service’s OpenTelemetry initialization code, use registerInstrumentation() to load plugins. See the Demo app for a full example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const {
  lightstep, opentelemetry,
} = require('lightstep-opentelemetry-launcher-node');

const { AwsInstrumentation } = require('opentelemetry-instrumentation-aws-sdk');

module.exports = async (serviceName) => {
  const sdk = lightstep.configureOpenTelemetry({
    accessToken: process.env.LS_ACCESS_TOKEN,
    serviceName,
    instrumentations: [
      new AwsInstrumentation({
        suppressInternalInstrumentation: true,
        preRequestHook: (span, request) => {
          if (span.attributes['aws.service.api'] === 'S3') {
            span.setAttribute('s3.bucket.name', request.params.Bucket);
          }
        },
      }),
    ]
};

In the next step, you’ll see the trace data generated by the new instrumentation.


What Did We Learn?

  • The OpenTelemetry AWS plugin automatically instruments your code to send and display AWS data in Lightstep.