JSPM

serverless-plugin-tracing

1.0.6
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 41536
  • Score
    100M100P100Q156063F
  • License MIT

Enables AWS X-Ray for entire Serverless stack or individual functions

Package Exports

  • serverless-plugin-tracing

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-plugin-tracing) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

serverless-plugin-tracing

npm version CircleCI Coverage Status

Enables AWS X-Ray (https://aws.amazon.com/xray/) for the entire Serverless stack or individual functions.

Note: this plugin is currently Beta.

Note: tested to work well with serverless@1.13.2. Some older versions of serverless may not work due to outdated Javascript SDK that does not support TracingConfig.

npm install --save-dev serverless-plugin-tracing

Example serverless.yml:

service: my-great-service

provider:
  name: aws
  stage: test
  tracing: true # enable tracing
  iamRoleStatements:
    - Effect: "Allow" # xray permissions (required)
      Action:
        - "xray:PutTraceSegments"
        - "xray:PutTelemetryRecords"
      Resource:
        - "*"

plugins:
  - serverless-plugin-tracing

functions:
  mainFunction: # inherits tracing settings from "provider"
    handler: src/app/index.handler
  healthcheck:
    tracing: false # overrides provider settings (opt out)

Output after serverless deploy:

Serverless: Tracing ENABLED for function
  "my-great-service-test-mainFunction"
Serverless: Tracing DISABLED for function
  "my-great-service-test-healthcheck"

Important: in addition to using the plugin, you need to enable capturing traces in the code as well:

const awsXRay = require('aws-xray-sdk');
const awsSdk = awsXRay.captureAWS(require('aws-sdk'));

The plugin only controls the checkbox that be viewed in AWS Console: go to AWS Lambda -> select a Lambda function -> Configuration tab -> Advanced settings -> "Enable active tracing". If tracing ends up being true for a function, the checkbox will be checked for that function.