Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support addEvent Otel API #7408

Merged
merged 40 commits into from
Sep 16, 2024
Merged

Support addEvent Otel API #7408

merged 40 commits into from
Sep 16, 2024

Conversation

mtoffl01
Copy link
Contributor

@mtoffl01 mtoffl01 commented Aug 9, 2024

What Does This Do

Adds support for span events via Span.addEvent and Span.recordException.

Motivation

https://datadoghq.atlassian.net/browse/APMAPI-199

Additional Notes

Passing all system tests enabled here: DataDog/system-tests#3027

Contributor Checklist

Jira ticket: [PROJ-IDENT]

@pr-commenter
Copy link

pr-commenter bot commented Aug 9, 2024

Benchmarks

Startup

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mtoff/span-events
git_commit_date 1726485541 1726488640
git_commit_sha c59beb4 3af7937
release_version 1.40.0-SNAPSHOT~c59beb4dc9 1.40.0-SNAPSHOT~3af7937d33
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1726491821 1726491821
ci_job_id 640353157 640353157
ci_pipeline_id 44403900 44403900
cpu_model Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz Intel(R) Xeon(R) Platinum 8175M 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 petclinic
gantt
    title petclinic - global startup overhead: candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.568 s) : 0, 1568370
Total [baseline] (14.158 s) : 0, 14158048
Agent [candidate] (1.565 s) : 0, 1565333
Total [candidate] (14.302 s) : 0, 14302435
section appsec
Agent [baseline] (1.77 s) : 0, 1769793
Total [baseline] (14.518 s) : 0, 14518005
Agent [candidate] (1.759 s) : 0, 1759228
Total [candidate] (14.548 s) : 0, 14548298
section iast
Agent [baseline] (1.735 s) : 0, 1735499
Total [baseline] (14.904 s) : 0, 14904290
Agent [candidate] (1.731 s) : 0, 1730702
Total [candidate] (14.733 s) : 0, 14732580
section profiling
Agent [baseline] (1.876 s) : 0, 1876310
Total [baseline] (14.465 s) : 0, 14465425
Agent [candidate] (1.874 s) : 0, 1873830
Total [candidate] (14.482 s) : 0, 14482200
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.568 s -
Agent appsec 1.77 s 201.422 ms (12.8%)
Agent iast 1.735 s 167.129 ms (10.7%)
Agent profiling 1.876 s 307.939 ms (19.6%)
Total tracing 14.158 s -
Total appsec 14.518 s 359.957 ms (2.5%)
Total iast 14.904 s 746.242 ms (5.3%)
Total profiling 14.465 s 307.377 ms (2.2%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.565 s -
Agent appsec 1.759 s 193.895 ms (12.4%)
Agent iast 1.731 s 165.369 ms (10.6%)
Agent profiling 1.874 s 308.497 ms (19.7%)
Total tracing 14.302 s -
Total appsec 14.548 s 245.863 ms (1.7%)
Total iast 14.733 s 430.145 ms (3.0%)
Total profiling 14.482 s 179.764 ms (1.3%)
gantt
    title petclinic - break down per module: candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (1.005 s) : 0, 1004598
BytebuddyAgent [candidate] (1.003 s) : 0, 1002978
GlobalTracer [baseline] (460.068 ms) : 0, 460068
GlobalTracer [candidate] (458.869 ms) : 0, 458869
AppSec [baseline] (73.018 ms) : 0, 73018
AppSec [candidate] (72.731 ms) : 0, 72731
Remote Config [baseline] (819.846 µs) : 0, 820
Remote Config [candidate] (858.958 µs) : 0, 859
Telemetry [baseline] (9.721 ms) : 0, 9721
Telemetry [candidate] (9.699 ms) : 0, 9699
section appsec
BytebuddyAgent [baseline] (1.036 s) : 0, 1036478
BytebuddyAgent [candidate] (1.028 s) : 0, 1027912
GlobalTracer [baseline] (449.069 ms) : 0, 449069
GlobalTracer [candidate] (447.954 ms) : 0, 447954
AppSec [baseline] (239.175 ms) : 0, 239175
AppSec [candidate] (237.955 ms) : 0, 237955
IAST [baseline] (26.266 ms) : 0, 26266
IAST [candidate] (25.745 ms) : 0, 25745
Remote Config [baseline] (788.909 µs) : 0, 789
Remote Config [candidate] (791.171 µs) : 0, 791
Telemetry [baseline] (11.011 ms) : 0, 11011
Telemetry [candidate] (11.605 ms) : 0, 11605
section iast
BytebuddyAgent [baseline] (1.165 s) : 0, 1164932
BytebuddyAgent [candidate] (1.16 s) : 0, 1160386
GlobalTracer [baseline] (437.435 ms) : 0, 437435
GlobalTracer [candidate] (437.416 ms) : 0, 437416
AppSec [baseline] (72.561 ms) : 0, 72561
AppSec [candidate] (70.49 ms) : 0, 70490
IAST [baseline] (30.003 ms) : 0, 30003
IAST [candidate] (30.068 ms) : 0, 30068
Remote Config [baseline] (837.517 µs) : 0, 838
Remote Config [candidate] (2.45 ms) : 0, 2450
Telemetry [baseline] (9.453 ms) : 0, 9453
Telemetry [candidate] (9.614 ms) : 0, 9614
section profiling
BytebuddyAgent [baseline] (992.295 ms) : 0, 992295
BytebuddyAgent [candidate] (991.386 ms) : 0, 991386
GlobalTracer [baseline] (584.686 ms) : 0, 584686
GlobalTracer [candidate] (585.282 ms) : 0, 585282
AppSec [baseline] (73.599 ms) : 0, 73599
AppSec [candidate] (73.095 ms) : 0, 73095
Remote Config [baseline] (836.788 µs) : 0, 837
Remote Config [candidate] (851.029 µs) : 0, 851
Telemetry [baseline] (9.458 ms) : 0, 9458
Telemetry [candidate] (9.478 ms) : 0, 9478
ProfilingAgent [baseline] (158.892 ms) : 0, 158892
ProfilingAgent [candidate] (157.239 ms) : 0, 157239
Profiling [baseline] (158.952 ms) : 0, 158952
Profiling [candidate] (157.301 ms) : 0, 157301
Loading
Startup time reports for insecure-bank
gantt
    title insecure-bank - global startup overhead: candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9

    dateFormat X
    axisFormat %s
section tracing
Agent [baseline] (1.571 s) : 0, 1571088
Total [baseline] (11.818 s) : 0, 11818104
Agent [candidate] (1.561 s) : 0, 1560828
Total [candidate] (11.769 s) : 0, 11768625
section iast
Agent [baseline] (1.731 s) : 0, 1730862
Total [baseline] (12.484 s) : 0, 12483505
Agent [candidate] (1.727 s) : 0, 1726993
Total [candidate] (12.513 s) : 0, 12512935
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.733 s) : 0, 1732960
Total [baseline] (12.412 s) : 0, 12412480
Agent [candidate] (1.725 s) : 0, 1725069
Total [candidate] (12.434 s) : 0, 12434499
section iast_TELEMETRY_OFF
Agent [baseline] (1.73 s) : 0, 1730180
Total [baseline] (12.446 s) : 0, 12445583
Agent [candidate] (1.72 s) : 0, 1719603
Total [candidate] (12.426 s) : 0, 12426082
Loading
  • baseline results
