DataDog / dd-trace-java

Datadog APM client for Java
https://docs.datadoghq.com/tracing/languages/java
Apache License 2.0
588 stars 290 forks source link

Parse 128 bit trace Id retuned by lambda extension #7620

Closed agocs closed 1 month ago

agocs commented 2 months ago

What Does This Do

I've updated the Lambda extension so it is capable of returning a 128 bit trace ID when a tracer calls the /lambda/start-invocation endpoint in this PR

As per the RFC, the

lower 64 bits in x-datadog-trace-id (decimal) and the higher 64 bits in x-datadog-tags header under _dd.p.tid (hex) tag.

This change modifies the function that calls /lambda/start-invocation, allowing it to pick out the upper 64 bits of the trace ID and set the resulting 128-bit trace ID in the extracted context.

I labelled this with tag: no release notes because it just changes behavior between the tracer and the Lambda extension.

Motivation

Step Function traces create 128 bit trace IDs. Soon everything else will too.

Additional Notes

Contributor Checklist

Jira ticket: SVLS-5583

pr-commenter[bot] commented 2 months ago

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master chris.agocs/parse_128_bit_trace_id_from_lambda_extension
git_commit_date 1727371427 1727373750
git_commit_sha 1392830fdb 0ba15ad2ef
release_version 1.40.0-SNAPSHOT~1392830fdb 1.40.0-SNAPSHOT~0ba15ad2ef
See matching parameters | |Baseline |Candidate | |---------------------|----------------------------------------------|----------------------------------------------| |application |insecure-bank |insecure-bank | |ci_job_date |1727376104 |1727376104 | |ci_job_id |653208294 |653208294 | |ci_pipeline_id|45246232 |45246232 | |cpu_model |Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz|Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz| |module |Agent |Agent | |parent |None |None | |variant |iast |iast |

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 15 unstable metrics.

