Skip to content

Commit

Permalink
feat: add response streaming (#376)
Browse files Browse the repository at this point in the history
* update `dd-trace` to `v2.30.1`

* add response streaming constants

* update handler

* update `trigget.ts`

* update `listener.ts`

make sure we update status to check if a function is response streaming

* update `index.ts`

make sure response streaming functions are instrumented correctly

* fix: lint

* bump layer uncompressed size

* update snapshots

---------

Co-authored-by: AJ Stuyvenberg <[email protected]>
  • Loading branch information
duncanista and astuyve authored Apr 7, 2023
1 parent 56f6227 commit c9c0fdc
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 106 deletions.
24 changes: 8 additions & 16 deletions integration_tests/snapshots/logs/process-input-traced_node14.log
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -107,8 +106,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -130,8 +128,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -152,8 +149,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -250,8 +246,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -274,8 +269,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -371,8 +365,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -395,8 +388,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down
24 changes: 8 additions & 16 deletions integration_tests/snapshots/logs/process-input-traced_node16.log
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -110,8 +109,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -134,8 +132,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -157,8 +154,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -257,8 +253,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -282,8 +277,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -381,8 +375,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -406,8 +399,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down
24 changes: 8 additions & 16 deletions integration_tests/snapshots/logs/process-input-traced_node18.log
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -110,8 +109,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -134,8 +132,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -157,8 +154,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -257,8 +253,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -282,8 +277,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -381,8 +375,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -406,8 +399,7 @@ START
},
"metrics": {
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down
14 changes: 5 additions & 9 deletions integration_tests/snapshots/logs/status-code-500s_node14.log
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -112,8 +111,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -200,8 +198,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -213,7 +210,6 @@ START
}
END Duration: XXXX ms Memory Used: XXXX MB
START
END Duration: XXXX ms Memory Used: XXXX MB
{
"e": XXXX,
"m": "aws.lambda.enhanced.invocations",
Expand Down Expand Up @@ -289,8 +285,7 @@ END Duration: XXXX ms Memory Used: XXXX MB
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -300,3 +295,4 @@ END Duration: XXXX ms Memory Used: XXXX MB
]
]
}
END Duration: XXXX ms Memory Used: XXXX MB
12 changes: 4 additions & 8 deletions integration_tests/snapshots/logs/status-code-500s_node16.log
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -115,8 +114,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -205,8 +203,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -295,8 +292,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down
12 changes: 4 additions & 8 deletions integration_tests/snapshots/logs/status-code-500s_node18.log
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ START
"metrics": {
"cold_start": 1,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand All @@ -115,8 +114,7 @@ START
"language": "javascript"
},
"metrics": {
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -205,8 +203,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down Expand Up @@ -295,8 +292,7 @@ START
"metrics": {
"cold_start": 0,
"_dd.measured": 1,
"process_id":XXXX,
"_sampling_priority_v1": 1
"process_id":XXXX
},
"start":XXXX,
"duration":XXXX,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ START
],
"v": 1
}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at traceListenerOnWrap (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
END Duration: XXXX ms (init: XXXX ms) Memory Used: XXXX MB
START
{
Expand Down Expand Up @@ -63,7 +63,7 @@ START
],
"v": 1
}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at traceListenerOnWrap (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
END Duration: XXXX ms Memory Used: XXXX MB
START
{
Expand Down Expand Up @@ -96,5 +96,5 @@ START
],
"v": 1
}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
XXXX-XX-XX XX:XX:XX.XXX ERROR [dd.trace_id=XXXX dd.span_id=XXXX] Invoke Error {"errorType":"Error","errorMessage":"Hello","stack":["Error: Hello"," at handle (/var/task/throw-error-traced.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/utils/handler.js:XXX:XXX"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at step (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at Object.next (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"," at new Promise (<anonymous>)"," at __awaiter (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at traceListenerOnWrap (/opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX)"," at /opt/nodejs/node_modules/datadog-lambda-js/index.js:XXX:XXX"]}
END Duration: XXXX ms Memory Used: XXXX MB
Loading

0 comments on commit c9c0fdc

Please sign in to comment.