11import { invokeLambdaAndGetDatadogData , LambdaInvocationDatadogData , DATADOG_INDEXING_WAIT_5_MIN_MS } from './utils/util' ;
2- import { getTraces } from './utils/datadog' ;
32import { getIdentifier } from '../config' ;
4- import { LambdaClient , InvokeCommand } from '@aws-sdk/client-lambda' ;
53
64describe ( 'OTLP Integration Tests' , ( ) => {
75 const results : Record < string , LambdaInvocationDatadogData > = { } ;
@@ -13,6 +11,7 @@ describe('OTLP Integration Tests', () => {
1311 python : `integ-${ identifier } -otlp-python-lambda` ,
1412 java : `integ-${ identifier } -otlp-java-lambda` ,
1513 dotnet : `integ-${ identifier } -otlp-dotnet-lambda` ,
14+ responseValidation : `integ-${ identifier } -otlp-response-validation-lambda` ,
1615 } ;
1716
1817 console . log ( 'Invoking all OTLP Lambda functions in parallel...' ) ;
@@ -23,13 +22,15 @@ describe('OTLP Integration Tests', () => {
2322 invokeLambdaAndGetDatadogData ( functions . python , { } , true , true , DATADOG_INDEXING_WAIT_5_MIN_MS ) ,
2423 invokeLambdaAndGetDatadogData ( functions . java , { } , true , true , DATADOG_INDEXING_WAIT_5_MIN_MS ) ,
2524 invokeLambdaAndGetDatadogData ( functions . dotnet , { } , true , true , DATADOG_INDEXING_WAIT_5_MIN_MS ) ,
25+ invokeLambdaAndGetDatadogData ( functions . responseValidation , { } , true , true , DATADOG_INDEXING_WAIT_5_MIN_MS ) ,
2626 ] ) ;
2727
2828 // Store results
2929 results . node = invocationResults [ 0 ] ;
3030 results . python = invocationResults [ 1 ] ;
3131 results . java = invocationResults [ 2 ] ;
3232 results . dotnet = invocationResults [ 3 ] ;
33+ results . responseValidation = invocationResults [ 4 ] ;
3334
3435 console . log ( 'All OTLP Lambda invocations and data fetching completed' ) ;
3536 } , 700000 ) ; // 11.6 minute timeout
@@ -94,66 +95,54 @@ describe('OTLP Integration Tests', () => {
9495 } ) ;
9596 } ) ;
9697
97- describe ( 'OTLP Response Validation' , ( ) => {
98- const lambdaClient = new LambdaClient ( { region : 'us-east-1' } ) ;
99- const identifier = getIdentifier ( ) ;
100- const functionName = `integ-${ identifier } -otlp-response-validation-lambda` ;
101-
102- // This test validates SVLS-8626: JSON encoding support for OTLP traces
103- // The Lambda uses the OpenTelemetry SDK to send spans via both JSON and Protobuf
104- // encodings, then we verify both were accepted and reached Datadog
105- it ( 'should handle both protobuf and JSON encodings and send spans to Datadog' , async ( ) => {
106- console . log ( `Invoking ${ functionName } ...` ) ;
107-
108- const command = new InvokeCommand ( {
109- FunctionName : functionName ,
110- Payload : Buffer . from ( JSON . stringify ( { } ) ) ,
111- } ) ;
112-
113- const response = await lambdaClient . send ( command ) ;
114-
115- expect ( response . StatusCode ) . toBe ( 200 ) ;
116- expect ( response . FunctionError ) . toBeUndefined ( ) ;
117-
118- const payload = JSON . parse ( Buffer . from ( response . Payload ! ) . toString ( ) ) ;
119- const validationResult = JSON . parse ( payload . body ) ;
98+ // This test validates SVLS-8626: JSON encoding support for OTLP traces
99+ // The Lambda uses the OpenTelemetry SDK to send spans via both JSON and Protobuf
100+ // encodings, then we verify both were accepted and reached Datadog
101+ describe ( 'OTLP Response Validation (SVLS-8626)' , ( ) => {
102+ it ( 'should invoke response-validation Lambda successfully' , ( ) => {
103+ expect ( results . responseValidation . statusCode ) . toBe ( 200 ) ;
104+ } ) ;
120105
121- console . log ( 'Validation result:' , JSON . stringify ( validationResult , null , 2 ) ) ;
106+ it ( 'should accept JSON encoded OTLP traces' , ( ) => {
107+ const body = JSON . parse ( results . responseValidation . payload ?. body || '{}' ) ;
108+ expect ( body . json ?. success ) . toBe ( true ) ;
109+ } ) ;
122110
123- // Both encodings should be accepted by the extension
124- expect ( validationResult . success ) . toBe ( true ) ;
125- expect ( validationResult . json . success ) . toBe ( true ) ;
126- expect ( validationResult . protobuf . success ) . toBe ( true ) ;
111+ it ( 'should accept Protobuf encoded OTLP traces' , ( ) => {
112+ const body = JSON . parse ( results . responseValidation . payload ?. body || '{}' ) ;
113+ expect ( body . protobuf ? .success ) . toBe ( true ) ;
114+ } ) ;
127115
128- // Wait for spans to be indexed in Datadog (60s is typically enough)
129- const requestId = validationResult . requestId ;
130- console . log ( `Request ID: ${ requestId } ` ) ;
131- console . log ( 'Waiting 60s for spans to be indexed in Datadog...' ) ;
132- await new Promise ( resolve => setTimeout ( resolve , 60000 ) ) ;
116+ it ( 'should send at least one trace to Datadog' , ( ) => {
117+ expect ( results . responseValidation . traces ?. length ) . toBeGreaterThan ( 0 ) ;
118+ } ) ;
133119
134- // Query Datadog for the spans by service name (no request_id filter - nested attribute)
135- const traces = await getTraces ( functionName ) ;
136- const allSpans = traces . flatMap ( t => t . spans ) ;
137- console . log ( `Total spans in Datadog: ${ allSpans . length } ` ) ;
120+ it ( 'should have JSON encoded span in Datadog' , ( ) => {
121+ const body = JSON . parse ( results . responseValidation . payload ?. body || '{}' ) ;
122+ const requestId = body . requestId ;
123+ const allSpans = results . responseValidation . traces ?. flatMap ( t => t . spans ) || [ ] ;
138124
139125 // Filter by request_id from this invocation (at custom.request_id path)
140126 const currentRunSpans = allSpans . filter ( s => s . attributes ?. custom ?. request_id === requestId ) ;
141- console . log ( `Spans from this invocation (request_id=${ requestId } ): ${ currentRunSpans . length } ` ) ;
142127
143- // Verify we have spans from this invocation
144- expect ( currentRunSpans . length ) . toBeGreaterThanOrEqual ( 2 ) ;
145-
146- // Verify we have both JSON and Protobuf encoded spans
147128 const hasJsonSpan = currentRunSpans . some ( s =>
148129 s . attributes ?. resource_name === 'test-span-json' && s . attributes ?. custom ?. encoding === 'json'
149130 ) ;
131+ expect ( hasJsonSpan ) . toBe ( true ) ;
132+ } ) ;
133+
134+ it ( 'should have Protobuf encoded span in Datadog' , ( ) => {
135+ const body = JSON . parse ( results . responseValidation . payload ?. body || '{}' ) ;
136+ const requestId = body . requestId ;
137+ const allSpans = results . responseValidation . traces ?. flatMap ( t => t . spans ) || [ ] ;
138+
139+ // Filter by request_id from this invocation (at custom.request_id path)
140+ const currentRunSpans = allSpans . filter ( s => s . attributes ?. custom ?. request_id === requestId ) ;
141+
150142 const hasProtobufSpan = currentRunSpans . some ( s =>
151143 s . attributes ?. resource_name === 'test-span-protobuf' && s . attributes ?. custom ?. encoding === 'protobuf'
152144 ) ;
153-
154- console . log ( `Has JSON span: ${ hasJsonSpan } , Has Protobuf span: ${ hasProtobufSpan } ` ) ;
155- expect ( hasJsonSpan ) . toBe ( true ) ;
156145 expect ( hasProtobufSpan ) . toBe ( true ) ;
157- } , 120000 ) ; // 2 minute timeout
146+ } ) ;
158147 } ) ;
159148} ) ;
0 commit comments