Startup time reports for insecure-bank ```mermaid gantt title insecure-bank - global startup overhead: candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section tracing Agent [baseline] (1.07 s) : 0, 1070394 Total [baseline] (8.554 s) : 0, 8553949 Agent [candidate] (1.088 s) : 0, 1088105 Total [candidate] (8.606 s) : 0, 8606253 section iast Agent [baseline] (1.191 s) : 0, 1190710 Total [baseline] (9.029 s) : 0, 9028923 Agent [candidate] (1.204 s) : 0, 1203552 Total [candidate] (9.043 s) : 0, 9042868 section iast_HARDCODED_SECRET_DISABLED Agent [baseline] (1.193 s) : 0, 1193042 Total [baseline] (9.032 s) : 0, 9031591 Agent [candidate] (1.194 s) : 0, 1194340 Total [candidate] (9.007 s) : 0, 9006748 section iast_TELEMETRY_OFF Agent [baseline] (1.199 s) : 0, 1199003 Total [baseline] (9.023 s) : 0, 9022907 Agent [candidate] (1.192 s) : 0, 1192312 Total [candidate] (9.064 s) : 0, 9064044 ``` * **baseline** results |Module|Variant|Duration|Δ tracing| |---|---|---|---| |Agent|tracing|1.07 s |-| |Agent|iast|1.191 s |120.316 ms (11.2%)| |Agent|iast_HARDCODED_SECRET_DISABLED|1.193 s |122.648 ms (11.5%)| |Agent|iast_TELEMETRY_OFF|1.199 s |128.609 ms (12.0%)| |Total|tracing|8.554 s |-| |Total|iast|9.029 s |474.973 ms (5.6%)| |Total|iast_HARDCODED_SECRET_DISABLED|9.032 s |477.641 ms (5.6%)| |Total|iast_TELEMETRY_OFF|9.023 s |468.958 ms (5.5%)| * **candidate** results |Module|Variant|Duration|Δ tracing| |---|---|---|---| |Agent|tracing|1.088 s |-| |Agent|iast|1.204 s |115.447 ms (10.6%)| |Agent|iast_HARDCODED_SECRET_DISABLED|1.194 s |106.235 ms (9.8%)| |Agent|iast_TELEMETRY_OFF|1.192 s |104.208 ms (9.6%)| |Total|tracing|8.606 s |-| |Total|iast|9.043 s |436.616 ms (5.1%)| |Total|iast_HARDCODED_SECRET_DISABLED|9.007 s |400.495 ms (4.7%)| |Total|iast_TELEMETRY_OFF|9.064 s |457.791 ms (5.3%)| ```mermaid gantt title insecure-bank - break down per module: candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section tracing BytebuddyAgent [baseline] (684.182 ms) : 0, 684182 BytebuddyAgent [candidate] (695.431 ms) : 0, 695431 GlobalTracer [baseline] (310.161 ms) : 0, 310161 GlobalTracer [candidate] (315.324 ms) : 0, 315324 AppSec [baseline] (53.97 ms) : 0, 53970 AppSec [candidate] (54.818 ms) : 0, 54818 Remote Config [baseline] (686.346 µs) : 0, 686 Remote Config [candidate] (682.676 µs) : 0, 683 Telemetry [baseline] (7.695 ms) : 0, 7695 Telemetry [candidate] (7.832 ms) : 0, 7832 section iast BytebuddyAgent [baseline] (792.65 ms) : 0, 792650 BytebuddyAgent [candidate] (801.545 ms) : 0, 801545 GlobalTracer [baseline] (298.5 ms) : 0, 298500 GlobalTracer [candidate] (302.334 ms) : 0, 302334 AppSec [baseline] (53.838 ms) : 0, 53838 AppSec [candidate] (53.401 ms) : 0, 53401 IAST [baseline] (24.473 ms) : 0, 24473 IAST [candidate] (24.648 ms) : 0, 24648 Remote Config [baseline] (591.434 µs) : 0, 591 Remote Config [candidate] (636.279 µs) : 0, 636 Telemetry [baseline] (6.913 ms) : 0, 6913 Telemetry [candidate] (7.063 ms) : 0, 7063 section iast_HARDCODED_SECRET_DISABLED BytebuddyAgent [baseline] (793.912 ms) : 0, 793912 BytebuddyAgent [candidate] (793.501 ms) : 0, 793501 GlobalTracer [baseline] (299.501 ms) : 0, 299501 GlobalTracer [candidate] (300.277 ms) : 0, 300277 AppSec [baseline] (55.375 ms) : 0, 55375 AppSec [candidate] (54.994 ms) : 0, 54994 IAST [baseline] (22.777 ms) : 0, 22777 IAST [candidate] (23.931 ms) : 0, 23931 Remote Config [baseline] (620.321 µs) : 0, 620 Remote Config [candidate] (650.511 µs) : 0, 651 Telemetry [baseline] (7.067 ms) : 0, 7067 Telemetry [candidate] (7.19 ms) : 0, 7190 section iast_TELEMETRY_OFF BytebuddyAgent [baseline] (796.668 ms) : 0, 796668 BytebuddyAgent [candidate] (791.808 ms) : 0, 791808 GlobalTracer [baseline] (302.307 ms) : 0, 302307 GlobalTracer [candidate] (300.298 ms) : 0, 300298 AppSec [baseline] (56.185 ms) : 0, 56185 AppSec [candidate] (54.446 ms) : 0, 54446 IAST [baseline] (20.786 ms) : 0, 20786 IAST [candidate] (23.518 ms) : 0, 23518 Remote Config [baseline] (2.163 ms) : 0, 2163 Remote Config [candidate] (1.397 ms) : 0, 1397 Telemetry [baseline] (7.012 ms) : 0, 7012 Telemetry [candidate] (7.01 ms) : 0, 7010 ```
Startup time reports for petclinic ```mermaid gantt title petclinic - global startup overhead: candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section tracing Agent [baseline] (1.068 s) : 0, 1068254 Total [baseline] (10.497 s) : 0, 10497146 Agent [candidate] (1.066 s) : 0, 1066318 Total [candidate] (10.469 s) : 0, 10468734 section appsec Agent [baseline] (1.205 s) : 0, 1205209 Total [baseline] (10.678 s) : 0, 10678262 Agent [candidate] (1.214 s) : 0, 1213777 Total [candidate] (10.683 s) : 0, 10682904 section iast Agent [baseline] (1.19 s) : 0, 1190269 Total [baseline] (10.89 s) : 0, 10890099 Agent [candidate] (1.196 s) : 0, 1195612 Total [candidate] (10.875 s) : 0, 10874589 section profiling Agent [baseline] (1.268 s) : 0, 1268123 Total [baseline] (10.645 s) : 0, 10644847 Agent [candidate] (1.276 s) : 0, 1276137 Total [candidate] (10.594 s) : 0, 10594097 ``` * **baseline** results |Module|Variant|Duration|Δ tracing| |---|---|---|---| |Agent|tracing|1.068 s |-| |Agent|appsec|1.205 s |136.955 ms (12.8%)| |Agent|iast|1.19 s |122.015 ms (11.4%)| |Agent|profiling|1.268 s |199.869 ms (18.7%)| |Total|tracing|10.497 s |-| |Total|appsec|10.678 s |181.117 ms (1.7%)| |Total|iast|10.89 s |392.954 ms (3.7%)| |Total|profiling|10.645 s |147.701 ms (1.4%)| * **candidate** results |Module|Variant|Duration|Δ tracing| |---|---|---|---| |Agent|tracing|1.066 s |-| |Agent|appsec|1.214 s |147.459 ms (13.8%)| |Agent|iast|1.196 s |129.295 ms (12.1%)| |Agent|profiling|1.276 s |209.82 ms (19.7%)| |Total|tracing|10.469 s |-| |Total|appsec|10.683 s |214.17 ms (2.0%)| |Total|iast|10.875 s |405.855 ms (3.9%)| |Total|profiling|10.594 s |125.362 ms (1.2%)| ```mermaid gantt title petclinic - break down per module: candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section tracing BytebuddyAgent [baseline] (681.231 ms) : 0, 681231 BytebuddyAgent [candidate] (680.332 ms) : 0, 680332 GlobalTracer [baseline] (310.768 ms) : 0, 310768 GlobalTracer [candidate] (310.384 ms) : 0, 310384 AppSec [baseline] (54.108 ms) : 0, 54108 AppSec [candidate] (53.651 ms) : 0, 53651 Remote Config [baseline] (680.014 µs) : 0, 680 Remote Config [candidate] (656.297 µs) : 0, 656 Telemetry [baseline] (7.751 ms) : 0, 7751 Telemetry [candidate] (7.592 ms) : 0, 7592 section appsec BytebuddyAgent [baseline] (704.011 ms) : 0, 704011 BytebuddyAgent [candidate] (709.952 ms) : 0, 709952 GlobalTracer [baseline] (304.788 ms) : 0, 304788 GlobalTracer [candidate] (306.952 ms) : 0, 306952 AppSec [baseline] (163.134 ms) : 0, 163134 AppSec [candidate] (164.122 ms) : 0, 164122 Remote Config [baseline] (653.827 µs) : 0, 654 Remote Config [candidate] (638.967 µs) : 0, 639 Telemetry [baseline] (8.211 ms) : 0, 8211 Telemetry [candidate] (8.607 ms) : 0, 8607 IAST [baseline] (21.402 ms) : 0, 21402 IAST [candidate] (19.26 ms) : 0, 19260 section iast BytebuddyAgent [baseline] (791.355 ms) : 0, 791355 BytebuddyAgent [candidate] (793.937 ms) : 0, 793937 GlobalTracer [baseline] (298.747 ms) : 0, 298747 GlobalTracer [candidate] (301.438 ms) : 0, 301438 AppSec [baseline] (54.113 ms) : 0, 54113 AppSec [candidate] (54.656 ms) : 0, 54656 Remote Config [baseline] (633.806 µs) : 0, 634 Remote Config [candidate] (642.243 µs) : 0, 642 Telemetry [baseline] (7.017 ms) : 0, 7017 Telemetry [candidate] (7.166 ms) : 0, 7166 IAST [baseline] (24.633 ms) : 0, 24633 IAST [candidate] (24.012 ms) : 0, 24012 section profiling ProfilingAgent [baseline] (96.405 ms) : 0, 96405 ProfilingAgent [candidate] (96.944 ms) : 0, 96944 BytebuddyAgent [baseline] (675.466 ms) : 0, 675466 BytebuddyAgent [candidate] (680.189 ms) : 0, 680189 GlobalTracer [baseline] (394.486 ms) : 0, 394486 GlobalTracer [candidate] (396.304 ms) : 0, 396304 AppSec [baseline] (54.853 ms) : 0, 54853 AppSec [candidate] (55.352 ms) : 0, 55352 Remote Config [baseline] (651.04 µs) : 0, 651 Remote Config [candidate] (657.942 µs) : 0, 658 Telemetry [baseline] (7.431 ms) : 0, 7431 Telemetry [candidate] (7.534 ms) : 0, 7534 Profiling [baseline] (96.428 ms) : 0, 96428 Profiling [candidate] (96.97 ms) : 0, 96970 ```

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-09-26T18:12:14 2024-09-26T18:19:05
git_branch master chris.agocs/parse_128_bit_trace_id_from_lambda_extension
git_commit_date 1727371427 1727373750
git_commit_sha 1392830fdb 0ba15ad2ef
release_version 1.40.0-SNAPSHOT~1392830fdb 1.40.0-SNAPSHOT~0ba15ad2ef
start_time 2024-09-26T18:12:00 2024-09-26T18:18:52
See matching parameters | |Baseline |Candidate | |---------------------|----------------------------------------------|----------------------------------------------| |application |insecure-bank |insecure-bank | |ci_job_date |1727375091 |1727375091 | |ci_job_id |653208295 |653208295 | |ci_pipeline_id|45246232 |45246232 | |cpu_model |Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz|Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz| |variant |iast |iast |

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 10 metrics, 18 unstable metrics.

