AWS Xray NodeJS: How to Fix "Missing AWS Lambda trace data for X-Ray" messages on startup

Viewed 1091

We have several NodeJS Lambdas with AWS X-Ray with the following general setup.

process.env.AWS_XRAY_DEBUG_MODE = 'TRUE'
process.env.AWS_XRAY_TRACING_NAME = 'api-extensions'
console.log('Enabled XRAY debug mode')

import AWSXRay from 'aws-xray-sdk-core'
import { inputHandler } from './lib/handler'
import Sentry from './lib/sentry'

if (process.env.AWS_XRAY_ENABLED) {
  AWSXRay.captureHTTPsGlobal(require('http'), true)
  AWSXRay.captureHTTPsGlobal(require('https'), true)
  AWSXRay.capturePromise() <----- causes the startup messages
}

export const handler = Sentry.wrapHandler(inputHandler)

All these lambda's give me one of the following errors on startup (during initialisation):

Missing AWS Lambda trace data for X-Ray. Ensure Active Tracing is enabled and no subsegments are created outside the function handler

or

Missing AWS Lambda trace data for X-Ray. Expected _X_AMZN_TRACE_ID to be set

My understanding is that we need capturePromise() for our axios dependency.|

I'm wondering where those messages come from and how I can fix them.

Relevant details (will add on demand/request):

  • AWS_XRAY_ENABLED is set
  • package version: aws-xray-sdk-core": "3.3.1"
0 Answers
Related