Module Variant Duration Δ tracing
Agent tracing 1.571 s -
Agent iast 1.731 s 159.774 ms (10.2%)
Agent iast_HARDCODED_SECRET_DISABLED 1.733 s 161.871 ms (10.3%)
Agent iast_TELEMETRY_OFF 1.73 s 159.092 ms (10.1%)
Total tracing 11.818 s -
Total iast 12.484 s 665.401 ms (5.6%)
Total iast_HARDCODED_SECRET_DISABLED 12.412 s 594.376 ms (5.0%)
Total iast_TELEMETRY_OFF 12.446 s 627.479 ms (5.3%)
  • candidate results
Module Variant Duration Δ tracing
Agent tracing 1.561 s -
Agent iast 1.727 s 166.165 ms (10.6%)
Agent iast_HARDCODED_SECRET_DISABLED 1.725 s 164.241 ms (10.5%)
Agent iast_TELEMETRY_OFF 1.72 s 158.775 ms (10.2%)
Total tracing 11.769 s -
Total iast 12.513 s 744.31 ms (6.3%)
Total iast_HARDCODED_SECRET_DISABLED 12.434 s 665.874 ms (5.7%)
Total iast_TELEMETRY_OFF 12.426 s 657.457 ms (5.6%)
gantt
    title insecure-bank - break down per module: candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9

    dateFormat X
    axisFormat %s
