0

I am getting "Failed to get the current sub/segment from the context" with node lambda. AFter adding environment variable as suggested in another post, I am getting addAnnotation of NULL. Because of this my test are getting failed.

Is there any workaround to make this pass? Help is much appreciated.

Ramya Karuna
  • 61
  • 2
  • 5

1 Answers1

2

Which other post are you referring to? Can you post the code to reproduce?

When in Lambda, X-Ray does not have access to the segment. The segment is created by Lambda and sent independently. In order for the X-Ray service to reconstruct the full segment/subsegment structure, the SDK picks up an environment varibale set by Lambda, and creates a "facade segment". This represents a placeholder to build off of and cannot be modified.

Typically we advise to create a new subsegment and add the annotation there. Keep in mind, this will only work within the handler.

AWSSandra
  • 374
  • 1
  • 7
  • In my local, if I use node-lambda to run the lambda function, I am getting "Failed to get the current sub/segment from the context". Whereas, when I deploy the nodeJS code as lambda function in AWS, it is working fine. I am checking with node-lambda in local and that triggers this issue. Does AWS X-ray support nodelambda ? – Ramya Karuna Feb 07 '19 at 07:10
  • 1
    Ah, node-lambda is a (recently published) 3rd party library. They are probably missing the mechanisms to support X-Ray. If you open a github issue on their repo https://github.com/motdotla/node-lambda we can chime in there and help. – AWSSandra Feb 12 '19 at 20:59