-
Notifications
You must be signed in to change notification settings - Fork 279
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
Append sql comments instead of prepend to prevent exceptions on CallableStatements #6034
Conversation
BenchmarksStartupParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 53 cases.
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.021 s) : 0, 1020681
Total [baseline] (8.723 s) : 0, 8722798
Agent [candidate] (1.022 s) : 0, 1022417
Total [candidate] (8.703 s) : 0, 8703462
section iast
Agent [baseline] (1.169 s) : 0, 1169430
Total [baseline] (9.307 s) : 0, 9307292
Agent [candidate] (1.145 s) : 0, 1144817
Total [candidate] (9.293 s) : 0, 9293410
section iast_TELEMETRY_OFF
Agent [baseline] (1.149 s) : 0, 1148620
Total [baseline] (9.232 s) : 0, 9231836
Agent [candidate] (1.145 s) : 0, 1145254
Total [candidate] (9.214 s) : 0, 9213527
gantt
title insecure-bank - break down per module: candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (637.994 ms) : 0, 637994
BytebuddyAgent [candidate] (638.807 ms) : 0, 638807
GlobalTracer [baseline] (292.796 ms) : 0, 292796
GlobalTracer [candidate] (293.123 ms) : 0, 293123
AppSec [baseline] (48.803 ms) : 0, 48803
AppSec [candidate] (49.335 ms) : 0, 49335
Remote Config [baseline] (676.352 µs) : 0, 676
Remote Config [candidate] (679.334 µs) : 0, 679
Telemetry [baseline] (5.989 ms) : 0, 5989
Telemetry [candidate] (6.085 ms) : 0, 6085
section iast
BytebuddyAgent [baseline] (784.072 ms) : 0, 784072
BytebuddyAgent [candidate] (766.497 ms) : 0, 766497
GlobalTracer [baseline] (276.535 ms) : 0, 276535
GlobalTracer [candidate] (272.11 ms) : 0, 272110
AppSec [baseline] (47.23 ms) : 0, 47230
AppSec [candidate] (47.681 ms) : 0, 47681
IAST [baseline] (15.566 ms) : 0, 15566
IAST [candidate] (15.903 ms) : 0, 15903
Remote Config [baseline] (601.676 µs) : 0, 602
Remote Config [candidate] (581.494 µs) : 0, 581
Telemetry [baseline] (10.401 ms) : 0, 10401
Telemetry [candidate] (7.567 ms) : 0, 7567
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (766.29 ms) : 0, 766290
BytebuddyAgent [candidate] (764.27 ms) : 0, 764270
GlobalTracer [baseline] (274.764 ms) : 0, 274764
GlobalTracer [candidate] (273.999 ms) : 0, 273999
AppSec [baseline] (46.38 ms) : 0, 46380
AppSec [candidate] (46.593 ms) : 0, 46593
IAST [baseline] (17.686 ms) : 0, 17686
IAST [candidate] (19.735 ms) : 0, 19735
Remote Config [baseline] (664.856 µs) : 0, 665
Remote Config [candidate] (659.006 µs) : 0, 659
Telemetry [baseline] (8.186 ms) : 0, 8186
Telemetry [candidate] (5.421 ms) : 0, 5421
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.023 s) : 0, 1022704
Total [baseline] (9.363 s) : 0, 9362823
Agent [candidate] (1.021 s) : 0, 1020700
Total [candidate] (9.243 s) : 0, 9243080
section appsec
Agent [baseline] (1.107 s) : 0, 1107420
Total [baseline] (9.276 s) : 0, 9275934
Agent [candidate] (1.107 s) : 0, 1107478
Total [candidate] (9.302 s) : 0, 9302145
section iast
Agent [baseline] (1.153 s) : 0, 1153079
Total [baseline] (9.409 s) : 0, 9408722
Agent [candidate] (1.146 s) : 0, 1145506
Total [candidate] (9.383 s) : 0, 9382583
section profiling
Agent [baseline] (1.199 s) : 0, 1198942
Total [baseline] (9.524 s) : 0, 9523941
Agent [candidate] (1.195 s) : 0, 1194545
Total [candidate] (9.522 s) : 0, 9521547
gantt
title petclinic - break down per module: candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (638.583 ms) : 0, 638583
BytebuddyAgent [candidate] (637.405 ms) : 0, 637405
GlobalTracer [baseline] (293.53 ms) : 0, 293530
GlobalTracer [candidate] (293.211 ms) : 0, 293211
AppSec [baseline] (49.304 ms) : 0, 49304
AppSec [candidate] (49.039 ms) : 0, 49039
Remote Config [baseline] (689.277 µs) : 0, 689
Remote Config [candidate] (687.56 µs) : 0, 688
Telemetry [baseline] (6.114 ms) : 0, 6114
Telemetry [candidate] (6.093 ms) : 0, 6093
section appsec
BytebuddyAgent [baseline] (637.702 ms) : 0, 637702
BytebuddyAgent [candidate] (637.28 ms) : 0, 637280
GlobalTracer [baseline] (291.423 ms) : 0, 291423
GlobalTracer [candidate] (291.472 ms) : 0, 291472
AppSec [baseline] (137.704 ms) : 0, 137704
AppSec [candidate] (138.114 ms) : 0, 138114
Remote Config [baseline] (637.859 µs) : 0, 638
Remote Config [candidate] (639.386 µs) : 0, 639
Telemetry [baseline] (5.66 ms) : 0, 5660
Telemetry [candidate] (5.679 ms) : 0, 5679
section iast
BytebuddyAgent [baseline] (772.459 ms) : 0, 772459
BytebuddyAgent [candidate] (767.029 ms) : 0, 767029
GlobalTracer [baseline] (273.111 ms) : 0, 273111
GlobalTracer [candidate] (271.686 ms) : 0, 271686
AppSec [baseline] (46.524 ms) : 0, 46524
AppSec [candidate] (46.82 ms) : 0, 46820
Remote Config [baseline] (593.728 µs) : 0, 594
Remote Config [candidate] (606.696 µs) : 0, 607
Telemetry [baseline] (9.14 ms) : 0, 9140
Telemetry [candidate] (7.569 ms) : 0, 7569
IAST [baseline] (16.668 ms) : 0, 16668
IAST [candidate] (17.367 ms) : 0, 17367
section profiling
ProfilingAgent [baseline] (80.537 ms) : 0, 80537
ProfilingAgent [candidate] (80.713 ms) : 0, 80713
BytebuddyAgent [baseline] (651.996 ms) : 0, 651996
BytebuddyAgent [candidate] (649.232 ms) : 0, 649232
GlobalTracer [baseline] (356.888 ms) : 0, 356888
GlobalTracer [candidate] (355.502 ms) : 0, 355502
AppSec [baseline] (49.225 ms) : 0, 49225
AppSec [candidate] (49.264 ms) : 0, 49264
Remote Config [baseline] (672.399 µs) : 0, 672
Remote Config [candidate] (643.932 µs) : 0, 644
Telemetry [baseline] (6.068 ms) : 0, 6068
Telemetry [candidate] (6.044 ms) : 0, 6044
Profiling [baseline] (80.561 ms) : 0, 80561
Profiling [candidate] (80.737 ms) : 0, 80737
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 22 cases. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section baseline
no_agent (369.718 µs) : 349, 390
. : milestone, 370,
iast (465.633 µs) : 445, 487
. : milestone, 466,
iast_FULL (521.923 µs) : 501, 543
. : milestone, 522,
iast_INACTIVE (440.486 µs) : 419, 462
. : milestone, 440,
iast_TELEMETRY_OFF (458.891 µs) : 437, 481
. : milestone, 459,
tracing (441.618 µs) : 420, 463
. : milestone, 442,
section candidate
no_agent (366.171 µs) : 346, 386
. : milestone, 366,
iast (470.737 µs) : 450, 492
. : milestone, 471,
iast_FULL (523.371 µs) : 503, 544
. : milestone, 523,
iast_INACTIVE (435.542 µs) : 415, 456
. : milestone, 436,
iast_TELEMETRY_OFF (466.913 µs) : 446, 488
. : milestone, 467,
tracing (439.293 µs) : 418, 460
. : milestone, 439,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.22.0-SNAPSHOT~3bc270d4db, baseline=1.22.0-SNAPSHOT~848d3775b0
dateFormat X
axisFormat %s
section baseline
no_agent (1.338 ms) : 1319, 1358
. : milestone, 1338,
appsec (1.709 ms) : 1684, 1734
. : milestone, 1709,
iast (1.459 ms) : 1435, 1484
. : milestone, 1459,
profiling (1.444 ms) : 1420, 1469
. : milestone, 1444,
tracing (1.427 ms) : 1403, 1452
. : milestone, 1427,
section candidate
no_agent (1.326 ms) : 1307, 1345
. : milestone, 1326,
appsec (1.705 ms) : 1681, 1729
. : milestone, 1705,
iast (1.489 ms) : 1465, 1514
. : milestone, 1489,
profiling (1.495 ms) : 1470, 1520
. : milestone, 1495,
tracing (1.452 ms) : 1428, 1476
. : milestone, 1452,
|
497349c
to
07d5287
Compare
Looks like the tests failures aren't related to my PR?
... although I'm not sure why this is failing now:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Except for integrations-core
. If it wasn't updated on purpose then follow https://github.com/DataDog/dd-trace-java/blob/master/CONTRIBUTING.md#git-submodule-setup to exclude it from the change.
07d5287
to
4232f80
Compare
@ygree ah okay, I ran |
4232f80
to
d6fec03
Compare
Looks like |
f3180de
to
9f52442
Compare
9f52442
to
3bc270d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
What Does This Do
This PR updates the logic for the APM-DBM link feature introduced in #4847. It changes from prepending the sql comments, containing the APM trace context, to appending them to the raw sql. This requires no changes on the DBM side of things in either the agent or our backend.
Jira ticket: DBMON-2759
Motivation
This fixes an issue, which has been reported by several customers that executing
CallableStatement
s with the following syntax causes exceptions to be thrown when enabling APM-DBM link:We were able to reproduce this, using the latest version of the java tracer && an internal application. It seems to be caused by the SQL comments we inject being prepended instead of appended. For example, the issue of prepending the comment was reproduced with a simple java application (without APM-DBM link enabled), which did the following:
... this throws the same exception with message
Incorrect syntax near '{'.
Proof of Fix
After doing a custom build of this tracer code, we deployed our test app, which runs a combination of
PreparedStatement
/Statements
/CallableStatement
& no longer saw theIncorrect syntax near '{'.
exception being thrown.We were also able to confirm that injection is still working properly, e.g: our events are being properly decorated:
Expected DBM Behavior for Stored Procedures
Stored Procedures aren't supported for the APM-DBM usecase (unless the same app that is calling them is the thing that created the stored procedure & the linking was enabled). Otherwise, we wouldn't see the comments if someone had code that was simply calling
EXEC proc
or{call proc}
, since the actual text we see in the activity code is either:Neither, contains the text
EXEC proc
, which is what would have the comment injected via the tracer.Obviously, this is of secondary concern here. Updating the tracer to append the comment will fix this edge case being reported by customers. We really don't want the feature to cause users to see exceptions being thrown in their production code.