11import datadog.trace.agent.test.naming.VersionedNamingTestBase
22import java.nio.charset.StandardCharsets
3+ import com.amazonaws.services.lambda.runtime.Context
34
45abstract class LambdaHandlerInstrumentationTest extends VersionedNamingTestBase {
6+ def requestId = " test-request-id"
57
68 @Override
79 String service () {
@@ -12,7 +14,10 @@ abstract class LambdaHandlerInstrumentationTest extends VersionedNamingTestBase
1214 when :
1315 def input = new ByteArrayInputStream (StandardCharsets . UTF_8 . encode(" Hello" ). array())
1416 def output = new ByteArrayOutputStream ()
15- new HandlerStreaming (). handleRequest(input, output, null )
17+ def ctx = Stub (Context ) {
18+ getAwsRequestId() >> requestId
19+ }
20+ new HandlerStreaming (). handleRequest(input, output, ctx)
1621
1722 then :
1823 assertTraces(1 ) {
@@ -29,7 +34,10 @@ abstract class LambdaHandlerInstrumentationTest extends VersionedNamingTestBase
2934 when :
3035 def input = new ByteArrayInputStream (StandardCharsets . UTF_8 . encode(" Hello" ). array())
3136 def output = new ByteArrayOutputStream ()
32- new HandlerStreamingWithError (). handleRequest(input, output, null )
37+ def ctx = Stub (Context ) {
38+ getAwsRequestId() >> requestId
39+ }
40+ new HandlerStreamingWithError (). handleRequest(input, output, ctx)
3341
3442 then :
3543 thrown(Error )
@@ -39,6 +47,7 @@ abstract class LambdaHandlerInstrumentationTest extends VersionedNamingTestBase
3947 operationName operation()
4048 errored true
4149 tags {
50+ tag " request_id" , requestId
4251 tag " error.type" , " java.lang.Error"
4352 tag " error.message" , " Some error"
4453 tag " error.stack" , String
0 commit comments