To analyse and debug your serverless application AWS X-Ray comes in very handy. It is a distributed tracing tool, that measures how long it takes your application to complete certain tasks. E.g. fetching data from a database system.
X-Ray can also visualize the connection between the components of your application and can therefor help you reason about it while it grows and get more complex.
To enable this functionality within your serverless application, we want to use the tracing plugin.
To instrument your code to send data to X-Ray we use the aws-sdk-go.
To complete this lab you have to:
The tracing data is stored in
telemetryRecords in X-Ray. In order for
the function to be able to store this data, we need to provide
it with the corresponding IAM permission.
provider: name: aws tracing: true # enable tracing iamRoleStatements: - Effect: "Allow" Action: - "xray:PutTraceSegments" - "xray:PutTelemetryRecords" Resource: - "*"
The serverless.com framework comes with a wide variety of plugins. Plugins are node modules that need to be installed and activated in order to be available.
npm install --save-dev serverless-plugin-tracing
plugins: - serverless-plugin-tracing