section tracing
BytebuddyAgent [baseline] (1.005 s) : 0, 1005445
BytebuddyAgent [candidate] (1.001 s) : 0, 1000649
GlobalTracer [baseline] (461.681 ms) : 0, 461681
GlobalTracer [candidate] (457.073 ms) : 0, 457073
AppSec [baseline] (73.293 ms) : 0, 73293
AppSec [candidate] (72.415 ms) : 0, 72415
Remote Config [baseline] (829.0 µs) : 0, 829
Remote Config [candidate] (846.197 µs) : 0, 846
Telemetry [baseline] (9.627 ms) : 0, 9627
Telemetry [candidate] (9.661 ms) : 0, 9661
section iast
BytebuddyAgent [baseline] (1.163 s) : 0, 1163143
BytebuddyAgent [candidate] (1.158 s) : 0, 1158008
GlobalTracer [baseline] (435.501 ms) : 0, 435501
GlobalTracer [candidate] (436.262 ms) : 0, 436262
AppSec [baseline] (71.888 ms) : 0, 71888
AppSec [candidate] (71.438 ms) : 0, 71438
Remote Config [baseline] (761.962 µs) : 0, 762
Remote Config [candidate] (2.553 ms) : 0, 2553
Telemetry [baseline] (9.376 ms) : 0, 9376
Telemetry [candidate] (9.493 ms) : 0, 9493
IAST [baseline] (29.923 ms) : 0, 29923
IAST [candidate] (28.952 ms) : 0, 28952
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (1.163 s) : 0, 1163271
BytebuddyAgent [candidate] (1.155 s) : 0, 1155466
GlobalTracer [baseline] (437.316 ms) : 0, 437316
GlobalTracer [candidate] (436.362 ms) : 0, 436362
AppSec [baseline] (70.901 ms) : 0, 70901
AppSec [candidate] (71.518 ms) : 0, 71518
Remote Config [baseline] (843.538 µs) : 0, 844
Remote Config [candidate] (799.882 µs) : 0, 800
Telemetry [baseline] (9.457 ms) : 0, 9457
Telemetry [candidate] (12.129 ms) : 0, 12129
IAST [baseline] (30.969 ms) : 0, 30969
IAST [candidate] (28.576 ms) : 0, 28576
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (1.16 s) : 0, 1160381
BytebuddyAgent [candidate] (1.151 s) : 0, 1151365
GlobalTracer [baseline] (437.364 ms) : 0, 437364
GlobalTracer [candidate] (436.064 ms) : 0, 436064
AppSec [baseline] (71.696 ms) : 0, 71696
AppSec [candidate] (69.657 ms) : 0, 69657
Remote Config [baseline] (756.874 µs) : 0, 757
Remote Config [candidate] (771.588 µs) : 0, 772
Telemetry [baseline] (10.971 ms) : 0, 10971
Telemetry [candidate] (12.656 ms) : 0, 12656
IAST [baseline] (28.765 ms) : 0, 28765
IAST [candidate] (28.859 ms) : 0, 28859
Loading

Load

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
end_time 2024-09-16T12:19:56 2024-09-16T12:26:45
git_branch master mtoff/span-events
git_commit_date 1726485541 1726488640
git_commit_sha c59beb4 3af7937
release_version 1.40.0-SNAPSHOT~c59beb4dc9 1.40.0-SNAPSHOT~3af7937d33
start_time 2024-09-16T12:19:42 2024-09-16T12:26:31
See matching parameters
Baseline Candidate
application insecure-bank insecure-bank
ci_job_date 1726489952 1726489952
ci_job_id 640353159 640353159
ci_pipeline_id 44403900 44403900
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 12 metrics, 16 unstable metrics.

