-
Notifications
You must be signed in to change notification settings - Fork 312
🪞 9251 - Add a span when waiting for an available database connection from a pool #9636
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
Conversation
- Use dd.trace.experimental.jdbc.pool.waiting.enabled=true to enable. - Change instrumentation name from jdbc-datasource to jdbc. - Record exceptions. - Use default instrumentation name (jdbc). - Set resource name to {dbcp2,hikari}.waiting
Also add PoolWaitingDecorator.
- Comment on the overall structure and highlight related instrumentations. - Avoid using reflection and breakup HikariConcurrentBagInstrumentation.ConstructorAdvice into separate, simpler instrumentations: HikariPoolInstrumentation and HikariConcurrentBagHandoffQueueInstrumentation. - Move HikariBlockedTrackingSynchronousQueue into HikariConcurrentBagHandoffQueueInstrumentation. - Make sure the instrumentationName is consistently "jdbc".
Thanks to @mcculls for pointing out the issue.
This would help if this feature becomes enabled it by default in the future, or if someone using this feature wanted to disable it for a particular pool library. Suggested during code review. Co-authored-by: Stuart McCulloch <mcculls@gmail.com>
🎯 Code Coverage 🔗 Commit SHA: 74ec816 | Docs | Was this helpful? Give us feedback! |
BenchmarksStartupParameters
See matching parameters
SummaryFound 1 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 9 unstable metrics.
Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.015 s) : 0, 1015294
Total [baseline] (10.619 s) : 0, 10618710
Agent [candidate] (1.016 s) : 0, 1015631
Total [candidate] (10.798 s) : 0, 10798239
section appsec
Agent [baseline] (1.192 s) : 0, 1191911
Total [baseline] (11.1 s) : 0, 11099816
Agent [candidate] (1.187 s) : 0, 1186715
Total [candidate] (11.0 s) : 0, 10999603
section iast
Agent [baseline] (1.154 s) : 0, 1153560
Total [baseline] (10.853 s) : 0, 10852674
Agent [candidate] (1.15 s) : 0, 1150232
Total [candidate] (10.907 s) : 0, 10907283
section profiling
Agent [baseline] (1.16 s) : 0, 1160372
Total [baseline] (11.036 s) : 0, 11036254
Agent [candidate] (1.173 s) : 0, 1173324
Total [candidate] (11.028 s) : 0, 11028028
gantt
title petclinic - break down per module: candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.472 ms) : 0, 1472
crashtracking [candidate] (1.475 ms) : 0, 1475
BytebuddyAgent [baseline] (692.173 ms) : 0, 692173
BytebuddyAgent [candidate] (691.916 ms) : 0, 691916
GlobalTracer [baseline] (241.506 ms) : 0, 241506
GlobalTracer [candidate] (244.528 ms) : 0, 244528
AppSec [baseline] (32.748 ms) : 0, 32748
AppSec [candidate] (31.664 ms) : 0, 31664
Debugger [baseline] (6.374 ms) : 0, 6374
Debugger [candidate] (6.407 ms) : 0, 6407
Remote Config [baseline] (688.537 µs) : 0, 689
Remote Config [candidate] (671.358 µs) : 0, 671
Telemetry [baseline] (9.001 ms) : 0, 9001
Telemetry [candidate] (9.122 ms) : 0, 9122
Flare Poller [baseline] (10.172 ms) : 0, 10172
Flare Poller [candidate] (8.667 ms) : 0, 8667
section appsec
crashtracking [baseline] (1.459 ms) : 0, 1459
crashtracking [candidate] (1.461 ms) : 0, 1461
BytebuddyAgent [baseline] (715.885 ms) : 0, 715885
BytebuddyAgent [candidate] (713.388 ms) : 0, 713388
GlobalTracer [baseline] (234.887 ms) : 0, 234887
GlobalTracer [candidate] (234.603 ms) : 0, 234603
AppSec [baseline] (173.153 ms) : 0, 173153
AppSec [candidate] (172.495 ms) : 0, 172495
Debugger [baseline] (6.023 ms) : 0, 6023
Debugger [candidate] (6.092 ms) : 0, 6092
Remote Config [baseline] (661.94 µs) : 0, 662
Remote Config [candidate] (628.261 µs) : 0, 628
Telemetry [baseline] (9.822 ms) : 0, 9822
Telemetry [candidate] (8.266 ms) : 0, 8266
Flare Poller [baseline] (3.962 ms) : 0, 3962
Flare Poller [candidate] (3.98 ms) : 0, 3980
IAST [baseline] (24.912 ms) : 0, 24912
IAST [candidate] (24.755 ms) : 0, 24755
section iast
crashtracking [baseline] (1.456 ms) : 0, 1456
crashtracking [candidate] (1.456 ms) : 0, 1456
BytebuddyAgent [baseline] (816.278 ms) : 0, 816278
BytebuddyAgent [candidate] (814.429 ms) : 0, 814429
GlobalTracer [baseline] (233.563 ms) : 0, 233563
GlobalTracer [candidate] (233.115 ms) : 0, 233115
AppSec [baseline] (34.965 ms) : 0, 34965
AppSec [candidate] (34.197 ms) : 0, 34197
Debugger [baseline] (6.012 ms) : 0, 6012
Debugger [candidate] (6.188 ms) : 0, 6188
Remote Config [baseline] (596.504 µs) : 0, 597
Remote Config [candidate] (601.314 µs) : 0, 601
Telemetry [baseline] (8.191 ms) : 0, 8191
Telemetry [candidate] (8.306 ms) : 0, 8306
Flare Poller [baseline] (4.287 ms) : 0, 4287
Flare Poller [candidate] (4.23 ms) : 0, 4230
IAST [baseline] (26.778 ms) : 0, 26778
IAST [candidate] (26.312 ms) : 0, 26312
section profiling
ProfilingAgent [baseline] (104.382 ms) : 0, 104382
ProfilingAgent [candidate] (106.909 ms) : 0, 106909
crashtracking [baseline] (1.421 ms) : 0, 1421
crashtracking [candidate] (1.442 ms) : 0, 1442
BytebuddyAgent [baseline] (719.72 ms) : 0, 719720
BytebuddyAgent [candidate] (731.082 ms) : 0, 731082
GlobalTracer [baseline] (218.891 ms) : 0, 218891
GlobalTracer [candidate] (221.016 ms) : 0, 221016
AppSec [baseline] (32.699 ms) : 0, 32699
AppSec [candidate] (31.871 ms) : 0, 31871
Debugger [baseline] (6.58 ms) : 0, 6580
Debugger [candidate] (8.252 ms) : 0, 8252
Remote Config [baseline] (839.005 µs) : 0, 839
Remote Config [candidate] (758.021 µs) : 0, 758
Telemetry [baseline] (15.714 ms) : 0, 15714
Telemetry [candidate] (14.67 ms) : 0, 14670
Flare Poller [baseline] (5.016 ms) : 0, 5016
Flare Poller [candidate] (4.155 ms) : 0, 4155
Profiling [baseline] (107.528 ms) : 0, 107528
Profiling [candidate] (107.516 ms) : 0, 107516
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.018 s) : 0, 1017807
Total [baseline] (8.642 s) : 0, 8642131
Agent [candidate] (1.018 s) : 0, 1017626
Total [candidate] (8.653 s) : 0, 8653050
section iast
Agent [baseline] (1.153 s) : 0, 1153475
Total [baseline] (9.273 s) : 0, 9273386
Agent [candidate] (1.156 s) : 0, 1156444
Total [candidate] (9.255 s) : 0, 9255099
gantt
title insecure-bank - break down per module: candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.465 ms) : 0, 1465
crashtracking [candidate] (1.464 ms) : 0, 1464
BytebuddyAgent [baseline] (692.237 ms) : 0, 692237
BytebuddyAgent [candidate] (693.148 ms) : 0, 693148
GlobalTracer [baseline] (242.665 ms) : 0, 242665
GlobalTracer [candidate] (243.693 ms) : 0, 243693
AppSec [baseline] (32.66 ms) : 0, 32660
AppSec [candidate] (31.28 ms) : 0, 31280
Debugger [baseline] (6.392 ms) : 0, 6392
Debugger [candidate] (6.366 ms) : 0, 6366
Remote Config [baseline] (680.431 µs) : 0, 680
Remote Config [candidate] (674.511 µs) : 0, 675
Telemetry [baseline] (9.098 ms) : 0, 9098
Telemetry [candidate] (9.104 ms) : 0, 9104
Flare Poller [baseline] (11.368 ms) : 0, 11368
Flare Poller [candidate] (10.815 ms) : 0, 10815
section iast
crashtracking [baseline] (1.469 ms) : 0, 1469
crashtracking [candidate] (1.459 ms) : 0, 1459
BytebuddyAgent [baseline] (815.845 ms) : 0, 815845
BytebuddyAgent [candidate] (819.1 ms) : 0, 819100
GlobalTracer [baseline] (233.196 ms) : 0, 233196
GlobalTracer [candidate] (234.207 ms) : 0, 234207
AppSec [baseline] (35.7 ms) : 0, 35700
AppSec [candidate] (34.655 ms) : 0, 34655
Debugger [baseline] (6.058 ms) : 0, 6058
Debugger [candidate] (6.117 ms) : 0, 6117
Remote Config [baseline] (590.868 µs) : 0, 591
Remote Config [candidate] (590.532 µs) : 0, 591
Telemetry [baseline] (8.184 ms) : 0, 8184
Telemetry [candidate] (8.134 ms) : 0, 8134
Flare Poller [baseline] (4.293 ms) : 0, 4293
Flare Poller [candidate] (4.238 ms) : 0, 4238
IAST [baseline] (26.651 ms) : 0, 26651
IAST [candidate] (26.636 ms) : 0, 26636
LoadParameters
See matching parameters
SummaryFound 4 performance improvements and 2 performance regressions! Performance is the same for 6 metrics, 12 unstable metrics.
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section baseline
no_agent (4.513 ms) : 4461, 4564
. : milestone, 4513,
iast (9.58 ms) : 9419, 9740
. : milestone, 9580,
iast_FULL (14.068 ms) : 13788, 14348
. : milestone, 14068,
iast_GLOBAL (10.694 ms) : 10501, 10886
. : milestone, 10694,
profiling (8.874 ms) : 8739, 9009
. : milestone, 8874,
tracing (8.193 ms) : 8068, 8317
. : milestone, 8193,
section candidate
no_agent (4.33 ms) : 4282, 4378
. : milestone, 4330,
iast (9.722 ms) : 9560, 9884
. : milestone, 9722,
iast_FULL (14.059 ms) : 13782, 14337
. : milestone, 14059,
iast_GLOBAL (10.208 ms) : 10027, 10388
. : milestone, 10208,
profiling (8.843 ms) : 8693, 8993
. : milestone, 8843,
tracing (7.71 ms) : 7593, 7828
. : milestone, 7710,
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section baseline
no_agent (36.373 ms) : 36082, 36664
. : milestone, 36373,
appsec (48.704 ms) : 48265, 49143
. : milestone, 48704,
code_origins (44.583 ms) : 44206, 44959
. : milestone, 44583,
iast (46.103 ms) : 45719, 46488
. : milestone, 46103,
profiling (47.539 ms) : 47119, 47960
. : milestone, 47539,
tracing (43.76 ms) : 43384, 44135
. : milestone, 43760,
section candidate
no_agent (38.04 ms) : 37732, 38347
. : milestone, 38040,
appsec (46.433 ms) : 46025, 46840
. : milestone, 46433,
code_origins (44.917 ms) : 44527, 45306
. : milestone, 44917,
iast (45.581 ms) : 45185, 45978
. : milestone, 45581,
profiling (47.089 ms) : 46658, 47520
. : milestone, 47089,
tracing (45.564 ms) : 45171, 45957
. : milestone, 45564,
DacapoParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 11 metrics, 1 unstable metrics. Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section baseline
no_agent (1.485 ms) : 1473, 1496
. : milestone, 1485,
appsec (3.75 ms) : 3532, 3967
. : milestone, 3750,
iast (2.217 ms) : 2154, 2281
. : milestone, 2217,
iast_GLOBAL (2.256 ms) : 2192, 2319
. : milestone, 2256,
profiling (2.055 ms) : 2003, 2106
. : milestone, 2055,
tracing (2.031 ms) : 1982, 2081
. : milestone, 2031,
section candidate
no_agent (1.482 ms) : 1471, 1494
. : milestone, 1482,
appsec (3.714 ms) : 3496, 3932
. : milestone, 3714,
iast (2.213 ms) : 2150, 2276
. : milestone, 2213,
iast_GLOBAL (2.274 ms) : 2209, 2339
. : milestone, 2274,
profiling (2.074 ms) : 2021, 2126
. : milestone, 2074,
tracing (2.041 ms) : 1991, 2091
. : milestone, 2041,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.54.0-SNAPSHOT~74ec816e56, baseline=1.54.0-SNAPSHOT~bd72002abf
dateFormat X
axisFormat %s
section baseline
no_agent (15.62 s) : 15620000, 15620000
. : milestone, 15620000,
appsec (15.374 s) : 15374000, 15374000
. : milestone, 15374000,
iast (18.496 s) : 18496000, 18496000
. : milestone, 18496000,
iast_GLOBAL (17.504 s) : 17504000, 17504000
. : milestone, 17504000,
profiling (15.675 s) : 15675000, 15675000
. : milestone, 15675000,
tracing (15.197 s) : 15197000, 15197000
. : milestone, 15197000,
section candidate
no_agent (15.419 s) : 15419000, 15419000
. : milestone, 15419000,
appsec (15.06 s) : 15060000, 15060000
. : milestone, 15060000,
iast (18.597 s) : 18597000, 18597000
. : milestone, 18597000,
iast_GLOBAL (18.138 s) : 18138000, 18138000
. : milestone, 18138000,
profiling (15.44 s) : 15440000, 15440000
. : milestone, 15440000,
tracing (15.028 s) : 15028000, 15028000
. : milestone, 15028000,
|
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.
Thanks for opening/mirroring that PR. Looks good to me. Nice coverage in terms of instrumentations for the two main different pool we already support. I left a comment (perhaps for the future) to have better trace metrics for this spans (they are btw not measured right now)
...rc/main/java/datadog/trace/instrumentation/jdbc/Dbcp2LinkedBlockingDequeInstrumentation.java
Show resolved
Hide resolved
private static final ThreadLocal<Boolean> tracker = new ThreadLocal<>(); | ||
|
||
public static void clearBlocked() { | ||
tracker.remove(); |
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.
@deejgregor I made a small change here to remove the thread-local when done, just in case a large number of threads end up calling into Hikari
} | ||
|
||
public static boolean wasBlocked() { | ||
return TRUE == tracker.get(); |
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.
@deejgregor likewise here we now avoid creating a false
entry in the thread-local map if there is no blocking happening (previously this would happen because of the withInitial
used when constructing the thread-local)
|
||
span.finish(); | ||
|
||
HikariBlockedTracker.clearBlocked(); |
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.
@deejgregor another small improvement: we check if there was blocking in the surrounding if
, so only need to clear it if we entered that if
block
@deejgregor I tweaked the |
Yes, looks great. Thank you! |
This PR mirrors the changes from the original community contribution to enable CI testing with
maintainer privileges.
Original PR: #9251
Original Author: @deejgregor
Original Branch: deejgregor/dd-trace-java:hikaricp-blocked-tracking
Closes #9251
This is an automated mirror created to run CI checks. See tooling/mirror-community-pull-request.sh for details.