Skip to content
Enables AWS X-Ray tracing for Serverless
Branch: master
Clone or download
alex-murashkin Merge pull request #17 from joeyvandijk/patch-1
Healthcheck value is unnecessary
Latest commit 9b86435 Feb 20, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
test Tracing set via CloudFormation Oct 13, 2017
.eslintrc Initial release May 16, 2017
.gitignore Initial commit May 16, 2017
.npmignore Initial release May 16, 2017
LICENSE healthcheck was a function Feb 16, 2018
index.js Tracing set via CloudFormation Oct 13, 2017
package.json Tracing set via CloudFormation Oct 13, 2017


npm version CircleCI Coverage Status

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

Update: as of 2.0.0, the plugin uses Cloud Formation to update TracingConfig and no longer makes additional AWS SDK calls. No change to YAML contract: stays same as in 1.x. Tested with serverless@1.22.0.

Note: this plugin is currently Beta.

Note: 1.x was 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

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

  - serverless-plugin-tracing

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

Output after serverless deploy:

Serverless: Tracing ENABLED for function
Serverless: Tracing DISABLED for function

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.

You can’t perform that action at this time.