Request duration reports for insecure-bank
gantt
    title insecure-bank - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9
    dateFormat X
    axisFormat %s
section baseline
no_agent (367.974 µs) : 348, 388
.   : milestone, 368,
iast (482.824 µs) : 462, 504
.   : milestone, 483,
iast_FULL (553.993 µs) : 533, 575
.   : milestone, 554,
iast_GLOBAL (497.331 µs) : 476, 518
.   : milestone, 497,
iast_HARDCODED_SECRET_DISABLED (482.027 µs) : 461, 503
.   : milestone, 482,
iast_INACTIVE (442.523 µs) : 422, 463
.   : milestone, 443,
iast_TELEMETRY_OFF (476.151 µs) : 454, 499
.   : milestone, 476,
tracing (435.373 µs) : 415, 455
.   : milestone, 435,
section candidate
no_agent (371.976 µs) : 353, 391
.   : milestone, 372,
iast (486.118 µs) : 464, 508
.   : milestone, 486,
iast_FULL (556.696 µs) : 536, 578
.   : milestone, 557,
iast_GLOBAL (508.242 µs) : 487, 530
.   : milestone, 508,
iast_HARDCODED_SECRET_DISABLED (485.787 µs) : 463, 508
.   : milestone, 486,
iast_INACTIVE (448.341 µs) : 428, 469
.   : milestone, 448,
iast_TELEMETRY_OFF (466.763 µs) : 444, 489
.   : milestone, 467,
tracing (444.896 µs) : 425, 465
.   : milestone, 445,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 367.974 µs [347.561 µs, 388.386 µs] -
iast 482.824 µs [461.52 µs, 504.128 µs] 114.85 µs (31.2%)
iast_FULL 553.993 µs [532.785 µs, 575.202 µs] 186.02 µs (50.6%)
iast_GLOBAL 497.331 µs [476.352 µs, 518.311 µs] 129.358 µs (35.2%)
iast_HARDCODED_SECRET_DISABLED 482.027 µs [460.927 µs, 503.128 µs] 114.054 µs (31.0%)
iast_INACTIVE 442.523 µs [422.1 µs, 462.945 µs] 74.549 µs (20.3%)
iast_TELEMETRY_OFF 476.151 µs [453.777 µs, 498.525 µs] 108.177 µs (29.4%)
tracing 435.373 µs [415.313 µs, 455.433 µs] 67.399 µs (18.3%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 371.976 µs [352.625 µs, 391.328 µs] -
iast 486.118 µs [464.269 µs, 507.967 µs] 114.142 µs (30.7%)
iast_FULL 556.696 µs [535.617 µs, 577.774 µs] 184.719 µs (49.7%)
iast_GLOBAL 508.242 µs [486.558 µs, 529.926 µs] 136.266 µs (36.6%)
iast_HARDCODED_SECRET_DISABLED 485.787 µs [463.225 µs, 508.348 µs] 113.81 µs (30.6%)
iast_INACTIVE 448.341 µs [427.87 µs, 468.813 µs] 76.365 µs (20.5%)
iast_TELEMETRY_OFF 466.763 µs [444.313 µs, 489.212 µs] 94.787 µs (25.5%)
tracing 444.896 µs [424.873 µs, 464.919 µs] 72.92 µs (19.6%)
Request duration reports for petclinic
gantt
    title petclinic - request duration [CI 0.99] : candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.35 ms) : 1331, 1369
.   : milestone, 1350,
appsec (1.706 ms) : 1681, 1731
.   : milestone, 1706,
appsec_no_iast (1.711 ms) : 1687, 1735
.   : milestone, 1711,
iast (1.483 ms) : 1460, 1506
.   : milestone, 1483,
profiling (1.48 ms) : 1457, 1503
.   : milestone, 1480,
tracing (1.459 ms) : 1433, 1484
.   : milestone, 1459,
section candidate
no_agent (1.355 ms) : 1335, 1374
.   : milestone, 1355,
appsec (1.738 ms) : 1714, 1761
.   : milestone, 1738,
appsec_no_iast (1.731 ms) : 1708, 1755
.   : milestone, 1731,
iast (1.491 ms) : 1468, 1515
.   : milestone, 1491,
profiling (1.507 ms) : 1483, 1531
.   : milestone, 1507,
tracing (1.474 ms) : 1450, 1498
.   : milestone, 1474,
Loading
  • baseline results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.35 ms [1.331 ms, 1.369 ms] -
