Repository navigation
[Serverless] remove LambdaContext - #3531
Conversation
devinsba
left a comment
There was a problem hiding this comment.
Just the one constant that should be moved
| AgentSpan span = | ||
| startSpan(UTF8BytesString.create("dd-tracer-serverless-span"), lambdaContext); | ||
| final AgentSpan span; | ||
| final UTF8BytesString invocationSpan = UTF8BytesString.create("dd-tracer-serverless-span"); |
There was a problem hiding this comment.
Can you pull this to a location where it can be static? LambdaHandler.java is probably a good place
| traceID, | ||
| samplingPriority); | ||
| return new ExtractedContext( | ||
| DDId.from(traceID), DDId.ZERO, samplingPriority, DEFAULT, null, 0, null, null); |
There was a problem hiding this comment.
So, this line says that this lambda will have a parent with span ID 0 (so it will be a root span), what about the case of one lambda calling another? Is the lambda layer doing some remapping outside the javaagent that we don't see here?
Maybe a class comment that outlines the flow would be helpful
There was a problem hiding this comment.
yeah, I'll add a comment.
Basically this span will be dropped by the extension since the extension is creating the top level invocation span on its own to avoid duplicating the logic of parsing the context in 6 different runtimes (this is our universal instrumentation project)
We just need this span for any subsequent created spans (custom spans or auto instrumented spans) so they will parented to this span and the trace will be consistent
There was a problem hiding this comment.
Would you mind posting the json too?
Also would it be possible for us to integration test this? Can we run the lambda layer as a docker container?
There was a problem hiding this comment.
I'm also not sure how the children end up with the correct parent, since the extension will have a span ID that the Java code won't know, unless the extension uses the span ID we communicate back in the notifyEndInvocation headers
There was a problem hiding this comment.
What I am saying here is: if the customer attempts to modify the active span during their handler code, adding tags for example, do those changes get lost? Or do they get copied into the extensions span?
There was a problem hiding this comment.
oh I see, sorry for the confusion. Indeed they would be lost.
Only extra tags provided via environment variables DD_TAGS or DD_EXTRA_TAGS / datadog.yml config file would be kept.
There was a problem hiding this comment.
I'm Ok with this if this shortcoming is documented somewhere (so that support can point users there). If you can point me to a docs PR or somewhere in the serverless docs that show this then I can 👍 the PR
I expect that this will surprise users so I don't want a bunch of support requests getting to our team
There was a problem hiding this comment.
I think not able to alter the Datadog generated lambda span is OK. We did hear from customers a lot in the past on how to tag the lambda span with an invocation/request specific tag (such as user id, etc.) However, with the recent support of capturing the request/response payloads into the lambda span OOB https://docs.datadoghq.com/serverless/configuration?tab=datadogcli#collect-the-request-and-response-payloads, I expect majority of customers no longer need to add custom tags to the lambda span any longer, because all the invocation specific information can already be captured to the span automatically. For custom tags that don't vary invocation by invocation, customers can use DD_TAGS.
Speaking of doc, I suggest adopting the lazy approach here to avoid confusing customers with things they don't even need to know. That said, I suggest only documenting this shortcoming in the release notes as a breaking change (java tracing is relatively new to serverless, don't expect customers actually are adding custom tags to the lambda span today). If customers prove that we are wrong and they still have a valid reason to add custom invocation-specific tags to the lambda span that we generate, I think we should actually come up with a solution to support that somehow instead of documenting it as a shortcoming/limitation.
There was a problem hiding this comment.
We will have to remember this as we gain more java users

What Does This Do
Following this PR : #3506 and DataDog/datadog-agent#11825
LambdaHandler is not needed anymore which simplifies the code
Motivation
Additional Notes