-
Notifications
You must be signed in to change notification settings - Fork 292
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
Full mode for SQL Server #7186
Full mode for SQL Server #7186
Conversation
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 15 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.052 s) : 0, 1052061
Total [baseline] (10.313 s) : 0, 10313273
Agent [candidate] (1.05 s) : 0, 1049807
Total [candidate] (10.291 s) : 0, 10291061
section appsec
Agent [baseline] (1.169 s) : 0, 1169259
Total [baseline] (10.547 s) : 0, 10546531
Agent [candidate] (1.165 s) : 0, 1165355
Total [candidate] (10.468 s) : 0, 10468177
section iast
Agent [baseline] (1.175 s) : 0, 1175004
Total [baseline] (10.734 s) : 0, 10733811
Agent [candidate] (1.171 s) : 0, 1170662
Total [candidate] (10.834 s) : 0, 10834359
section profiling
Agent [baseline] (1.254 s) : 0, 1254473
Total [baseline] (10.629 s) : 0, 10628669
Agent [candidate] (1.244 s) : 0, 1244105
Total [candidate] (10.625 s) : 0, 10625398
gantt
title petclinic - break down per module: candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (672.025 ms) : 0, 672025
BytebuddyAgent [candidate] (671.191 ms) : 0, 671191
GlobalTracer [baseline] (308.231 ms) : 0, 308231
GlobalTracer [candidate] (306.664 ms) : 0, 306664
AppSec [baseline] (50.356 ms) : 0, 50356
AppSec [candidate] (50.352 ms) : 0, 50352
Remote Config [baseline] (686.741 µs) : 0, 687
Remote Config [candidate] (691.809 µs) : 0, 692
Telemetry [baseline] (7.254 ms) : 0, 7254
Telemetry [candidate] (7.394 ms) : 0, 7394
section appsec
BytebuddyAgent [baseline] (680.752 ms) : 0, 680752
BytebuddyAgent [candidate] (678.205 ms) : 0, 678205
GlobalTracer [baseline] (301.149 ms) : 0, 301149
GlobalTracer [candidate] (299.037 ms) : 0, 299037
AppSec [baseline] (155.253 ms) : 0, 155253
AppSec [candidate] (155.319 ms) : 0, 155319
Remote Config [baseline] (607.987 µs) : 0, 608
Remote Config [candidate] (599.979 µs) : 0, 600
Telemetry [baseline] (7.269 ms) : 0, 7269
Telemetry [candidate] (7.602 ms) : 0, 7602
IAST [baseline] (21.406 ms) : 0, 21406
IAST [candidate] (22.138 ms) : 0, 22138
section iast
BytebuddyAgent [baseline] (782.807 ms) : 0, 782807
BytebuddyAgent [candidate] (780.715 ms) : 0, 780715
GlobalTracer [baseline] (295.776 ms) : 0, 295776
GlobalTracer [candidate] (294.968 ms) : 0, 294968
AppSec [baseline] (51.464 ms) : 0, 51464
AppSec [candidate] (51.113 ms) : 0, 51113
Remote Config [baseline] (572.789 µs) : 0, 573
Remote Config [candidate] (589.96 µs) : 0, 590
Telemetry [baseline] (7.822 ms) : 0, 7822
Telemetry [candidate] (7.023 ms) : 0, 7023
IAST [baseline] (23.092 ms) : 0, 23092
IAST [candidate] (22.742 ms) : 0, 22742
section profiling
BytebuddyAgent [baseline] (668.835 ms) : 0, 668835
BytebuddyAgent [candidate] (663.661 ms) : 0, 663661
GlobalTracer [baseline] (393.06 ms) : 0, 393060
GlobalTracer [candidate] (389.084 ms) : 0, 389084
AppSec [baseline] (51.844 ms) : 0, 51844
AppSec [candidate] (51.287 ms) : 0, 51287
Remote Config [baseline] (695.527 µs) : 0, 696
Remote Config [candidate] (693.696 µs) : 0, 694
Telemetry [baseline] (7.318 ms) : 0, 7318
Telemetry [candidate] (7.252 ms) : 0, 7252
ProfilingAgent [baseline] (95.278 ms) : 0, 95278
ProfilingAgent [candidate] (94.925 ms) : 0, 94925
Profiling [baseline] (95.303 ms) : 0, 95303
Profiling [candidate] (94.95 ms) : 0, 94950
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.057 s) : 0, 1056899
Total [baseline] (8.527 s) : 0, 8526787
Agent [candidate] (1.044 s) : 0, 1044020
Total [candidate] (8.467 s) : 0, 8467492
section iast
Agent [baseline] (1.177 s) : 0, 1176579
Total [baseline] (9.024 s) : 0, 9024099
Agent [candidate] (1.185 s) : 0, 1184919
Total [candidate] (9.02 s) : 0, 9020227
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.177 s) : 0, 1176681
Total [baseline] (8.944 s) : 0, 8943977
Agent [candidate] (1.185 s) : 0, 1184686
Total [candidate] (8.985 s) : 0, 8984587
section iast_TELEMETRY_OFF
Agent [baseline] (1.173 s) : 0, 1172575
Total [baseline] (8.991 s) : 0, 8991466
Agent [candidate] (1.175 s) : 0, 1175423
Total [candidate] (8.951 s) : 0, 8951168
gantt
title insecure-bank - break down per module: candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (673.877 ms) : 0, 673877
BytebuddyAgent [candidate] (666.785 ms) : 0, 666785
GlobalTracer [baseline] (310.497 ms) : 0, 310497
GlobalTracer [candidate] (305.623 ms) : 0, 305623
AppSec [baseline] (50.895 ms) : 0, 50895
AppSec [candidate] (50.221 ms) : 0, 50221
Remote Config [baseline] (704.639 µs) : 0, 705
Remote Config [candidate] (679.07 µs) : 0, 679
Telemetry [baseline] (7.428 ms) : 0, 7428
Telemetry [candidate] (7.286 ms) : 0, 7286
section iast
BytebuddyAgent [baseline] (782.994 ms) : 0, 782994
BytebuddyAgent [candidate] (792.132 ms) : 0, 792132
GlobalTracer [baseline] (296.76 ms) : 0, 296760
GlobalTracer [candidate] (296.537 ms) : 0, 296537
AppSec [baseline] (52.592 ms) : 0, 52592
AppSec [candidate] (52.576 ms) : 0, 52576
IAST [baseline] (22.524 ms) : 0, 22524
IAST [candidate] (22.422 ms) : 0, 22422
Remote Config [baseline] (564.092 µs) : 0, 564
Remote Config [candidate] (581.459 µs) : 0, 581
Telemetry [baseline] (7.652 ms) : 0, 7652
Telemetry [candidate] (7.019 ms) : 0, 7019
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (783.017 ms) : 0, 783017
BytebuddyAgent [candidate] (788.549 ms) : 0, 788549
GlobalTracer [baseline] (297.035 ms) : 0, 297035
GlobalTracer [candidate] (299.099 ms) : 0, 299099
AppSec [baseline] (49.966 ms) : 0, 49966
AppSec [candidate] (51.102 ms) : 0, 51102
IAST [baseline] (24.785 ms) : 0, 24785
IAST [candidate] (23.848 ms) : 0, 23848
Remote Config [baseline] (591.78 µs) : 0, 592
Remote Config [candidate] (1.324 ms) : 0, 1324
Telemetry [baseline] (7.781 ms) : 0, 7781
Telemetry [candidate] (7.144 ms) : 0, 7144
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (780.402 ms) : 0, 780402
BytebuddyAgent [candidate] (784.287 ms) : 0, 784287
GlobalTracer [baseline] (297.03 ms) : 0, 297030
GlobalTracer [candidate] (297.033 ms) : 0, 297033
AppSec [baseline] (46.746 ms) : 0, 46746
AppSec [candidate] (47.092 ms) : 0, 47092
IAST [baseline] (26.691 ms) : 0, 26691
IAST [candidate] (25.952 ms) : 0, 25952
Remote Config [baseline] (602.53 µs) : 0, 603
Remote Config [candidate] (610.234 µs) : 0, 610
Telemetry [baseline] (7.611 ms) : 0, 7611
Telemetry [candidate] (6.882 ms) : 0, 6882
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 6 metrics, 22 unstable metrics. Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section baseline
no_agent (444.242 µs) : 415, 473
. : milestone, 444,
iast (596.361 µs) : 564, 628
. : milestone, 596,
iast_FULL (680.72 µs) : 647, 714
. : milestone, 681,
iast_GLOBAL (614.06 µs) : 581, 647
. : milestone, 614,
iast_HARDCODED_SECRET_DISABLED (581.218 µs) : 550, 613
. : milestone, 581,
iast_INACTIVE (551.248 µs) : 518, 584
. : milestone, 551,
iast_TELEMETRY_OFF (583.858 µs) : 552, 616
. : milestone, 584,
tracing (534.777 µs) : 505, 564
. : milestone, 535,
section candidate
no_agent (448.094 µs) : 419, 477
. : milestone, 448,
iast (587.342 µs) : 555, 619
. : milestone, 587,
iast_FULL (686.557 µs) : 654, 719
. : milestone, 687,
iast_GLOBAL (617.216 µs) : 585, 649
. : milestone, 617,
iast_HARDCODED_SECRET_DISABLED (583.248 µs) : 552, 615
. : milestone, 583,
iast_INACTIVE (552.342 µs) : 521, 584
. : milestone, 552,
iast_TELEMETRY_OFF (582.881 µs) : 551, 614
. : milestone, 583,
tracing (545.357 µs) : 515, 575
. : milestone, 545,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section baseline
no_agent (1.709 ms) : 1685, 1734
. : milestone, 1709,
appsec (2.153 ms) : 2123, 2184
. : milestone, 2153,
appsec_no_iast (2.174 ms) : 2142, 2206
. : milestone, 2174,
iast (1.844 ms) : 1814, 1874
. : milestone, 1844,
profiling (1.889 ms) : 1858, 1921
. : milestone, 1889,
tracing (1.845 ms) : 1814, 1876
. : milestone, 1845,
section candidate
no_agent (1.719 ms) : 1694, 1743
. : milestone, 1719,
appsec (2.137 ms) : 2105, 2168
. : milestone, 2137,
appsec_no_iast (2.155 ms) : 2123, 2186
. : milestone, 2155,
iast (1.909 ms) : 1880, 1939
. : milestone, 1909,
profiling (1.881 ms) : 1849, 1913
. : milestone, 1881,
tracing (1.866 ms) : 1832, 1899
. : milestone, 1866,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 0 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section baseline
no_agent (1.537 ms) : 1525, 1550
. : milestone, 1537,
appsec (2.704 ms) : 2642, 2766
. : milestone, 2704,
iast (2.365 ms) : 2291, 2439
. : milestone, 2365,
iast_GLOBAL (2.427 ms) : 2351, 2502
. : milestone, 2427,
profiling (2.229 ms) : 2167, 2292
. : milestone, 2229,
tracing (2.18 ms) : 2120, 2240
. : milestone, 2180,
section candidate
no_agent (1.541 ms) : 1528, 1554
. : milestone, 1541,
appsec (2.713 ms) : 2651, 2775
. : milestone, 2713,
iast (2.328 ms) : 2256, 2399
. : milestone, 2328,
iast_GLOBAL (2.407 ms) : 2333, 2481
. : milestone, 2407,
profiling (2.242 ms) : 2177, 2307
. : milestone, 2242,
tracing (2.17 ms) : 2112, 2229
. : milestone, 2170,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.39.0-SNAPSHOT~c3e9fa9bab, baseline=1.39.0-SNAPSHOT~567c4e978d
dateFormat X
axisFormat %s
section baseline
no_agent (20.308 s) : 20308000, 20308000
. : milestone, 20308000,
appsec (21.282 s) : 21282000, 21282000
. : milestone, 21282000,
iast (24.463 s) : 24463000, 24463000
. : milestone, 24463000,
iast_GLOBAL (25.152 s) : 25152000, 25152000
. : milestone, 25152000,
profiling (20.492 s) : 20492000, 20492000
. : milestone, 20492000,
tracing (20.926 s) : 20926000, 20926000
. : milestone, 20926000,
section candidate
no_agent (20.644 s) : 20644000, 20644000
. : milestone, 20644000,
appsec (21.659 s) : 21659000, 21659000
. : milestone, 21659000,
iast (24.275 s) : 24275000, 24275000
. : milestone, 24275000,
iast_GLOBAL (25.172 s) : 25172000, 25172000
. : milestone, 25172000,
profiling (20.9 s) : 20900000, 20900000
. : milestone, 20900000,
tracing (21.376 s) : 21376000, 21376000
. : milestone, 21376000,
|
4d0aa82
to
87f47d8
Compare
...c/src/main/java/datadog/trace/instrumentation/jdbc/SQLServerPreparedStatementExcecution.java
Outdated
Show resolved
Hide resolved
...c/src/main/java/datadog/trace/instrumentation/jdbc/SQLServerPreparedStatementExcecution.java
Outdated
Show resolved
Hide resolved
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
fbd65dd
to
e8008cf
Compare
...c/main/java/datadog/trace/instrumentation/jdbc/AbstractPreparedStatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Show resolved
Hide resolved
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...c/main/java/datadog/trace/instrumentation/jdbc/AbstractPreparedStatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
dd-java-agent/instrumentation/jdbc/src/test/groovy/SQLServerTest.groovy
Outdated
Show resolved
Hide resolved
5ede329
to
16c3197
Compare
...c/main/java/datadog/trace/instrumentation/jdbc/AbstractPreparedStatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
...entation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/StatementInstrumentation.java
Outdated
Show resolved
Hide resolved
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.
LGTM
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
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.
Overall, design is okay.
However, there are injection vulnerabilities and resource leaks that need to be addressed.
606a9be
to
70721bc
Compare
Fixed now. |
note that when you force-push, it makes it hard to review what was changed since the last comment. |
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
Got it & will do it next time. |
Ok, there are still strings being converted to byte arrays, but honestly I think it's OK. Doug still has a blocking "change requested" btw |
ok, i pushed the change to write all the values directly to the stream now. thus, i completely eliminated string conversions. |
e); | ||
DECORATE.onError(instrumentationSpan, e); | ||
} finally { | ||
if (instrumentationStatement != null) { |
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.
If you create a smaller try / finally just around instrumentationStatement, then you won't need the null handling.
But that's a bit of a matter of preference
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.
I believe we need then another try/catch/finally block, as the code before instrumentationStatement = connection.prepareStatement(instrumentationSql);
also can throw exceptions we want to log. This would make the code more verbose. The current approach with the ugly (instrumentationStatement != null)
check seems less problematic. What do you prefer?
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.
My preference is usually that there's a tight try / finally with the resource acquisition just before the try and the resource disposed of by itself in the finally. This code is mixing the handling of two different resources into the one try / finally structure which can be hard to follow.
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Outdated
Show resolved
Hide resolved
...ent/instrumentation/jdbc/src/main/java/datadog/trace/instrumentation/jdbc/JDBCDecorator.java
Show resolved
Hide resolved
} catch (SQLException e) { | ||
} | ||
} | ||
instrumentationSpan.finish(); |
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.
Ideally, finish needs to be in a finally block.
If close raises anything other than a SQLException, the span isn't being finished.
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.
Can I change } catch (SQLException e) {
to } catch (Exception e) {
, and leave instrumentationSpan.finish();
where it is, instead? A (small) advantage would be to avoid nesting.
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.
fixed as described above
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.
No, it has to be a finally block. catch ( Exception e ) doesn't catch everything, since there are other classes of Throwables.
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.
I opened a separate PR for this.
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.
An issue remains where the span may not be properly closed, that should be fixed before this change is checked in.
There's also room for improving the allocation to be lighter, but that's less crucial.
I've gone ahead and approved with the expectation that the span finish problem will be fixed.
## Summary of changes Adding support for `Full` propagation mode for SQL Server when using DSM. DSM has 3 modes: disabled, service and full. Service means that we inject info about the service who sent the query Full means Service + trace ID and span ID. ## Reason for change We used to forbid Full mode for sql server because it uses a cache of query text -> execution plan, and injecting with comments like we did before would break the cache. (injecting service is OK because it doesn't change much, so the cache is still OK) The solution that was found was to use the `context_info` to set the trace/span ID. It's independant from the query itself, and sets a "context" for the duration of the session that is visible to DBM when they sample a "slice" of the DB. The drawback ofc is that it's an extra query (albeit a fast one) that we have to run before every "regular" query. It can be slow mostly if the network is slow. For this reason, we want to cover it with a span to clearly represent the time being spent there, so that clients can identify where the time is spent. ## Implementation details ## Test coverage I added this scenario to the integration test, but since the query is parameterized, I don't think I can assert easily on the value that is set. ## Other details This is the dotnet equivalent of DataDog/dd-trace-java#7186 --------- Co-authored-by: Lucas Pimentel <[email protected]>
What Does This Do
Add full APM/DBM mode for SQL Server.
Motivation
A large demand.
Additional Notes
Jira ticket: [PROJ-IDENT]