Request duration reports for petclinic ```mermaid gantt title petclinic - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section baseline no_agent (1.345 ms) : 1325, 1365 . : milestone, 1345, appsec (1.754 ms) : 1730, 1778 . : milestone, 1754, appsec_no_iast (1.715 ms) : 1692, 1739 . : milestone, 1715, iast (1.48 ms) : 1458, 1503 . : milestone, 1480, profiling (1.486 ms) : 1461, 1511 . : milestone, 1486, tracing (1.489 ms) : 1465, 1513 . : milestone, 1489, section candidate no_agent (1.353 ms) : 1334, 1373 . : milestone, 1353, appsec (1.728 ms) : 1703, 1754 . : milestone, 1728, appsec_no_iast (1.728 ms) : 1704, 1752 . : milestone, 1728, iast (1.482 ms) : 1459, 1505 . : milestone, 1482, profiling (1.478 ms) : 1455, 1500 . : milestone, 1478, tracing (1.473 ms) : 1447, 1498 . : milestone, 1473, ``` * **baseline** results |Variant|Request duration [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|1.345 ms [1.325 ms, 1.365 ms]|-| |appsec|1.754 ms [1.73 ms, 1.778 ms]|409.645 µs (30.5%)| |appsec_no_iast|1.715 ms [1.692 ms, 1.739 ms]|370.718 µs (27.6%)| |iast|1.48 ms [1.458 ms, 1.503 ms]|135.66 µs (10.1%)| |profiling|1.486 ms [1.461 ms, 1.511 ms]|141.085 µs (10.5%)| |tracing|1.489 ms [1.465 ms, 1.513 ms]|144.425 µs (10.7%)| * **candidate** results |Variant|Request duration [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|1.353 ms [1.334 ms, 1.373 ms]|-| |appsec|1.728 ms [1.703 ms, 1.754 ms]|374.892 µs (27.7%)| |appsec_no_iast|1.728 ms [1.704 ms, 1.752 ms]|374.747 µs (27.7%)| |iast|1.482 ms [1.459 ms, 1.505 ms]|128.779 µs (9.5%)| |profiling|1.478 ms [1.455 ms, 1.5 ms]|124.27 µs (9.2%)| |tracing|1.473 ms [1.447 ms, 1.498 ms]|119.192 µs (8.8%)|
Request duration reports for insecure-bank ```mermaid gantt title insecure-bank - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section baseline no_agent (366.436 µs) : 347, 386 . : milestone, 366, iast (477.59 µs) : 457, 499 . : milestone, 478, iast_FULL (553.988 µs) : 533, 575 . : milestone, 554, iast_GLOBAL (517.536 µs) : 494, 541 . : milestone, 518, iast_HARDCODED_SECRET_DISABLED (486.637 µs) : 465, 508 . : milestone, 487, iast_INACTIVE (449.026 µs) : 428, 470 . : milestone, 449, iast_TELEMETRY_OFF (476.063 µs) : 453, 499 . : milestone, 476, tracing (442.038 µs) : 421, 463 . : milestone, 442, section candidate no_agent (375.256 µs) : 354, 397 . : milestone, 375, iast (482.854 µs) : 462, 504 . : milestone, 483, iast_FULL (552.643 µs) : 532, 574 . : milestone, 553, iast_GLOBAL (500.969 µs) : 480, 522 . : milestone, 501, iast_HARDCODED_SECRET_DISABLED (484.146 µs) : 463, 506 . : milestone, 484, iast_INACTIVE (450.597 µs) : 429, 472 . : milestone, 451, iast_TELEMETRY_OFF (486.68 µs) : 464, 510 . : milestone, 487, tracing (445.473 µs) : 425, 466 . : milestone, 445, ``` * **baseline** results |Variant|Request duration [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|366.436 µs [346.762 µs, 386.111 µs]|-| |iast|477.59 µs [456.647 µs, 498.534 µs]|111.154 µs (30.3%)| |iast_FULL|553.988 µs [532.724 µs, 575.251 µs]|187.551 µs (51.2%)| |iast_GLOBAL|517.536 µs [493.985 µs, 541.088 µs]|151.1 µs (41.2%)| |iast_HARDCODED_SECRET_DISABLED|486.637 µs [465.235 µs, 508.039 µs]|120.2 µs (32.8%)| |iast_INACTIVE|449.026 µs [427.888 µs, 470.165 µs]|82.59 µs (22.5%)| |iast_TELEMETRY_OFF|476.063 µs [453.359 µs, 498.768 µs]|109.627 µs (29.9%)| |tracing|442.038 µs [421.457 µs, 462.618 µs]|75.601 µs (20.6%)| * **candidate** results |Variant|Request duration [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|375.256 µs [353.816 µs, 396.696 µs]|-| |iast|482.854 µs [461.514 µs, 504.195 µs]|107.599 µs (28.7%)| |iast_FULL|552.643 µs [531.506 µs, 573.779 µs]|177.387 µs (47.3%)| |iast_GLOBAL|500.969 µs [479.881 µs, 522.056 µs]|125.713 µs (33.5%)| |iast_HARDCODED_SECRET_DISABLED|484.146 µs [462.774 µs, 505.518 µs]|108.89 µs (29.0%)| |iast_INACTIVE|450.597 µs [429.358 µs, 471.836 µs]|75.341 µs (20.1%)| |iast_TELEMETRY_OFF|486.68 µs [463.534 µs, 509.826 µs]|111.425 µs (29.7%)| |tracing|445.473 µs [424.949 µs, 465.997 µs]|70.217 µs (18.7%)|

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master chris.agocs/parse_128_bit_trace_id_from_lambda_extension
git_commit_date 1727371427 1727373750
git_commit_sha 1392830fdb 0ba15ad2ef
release_version 1.40.0-SNAPSHOT~1392830fdb 1.40.0-SNAPSHOT~0ba15ad2ef
See matching parameters | |Baseline |Candidate | |---------------------|----------------------------------------------|----------------------------------------------| |application |biojava |biojava | |ci_job_date |1727375752 |1727375752 | |ci_job_id |653208296 |653208296 | |ci_pipeline_id|45246232 |45246232 | |cpu_model |Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz|Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz| |variant |appsec |appsec |

Summary

Found 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics.

Execution time for biojava ```mermaid gantt title biojava - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section baseline no_agent (14.897 s) : 14897000, 14897000 . : milestone, 14897000, appsec (15.27 s) : 15270000, 15270000 . : milestone, 15270000, iast (18.786 s) : 18786000, 18786000 . : milestone, 18786000, iast_GLOBAL (17.774 s) : 17774000, 17774000 . : milestone, 17774000, profiling (15.635 s) : 15635000, 15635000 . : milestone, 15635000, tracing (15.251 s) : 15251000, 15251000 . : milestone, 15251000, section candidate no_agent (15.382 s) : 15382000, 15382000 . : milestone, 15382000, appsec (15.257 s) : 15257000, 15257000 . : milestone, 15257000, iast (18.74 s) : 18740000, 18740000 . : milestone, 18740000, iast_GLOBAL (17.98 s) : 17980000, 17980000 . : milestone, 17980000, profiling (15.435 s) : 15435000, 15435000 . : milestone, 15435000, tracing (15.348 s) : 15348000, 15348000 . : milestone, 15348000, ``` * **baseline** results |Variant|Execution Time [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|14.897 s [14.897 s, 14.897 s]|-| |appsec|15.27 s [15.27 s, 15.27 s]|373.0 ms (2.5%)| |iast|18.786 s [18.786 s, 18.786 s]|3.889 s (26.1%)| |iast_GLOBAL|17.774 s [17.774 s, 17.774 s]|2.877 s (19.3%)| |profiling|15.635 s [15.635 s, 15.635 s]|738.0 ms (5.0%)| |tracing|15.251 s [15.251 s, 15.251 s]|354.0 ms (2.4%)| * **candidate** results |Variant|Execution Time [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|15.382 s [15.382 s, 15.382 s]|-| |appsec|15.257 s [15.257 s, 15.257 s]|-125.0 ms (-0.8%)| |iast|18.74 s [18.74 s, 18.74 s]|3.358 s (21.8%)| |iast_GLOBAL|17.98 s [17.98 s, 17.98 s]|2.598 s (16.9%)| |profiling|15.435 s [15.435 s, 15.435 s]|53.0 ms (0.3%)| |tracing|15.348 s [15.348 s, 15.348 s]|-34.0 ms (-0.2%)|
Execution time for tomcat ```mermaid gantt title tomcat - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~0ba15ad2ef, baseline=1.40.0-SNAPSHOT~1392830fdb dateFormat X axisFormat %s section baseline no_agent (1.463 ms) : 1451, 1474 . : milestone, 1463, appsec (2.307 ms) : 2267, 2348 . : milestone, 2307, iast (2.042 ms) : 1992, 2092 . : milestone, 2042, iast_GLOBAL (2.085 ms) : 2034, 2135 . : milestone, 2085, profiling (1.921 ms) : 1881, 1961 . : milestone, 1921, tracing (1.891 ms) : 1853, 1929 . : milestone, 1891, section candidate no_agent (1.459 ms) : 1447, 1470 . : milestone, 1459, appsec (2.306 ms) : 2265, 2346 . : milestone, 2306, iast (2.041 ms) : 1991, 2091 . : milestone, 2041, iast_GLOBAL (2.073 ms) : 2023, 2123 . : milestone, 2073, profiling (1.918 ms) : 1878, 1958 . : milestone, 1918, tracing (1.896 ms) : 1858, 1935 . : milestone, 1896, ``` * **baseline** results |Variant|Execution Time [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|1.463 ms [1.451 ms, 1.474 ms]|-| |appsec|2.307 ms [2.267 ms, 2.348 ms]|844.432 µs (57.7%)| |iast|2.042 ms [1.992 ms, 2.092 ms]|579.322 µs (39.6%)| |iast_GLOBAL|2.085 ms [2.034 ms, 2.135 ms]|621.778 µs (42.5%)| |profiling|1.921 ms [1.881 ms, 1.961 ms]|458.379 µs (31.3%)| |tracing|1.891 ms [1.853 ms, 1.929 ms]|428.0 µs (29.3%)| * **candidate** results |Variant|Execution Time [CI 0.99]|Δ no_agent| |---|---|---| |no_agent|1.459 ms [1.447 ms, 1.47 ms]|-| |appsec|2.306 ms [2.265 ms, 2.346 ms]|847.015 µs (58.1%)| |iast|2.041 ms [1.991 ms, 2.091 ms]|582.153 µs (39.9%)| |iast_GLOBAL|2.073 ms [2.023 ms, 2.123 ms]|614.176 µs (42.1%)| |profiling|1.918 ms [1.878 ms, 1.958 ms]|459.365 µs (31.5%)| |tracing|1.896 ms [1.858 ms, 1.935 ms]|437.656 µs (30.0%)|
agocs commented 2 months ago

Hi @PerfectSlayer, I'm extending code that was written two years ago. Can you point me to an example of the context propagation API?

PerfectSlayer commented 2 months ago

Sure, if pass the CoreTracer instance as a notifyStartInvocation() parameter, you can then use:

        Extracted context = tracer.propagate().extract(response.headers(), (carrier, classifier) -> {
          for (String headerName : carrier.names()) {
            classifier.accept(headerName, carrier.get(headerName));
          }
        });

propagate() gets the context propagation API and extract() extract context from a carrier. Here, your carrier are HTTP headers, and you need to have a quick glue to explain it how to iterate over headers key-values (the lambda as 2nd argument).

Using the context propagation API will ensure you will get the same behavior as any other instrumentations, respect customer config and benefits from any future evolution.

agocs commented 2 months ago

Thanks! I'll look into the failing checks and remove the old implementation of notifyStartInvocation() in the morning.

agocs commented 2 months ago

What's the right way to new up a CoreTracer in the Groovy tests? This seems to be giving me some problems.

PerfectSlayer commented 1 month ago

Using DDCoreSpecification and tracerBuilder().build() is the right way (plus tracer.close() on cleanUp).

Few things though:

  1. You might want to pass the custom Config instance to the tracer builder using config()
  2. Why are you trying to set xDatadogMaxLength to 512? It's already the default value 🤔

Note there are also injectSysConfig() and injectEnvConfig() methods to help with config overrides.

agocs commented 1 month ago

Thanks @PerfectSlayer. CoreTracer ct = tracerBuilder().config(config).build() was giving me null pointer exceptions, so I opted to get rid of Config config = Mock(Config). I honestly don't know why we were mocking config; I'm just doing my best to modify two year old code.

PerfectSlayer commented 1 month ago

I'm just doing my best to modify two year old code.

And tests look in good shape right now :wink:

Is there anything you have trouble with or want to improve as part of your PR?

agocs commented 1 month ago

@PerfectSlayer No, I'm ready to merge if you are