appsec 1.706 ms [1.681 ms, 1.731 ms] 355.565 µs (26.3%)
appsec_no_iast 1.711 ms [1.687 ms, 1.735 ms] 361.165 µs (26.8%)
iast 1.483 ms [1.46 ms, 1.506 ms] 132.986 µs (9.9%)
profiling 1.48 ms [1.457 ms, 1.503 ms] 129.749 µs (9.6%)
tracing 1.459 ms [1.433 ms, 1.484 ms] 108.659 µs (8.0%)
  • candidate results
Variant Request duration [CI 0.99] Δ no_agent
no_agent 1.355 ms [1.335 ms, 1.374 ms] -
appsec 1.738 ms [1.714 ms, 1.761 ms] 382.882 µs (28.3%)
appsec_no_iast 1.731 ms [1.708 ms, 1.755 ms] 376.76 µs (27.8%)
iast 1.491 ms [1.468 ms, 1.515 ms] 136.713 µs (10.1%)
profiling 1.507 ms [1.483 ms, 1.531 ms] 152.183 µs (11.2%)
tracing 1.474 ms [1.45 ms, 1.498 ms] 119.451 µs (8.8%)

Dacapo

Parameters

Baseline Candidate
baseline_or_candidate baseline candidate
git_branch master mtoff/span-events
git_commit_date 1726485541 1726488640
git_commit_sha c59beb4 3af7937
release_version 1.40.0-SNAPSHOT~c59beb4dc9 1.40.0-SNAPSHOT~3af7937d33
See matching parameters
Baseline Candidate
application biojava biojava
ci_job_date 1726490626 1726490626
ci_job_id 640353163 640353163
ci_pipeline_id 44403900 44403900
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 tomcat
gantt
    title tomcat - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9
    dateFormat X
    axisFormat %s
