Serverless framework - Enabling X-Ray in serverless.yml
Asked Answered
I

3

11

Is there a way to enable X-Ray from the serverless.yml for Lambda functions? I've added the X-Ray permissions in the file:

  iamRoleStatements:
    - Effect: "Allow"
      Resource: "*"
      Action:
        - "xray:*"

But Advanced Tracing still needs to be manually enabled in the AWS console.

Inquisition answered 24/10, 2017 at 14:2 Comment(0)
A
3

It's in development. If you're unwilling to wait until the official functionality is released, you can install the plugin until it's ready.

Afflux answered 24/10, 2017 at 22:40 Comment(3)
this plugin hasn't been updated for a year and still in beta mode. Does serverless framework support AWS XRay tracing now or this plugin is the only option?Renunciation
it's already released, check serverless AWS document here serverless.com/framework/docs/providers/aws/guide/…Reiss
This answer is out of date - don't use the plugin. Do what @ulad-kasach says.Clever
I
13

See the serverless documentation:

https://serverless.com/framework/docs/providers/aws/guide/functions/#aws-x-ray-tracing

service: myService

provider:
  name: aws
  runtime: nodejs8.10
  tracing:
    lambda: true

See also tracing for api gateway: https://serverless.com/framework/docs/providers/aws/events/apigateway/#aws-x-ray-tracing

# serverless.yml

provider:
  name: aws
  tracing:
    apiGateway: true
Imamate answered 14/5, 2019 at 11:31 Comment(1)
Does the apiGateway option only work if the API gateway is created by the serverless framework? I am trying this and the lambda option works ok, but the API gateway option doesnt work, I build my api gateway with terraform. My stage is created by serverless, so I figured it would work.Willms
A
3

It's in development. If you're unwilling to wait until the official functionality is released, you can install the plugin until it's ready.

Afflux answered 24/10, 2017 at 22:40 Comment(3)
this plugin hasn't been updated for a year and still in beta mode. Does serverless framework support AWS XRay tracing now or this plugin is the only option?Renunciation
it's already released, check serverless AWS document here serverless.com/framework/docs/providers/aws/guide/…Reiss
This answer is out of date - don't use the plugin. Do what @ulad-kasach says.Clever
E
0

It is also worth noting that currently X-Ray support is dependent on which type of Aws API is selected. If you chose REST (which by your syntax you did ) X-Ray is supported BUT if someone chooses HTTP it is NOT supported. For reference see https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-vs-rest.html#http-api-vs-rest.differences.monitoring

Emileeemili answered 5/6, 2023 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.