Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

captureHTTPsGlobal intercepting RAPIDClient.postInitError #578

Open
icholy opened this issue Mar 23, 2023 · 3 comments
Open

captureHTTPsGlobal intercepting RAPIDClient.postInitError #578

icholy opened this issue Mar 23, 2023 · 3 comments

Comments

@icholy
Copy link

icholy commented Mar 23, 2023

I'm getting the following error in one of my lambdas:

ERROR	Error: Missing AWS Lambda trace data for X-Ray. Ensure Active Tracing is enabled and no subsegments are created outside the function handler.
    at Object.contextMissingLogError [as contextMissing] (/var/task/lambda.js:40055:27)
    at Segment.resolveLambdaTraceData (/var/task/lambda.js:40428:49)
    at Object.getSegment (/var/task/lambda.js:40125:25)
    at Object.resolveSegment (/var/task/lambda.js:40104:25)
    at captureOutgoingHTTPs (/var/task/lambda.js:42220:37)
    at Object.captureHTTPsRequest [as request] (/var/task/lambda.js:42309:16)
    at RAPIDClient._post (file:///var/runtime/index.mjs:510:33)
    at RAPIDClient.postInitError (file:///var/runtime/index.mjs:460:14)
    at Object.uncaughtException (file:///var/runtime/index.mjs:1177:14)
    at process.<anonymous> (file:///var/runtime/index.mjs:1185:20)

It appears that there's an uncaught exception somewhere in my init code. The lambda runtime is attempting to report the error to some http endpoint. However, the xray instrumentation is preventing that from working.

I know I can set AWS_XRAY_CONTEXT_MISSING, but I feel like the xray sdk should work with the runtime without any additional workarounds.

@carolabadeer
Copy link
Contributor

Can you please provide an overview of any upstream services that may be calling this Lambda function, and if possible, share your init code that is throwing this error?

As mentioned in the error message, can you also please ensure that Active Tracing is enabled on this Lambda and that all subsegments (including the AWSXRay.captureHTTPsGlobal line) are being created within the Lambda handler?

@icholy
Copy link
Author

icholy commented Apr 4, 2023

Why would AWSXRay.captureHTTPsGlobal be called in the handler? It seems like you'd only want to install those hooks once during init.

I'll try to get you a simple repro.

@carolabadeer
Copy link
Contributor

carolabadeer commented Apr 17, 2023

Lambda creates a facade parent segment at the beginning of the handler function, so any custom subsegments or initialization of instrumentation should be initialized inside the function handler to be captured and have the Lambda facade segment as their parent.

Providing a sample of your implementation (including the "init" step where the instrumentations are initialized) would be very helpful in debugging this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants