Adding XRAY Tracing to non-rest functions

I have functions that aren’t attached to an API Gateway Endpoint, such as:

  • Cognito Triggers
  • S3 Event
  • DynamoDB Stream
  • SQS Events

I am also using XRAY tracing, which I have set as tracing: true in my serverless.yml file. It seems that these functions are not being traced, the debug message I receive is:

Ignoring flush on subsegment 20dcd559aa2ab487. Associated segment is marked as not sampled.

Is there any way to have these functions added, either via serverless or cloudformation?

Thanks in advance.

Is there any potential fixes for this?

I asked on StackOverflow with not too much of a solution, although the information was helpful.