section baseline
no_agent (1.459 ms) : 1448, 1470
.   : milestone, 1459,
appsec (2.282 ms) : 2242, 2323
.   : milestone, 2282,
iast (2.037 ms) : 1988, 2086
.   : milestone, 2037,
iast_GLOBAL (2.096 ms) : 2045, 2148
.   : milestone, 2096,
profiling (1.917 ms) : 1877, 1957
.   : milestone, 1917,
tracing (1.896 ms) : 1858, 1935
.   : milestone, 1896,
section candidate
no_agent (1.459 ms) : 1448, 1471
.   : milestone, 1459,
appsec (2.285 ms) : 2244, 2326
.   : milestone, 2285,
iast (2.024 ms) : 1976, 2073
.   : milestone, 2024,
iast_GLOBAL (2.091 ms) : 2040, 2141
.   : milestone, 2091,
profiling (1.906 ms) : 1865, 1946
.   : milestone, 1906,
tracing (1.898 ms) : 1859, 1936
.   : milestone, 1898,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.459 ms [1.448 ms, 1.47 ms] -
appsec 2.282 ms [2.242 ms, 2.323 ms] 823.363 µs (56.4%)
iast 2.037 ms [1.988 ms, 2.086 ms] 578.29 µs (39.6%)
iast_GLOBAL 2.096 ms [2.045 ms, 2.148 ms] 637.451 µs (43.7%)
profiling 1.917 ms [1.877 ms, 1.957 ms] 457.887 µs (31.4%)
tracing 1.896 ms [1.858 ms, 1.935 ms] 437.515 µs (30.0%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 1.459 ms [1.448 ms, 1.471 ms] -
appsec 2.285 ms [2.244 ms, 2.326 ms] 825.597 µs (56.6%)
iast 2.024 ms [1.976 ms, 2.073 ms] 565.122 µs (38.7%)
iast_GLOBAL 2.091 ms [2.04 ms, 2.141 ms] 631.38 µs (43.3%)
profiling 1.906 ms [1.865 ms, 1.946 ms] 446.441 µs (30.6%)
tracing 1.898 ms [1.859 ms, 1.936 ms] 438.51 µs (30.0%)
Execution time for biojava
gantt
    title biojava - execution time [CI 0.99] : candidate=1.40.0-SNAPSHOT~3af7937d33, baseline=1.40.0-SNAPSHOT~c59beb4dc9
    dateFormat X
    axisFormat %s
section baseline
no_agent (15.025 s) : 15025000, 15025000
.   : milestone, 15025000,
appsec (15.205 s) : 15205000, 15205000
.   : milestone, 15205000,
iast (18.762 s) : 18762000, 18762000
.   : milestone, 18762000,
iast_GLOBAL (17.924 s) : 17924000, 17924000
.   : milestone, 17924000,
profiling (15.506 s) : 15506000, 15506000
.   : milestone, 15506000,
tracing (14.861 s) : 14861000, 14861000
.   : milestone, 14861000,
section candidate
no_agent (14.825 s) : 14825000, 14825000
.   : milestone, 14825000,
appsec (15.196 s) : 15196000, 15196000
.   : milestone, 15196000,
iast (19.129 s) : 19129000, 19129000
.   : milestone, 19129000,
iast_GLOBAL (18.109 s) : 18109000, 18109000
.   : milestone, 18109000,
profiling (15.071 s) : 15071000, 15071000
.   : milestone, 15071000,
tracing (15.189 s) : 15189000, 15189000
.   : milestone, 15189000,
Loading
  • baseline results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 15.025 s [15.025 s, 15.025 s] -
appsec 15.205 s [15.205 s, 15.205 s] 180.0 ms (1.2%)
iast 18.762 s [18.762 s, 18.762 s] 3.737 s (24.9%)
iast_GLOBAL 17.924 s [17.924 s, 17.924 s] 2.899 s (19.3%)
profiling 15.506 s [15.506 s, 15.506 s] 481.0 ms (3.2%)
tracing 14.861 s [14.861 s, 14.861 s] -164.0 ms (-1.1%)
  • candidate results
Variant Execution Time [CI 0.99] Δ no_agent
no_agent 14.825 s [14.825 s, 14.825 s] -
appsec 15.196 s [15.196 s, 15.196 s] 371.0 ms (2.5%)
iast 19.129 s [19.129 s, 19.129 s] 4.304 s (29.0%)
iast_GLOBAL 18.109 s [18.109 s, 18.109 s] 3.284 s (22.2%)
profiling 15.071 s [15.071 s, 15.071 s] 246.0 ms (1.7%)
tracing 15.189 s [15.189 s, 15.189 s] 364.0 ms (2.5%)

Comment on lines 33 to 53
public String toString() {
// TODO if attributes exist, process those
return "{\"name\":\""
+ this.name
+ "\",\"time_unix_nano\":"
+ Long.toString(this.timestamp)
+ "}";
}

// @NotNull
// TODO: give this a notnull annotation
public static String toTag(List<OtelSpanEvent> events) {
StringBuilder builder = new StringBuilder("[");
for (int i = 0; i < events.size(); i++) {
if (i > 0) {
builder.append(",");
}
builder.append(events.get(i).toString());
}
return builder.append("]").toString();
}
Copy link
Contributor

@PerfectSlayer PerfectSlayer Aug 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't check at the RFC yet but this looks like JSON.
Rather than try to avoid any conversion issue, like escaping double quote from attribute name, what about reusing the JsonBuffer that @dougqh is building in bootstrap?

https://github.com/DataDog/dd-trace-java/pull/7287/files#diff-519b444cb8473a52b363e23131006a599b0fc5c0d9968d0934ef9b59a785872d

Or maybe simply use Moshi: implementation libs.moshi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerfectSlayer unfortunately we can't use moshi directly because of where this code ends up in the final jar (and how it gets injected into the user's application) - given the JSON output is straightforward I'd suggest manually encoding it, as before, or re-using the JsonBuffer from Doug's PR (we'd need to decide what's the best place to host that code)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that’s what I though and why I propose Doug’s code in the first place.
We can find a proper place and add some tests to promote it as a resuable piece of code 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PerfectSlayer , Stuart and I discussed just using the manual parsing method I had initially, and to migrate the code to use Doug's parser once that's been merged (so as not to block this PR)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now, my JsonBuffer is only in the bootstrap, but we could make it available elsewhere, too.

