Enables AWS X-Ray (https://aws.amazon.com/xray/) for the entire Serverless stack or individual functions.
Update: as of
2.0.0, plugin uses Cloud Formation to update
TracingConfig and no longer
makes additional AWS SDK calls. No cange to YAML contract: stays same as in 1.x
Note: this plugin is currently Beta.
Note: 1.x was tested to work well with
firstname.lastname@example.org. Some older versions of
does not support
npm install --save-dev serverless-plugin-tracing
service: my-great-serviceprovider:name: awsstage: testtracing: true # enable tracingiamRoleStatements:- Effect: "Allow" # xray permissions (required)Action:- "xray:PutTraceSegments"- "xray:PutTelemetryRecords"Resource:- "*"plugins:- serverless-plugin-tracingfunctions:mainFunction: # inherits tracing settings from "provider"handler: src/app/index.handlerhealthcheck:tracing: false # overrides provider settings (opt out)
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 = ;const awsSdk = awsXRay;
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.