We have an application with around 25 Lambdas where we want to implement Xray tracing for all (or most) AWS SDK client calls. We have done a PoC implementation as described here, and it's working as expected. What I'm wondering is how we can best pass around the xray context object that is needed by all the client ...WithContext() methods?
I feel that the best way would be to pass the context along when the actual client is created, but since we create the clients BEFORE the actual handler is invoked to allow for reuse of those clients, this is not possible since we don't yet have access to the request context object. Passing the context in every single method call downstream to the clients (DynamoDB, Cognito, S3, KMS etc.) doesn't feel like a good solution either since that will clutter the code, and we're essentially passing the exact same context everywhere.
Is there a better way to share the context?