I'm also open to modifying it to having a template mode, so we can prebuild most of the structure and reuse.
It also already has a mechanism to put multiple buffers together if that would be of use here.

StringBuilder builder = new StringBuilder("[");
int index = 0;
while (index < events.size()) {
String linkAsJson = getEncoder().toJson(events.get(index));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above we can avoid the moshi dependency if we wrote out own method(s) to write span event data as JSON. The structure is simple, so this shouldn't involve much code. Also we only need to handle writing JSON, not parsing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question I have is what the RFC states about encoding when reaching tag max length?
Should the tracer take care of it? Should we limit event count or drop attributes?
Because if the tag value is cropped, I don’t know what will happen on the backend side with invalid JSON object 🤷

Copy link
Contributor Author

@mtoffl01 mtoffl01 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RFC does not specify any limits, however:

  1. Otel Span Events API does not specify any limits on span event count
  2. However, Otel does enforce a [default limit of 128 span events per span and a maximum of 128 attributes per span event](Span Events, they include a default of 128 maximum span events per span and a maximum of 128 attributes per span event) within the SDK
  3. Our implementation of Span Links enforces a character limit with TAG_MAX_LENGTH

@mtoffl01 mtoffl01 requested a review from a team as a code owner September 3, 2024 20:58
@mtoffl01
Copy link
Contributor Author

mtoffl01 commented Sep 5, 2024

Note: Test coverage is failing for SpanAttributes.Builder and SpanAttributes.JSONParser, but I'm confused by the results. The Opentelemetry14Test tests for adding events do utilize the builder and JSONParser, and when I run a test with coverage, we can see green on convertAttributes functionality that calls on SpanAttributes.Builder functionality, but the relevant SpanAttributes.Builder blocks are labeled with red.
2024-09-05_11-36-05

Copy link
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly focused on the OTel part and left a bunch of comments (sorry for that 😓 ).

In addition, I don't think we should reuse the span attributes for the event attributes.
Encoding and handling are not the same, and the introduced format impact nearly every single behavior (all except than String handling).

As span events are not a thing outside OpenTelemetry, they should not impact the Span.Attributes class nor the core part. I would advocate for creating a SpanEvent.Attribute class to handle this specifically for OTel and revert any change to internal-api and core.

How do you feel about it?

@mtoffl01 mtoffl01 marked this pull request as draft September 12, 2024 01:51
@mtoffl01 mtoffl01 marked this pull request as ready for review September 13, 2024 14:08
Move convention related span event handling to OtelConventions
Move span event related logic to OtelSpanEvent
Add OTel attributes cache for performance
Add comment about nullable field
Rename OtelSpanEvent from toString to toJson to avoid confusion with Java Object semantic
Add OtelSpanEvent toString method for debugging
Add OtelSpanEvent recordException test cases
Improve JSON encoding to use buffer length and char append when possible
Rename AttributeJsonParser to follow Java naming conventions
Clean up Javadoc
Add test to check events behavior after span end
Simplify expected JSON building
Remove custom time source when not needed
Used tag name from constants
Ensure span close
Improve time API usage
Fix expected JSON keys
Copy link
Contributor

@PerfectSlayer PerfectSlayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current limitations are:

  • TimeSource is not fetch from CoreTracer
  • JSON encoding is manual and not Moshi based (as currently not opened to instrumentations)

But overall, it's good to merge 👍

@mtoffl01 mtoffl01 merged commit a420d2c into master Sep 16, 2024
98 checks passed
@mtoffl01 mtoffl01 deleted the mtoff/span-events branch September 16, 2024 16:08
@github-actions github-actions bot added this to the 1.40.0 milestone Sep 16, 2024
@PerfectSlayer PerfectSlayer added type: enhancement inst: opentelemetry OpenTelemetry instrumentation labels Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inst: opentelemetry OpenTelemetry instrumentation type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants