instrument inner requests in apache http client#10603
instrument inner requests in apache http client#10603
Conversation
|
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
| .setDefaultRequestConfig(RequestConfig.custom() | ||
| .setConnectTimeout(CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS) | ||
| .build()).build() | ||
| def response = client.execute(new BasicClassicHttpRequest("GET", mainUri), { r -> |
There was a problem hiding this comment.
The code referenced in the issue runs in an interceptor that's completely different orchestration. I'm not sure it's reproducing the same use case
|
|
||
| @Override | ||
| public Map<String, String> contextStore() { | ||
| return Collections.singletonMap("org.apache.hc.core5.http.HttpRequest", "java.lang.Integer"); |
There was a problem hiding this comment.
A boolean will be enough here. There is no need to track the depth but just to flag that the request is being traced (or not)
There was a problem hiding this comment.
Also you can use ClassicHttpRequest as key since it's the type required by the matchers. it will avoid transforming too much types
There was a problem hiding this comment.
using a boolean is nice, because I actually never need to unset the boolean, so I can clear a lot of the instrumentation code that was dedicated to that
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 60 metrics, 11 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.062 s) : 0, 1061965
Total [baseline] (10.913 s) : 0, 10913252
Agent [candidate] (1.079 s) : 0, 1079455
Total [candidate] (11.007 s) : 0, 11006983
section appsec
Agent [baseline] (1.243 s) : 0, 1242741
Total [baseline] (11.155 s) : 0, 11155220
Agent [candidate] (1.248 s) : 0, 1248061
Total [candidate] (11.105 s) : 0, 11105129
section iast
Agent [baseline] (1.237 s) : 0, 1237124
Total [baseline] (11.216 s) : 0, 11215813
Agent [candidate] (1.233 s) : 0, 1233489
Total [candidate] (11.152 s) : 0, 11151839
section profiling
Agent [baseline] (1.197 s) : 0, 1196685
Total [baseline] (11.001 s) : 0, 11000888
Agent [candidate] (1.19 s) : 0, 1189838
Total [candidate] (10.913 s) : 0, 10912515
gantt
title petclinic - break down per module: candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.192 ms) : 0, 1192
crashtracking [candidate] (1.194 ms) : 0, 1194
BytebuddyAgent [baseline] (627.993 ms) : 0, 627993
BytebuddyAgent [candidate] (636.946 ms) : 0, 636946
AgentMeter [baseline] (28.96 ms) : 0, 28960
AgentMeter [candidate] (29.433 ms) : 0, 29433
GlobalTracer [baseline] (257.597 ms) : 0, 257597
GlobalTracer [candidate] (260.763 ms) : 0, 260763
AppSec [baseline] (32.661 ms) : 0, 32661
AppSec [candidate] (33.195 ms) : 0, 33195
Debugger [baseline] (61.143 ms) : 0, 61143
Debugger [candidate] (62.945 ms) : 0, 62945
Remote Config [baseline] (626.887 µs) : 0, 627
Remote Config [candidate] (608.997 µs) : 0, 609
Telemetry [baseline] (10.576 ms) : 0, 10576
Telemetry [candidate] (11.677 ms) : 0, 11677
Flare Poller [baseline] (6.024 ms) : 0, 6024
Flare Poller [candidate] (7.017 ms) : 0, 7017
section appsec
crashtracking [baseline] (1.196 ms) : 0, 1196
crashtracking [candidate] (1.207 ms) : 0, 1207
BytebuddyAgent [baseline] (660.183 ms) : 0, 660183
BytebuddyAgent [candidate] (663.114 ms) : 0, 663114
AgentMeter [baseline] (12.03 ms) : 0, 12030
AgentMeter [candidate] (12.076 ms) : 0, 12076
GlobalTracer [baseline] (258.838 ms) : 0, 258838
GlobalTracer [candidate] (260.009 ms) : 0, 260009
IAST [baseline] (25.208 ms) : 0, 25208
IAST [candidate] (25.439 ms) : 0, 25439
AppSec [baseline] (168.137 ms) : 0, 168137
AppSec [candidate] (169.019 ms) : 0, 169019
Debugger [baseline] (67.509 ms) : 0, 67509
Debugger [candidate] (67.469 ms) : 0, 67469
Remote Config [baseline] (658.412 µs) : 0, 658
Remote Config [candidate] (672.205 µs) : 0, 672
Telemetry [baseline] (9.769 ms) : 0, 9769
Telemetry [candidate] (9.733 ms) : 0, 9733
Flare Poller [baseline] (3.766 ms) : 0, 3766
Flare Poller [candidate] (3.808 ms) : 0, 3808
section iast
crashtracking [baseline] (1.194 ms) : 0, 1194
crashtracking [candidate] (1.176 ms) : 0, 1176
BytebuddyAgent [baseline] (798.482 ms) : 0, 798482
BytebuddyAgent [candidate] (796.082 ms) : 0, 796082
AgentMeter [baseline] (11.366 ms) : 0, 11366
AgentMeter [candidate] (11.276 ms) : 0, 11276
GlobalTracer [baseline] (249.784 ms) : 0, 249784
GlobalTracer [candidate] (248.915 ms) : 0, 248915
IAST [baseline] (27.074 ms) : 0, 27074
IAST [candidate] (26.905 ms) : 0, 26905
AppSec [baseline] (34.991 ms) : 0, 34991
AppSec [candidate] (32.414 ms) : 0, 32414
Debugger [baseline] (66.091 ms) : 0, 66091
Debugger [candidate] (68.685 ms) : 0, 68685
Remote Config [baseline] (543.834 µs) : 0, 544
Remote Config [candidate] (562.546 µs) : 0, 563
Telemetry [baseline] (8.616 ms) : 0, 8616
Telemetry [candidate] (8.675 ms) : 0, 8675
Flare Poller [baseline] (3.503 ms) : 0, 3503
Flare Poller [candidate] (3.481 ms) : 0, 3481
section profiling
crashtracking [baseline] (1.241 ms) : 0, 1241
crashtracking [candidate] (1.206 ms) : 0, 1206
BytebuddyAgent [baseline] (686.158 ms) : 0, 686158
BytebuddyAgent [candidate] (681.985 ms) : 0, 681985
AgentMeter [baseline] (8.675 ms) : 0, 8675
AgentMeter [candidate] (8.629 ms) : 0, 8629
GlobalTracer [baseline] (216.761 ms) : 0, 216761
GlobalTracer [candidate] (215.64 ms) : 0, 215640
AppSec [baseline] (32.689 ms) : 0, 32689
AppSec [candidate] (32.448 ms) : 0, 32448
Debugger [baseline] (68.117 ms) : 0, 68117
Debugger [candidate] (67.192 ms) : 0, 67192
Remote Config [baseline] (640.873 µs) : 0, 641
Remote Config [candidate] (635.269 µs) : 0, 635
Telemetry [baseline] (8.952 ms) : 0, 8952
Telemetry [candidate] (9.005 ms) : 0, 9005
Flare Poller [baseline] (3.744 ms) : 0, 3744
Flare Poller [candidate] (3.772 ms) : 0, 3772
ProfilingAgent [baseline] (99.426 ms) : 0, 99426
ProfilingAgent [candidate] (99.38 ms) : 0, 99380
Profiling [baseline] (100.005 ms) : 0, 100005
Profiling [candidate] (99.957 ms) : 0, 99957
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.066 s) : 0, 1065745
Total [baseline] (8.794 s) : 0, 8793844
Agent [candidate] (1.079 s) : 0, 1079349
Total [candidate] (8.793 s) : 0, 8792640
section iast
Agent [baseline] (1.241 s) : 0, 1240563
Total [baseline] (9.403 s) : 0, 9403114
Agent [candidate] (1.234 s) : 0, 1233574
Total [candidate] (9.391 s) : 0, 9390823
gantt
title insecure-bank - break down per module: candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section tracing
crashtracking [baseline] (1.178 ms) : 0, 1178
crashtracking [candidate] (1.201 ms) : 0, 1201
BytebuddyAgent [baseline] (629.456 ms) : 0, 629456
BytebuddyAgent [candidate] (637.204 ms) : 0, 637204
AgentMeter [baseline] (28.943 ms) : 0, 28943
AgentMeter [candidate] (29.322 ms) : 0, 29322
GlobalTracer [baseline] (257.037 ms) : 0, 257037
GlobalTracer [candidate] (260.614 ms) : 0, 260614
AppSec [baseline] (32.762 ms) : 0, 32762
AppSec [candidate] (33.295 ms) : 0, 33295
Debugger [baseline] (62.075 ms) : 0, 62075
Debugger [candidate] (62.824 ms) : 0, 62824
Remote Config [baseline] (622.38 µs) : 0, 622
Remote Config [candidate] (624.74 µs) : 0, 625
Telemetry [baseline] (13.019 ms) : 0, 13019
Telemetry [candidate] (13.178 ms) : 0, 13178
Flare Poller [baseline] (5.35 ms) : 0, 5350
Flare Poller [candidate] (5.354 ms) : 0, 5354
section iast
crashtracking [baseline] (1.191 ms) : 0, 1191
crashtracking [candidate] (1.18 ms) : 0, 1180
BytebuddyAgent [baseline] (803.046 ms) : 0, 803046
BytebuddyAgent [candidate] (796.929 ms) : 0, 796929
AgentMeter [baseline] (11.45 ms) : 0, 11450
AgentMeter [candidate] (11.262 ms) : 0, 11262
GlobalTracer [baseline] (249.602 ms) : 0, 249602
GlobalTracer [candidate] (248.615 ms) : 0, 248615
IAST [baseline] (27.114 ms) : 0, 27114
IAST [candidate] (26.974 ms) : 0, 26974
AppSec [baseline] (33.492 ms) : 0, 33492
AppSec [candidate] (35.768 ms) : 0, 35768
Debugger [baseline] (66.49 ms) : 0, 66490
Debugger [candidate] (64.756 ms) : 0, 64756
Remote Config [baseline] (535.05 µs) : 0, 535
Remote Config [candidate] (540.196 µs) : 0, 540
Telemetry [baseline] (8.634 ms) : 0, 8634
Telemetry [candidate] (8.615 ms) : 0, 8615
Flare Poller [baseline] (3.5 ms) : 0, 3500
Flare Poller [candidate] (3.516 ms) : 0, 3516
LoadParameters
See matching parameters
SummaryFound 2 performance improvements and 1 performance regressions! Performance is the same for 17 metrics, 16 unstable metrics.
Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section baseline
no_agent (19.098 ms) : 18899, 19298
. : milestone, 19098,
appsec (18.488 ms) : 18301, 18675
. : milestone, 18488,
code_origins (17.441 ms) : 17269, 17612
. : milestone, 17441,
iast (17.578 ms) : 17403, 17753
. : milestone, 17578,
profiling (18.742 ms) : 18557, 18927
. : milestone, 18742,
tracing (17.435 ms) : 17262, 17609
. : milestone, 17435,
section candidate
no_agent (17.967 ms) : 17783, 18150
. : milestone, 17967,
appsec (18.389 ms) : 18199, 18580
. : milestone, 18389,
code_origins (18.707 ms) : 18517, 18897
. : milestone, 18707,
iast (17.558 ms) : 17382, 17735
. : milestone, 17558,
profiling (18.637 ms) : 18452, 18822
. : milestone, 18637,
tracing (17.526 ms) : 17353, 17698
. : milestone, 17526,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section baseline
no_agent (1.189 ms) : 1176, 1202
. : milestone, 1189,
iast (3.161 ms) : 3123, 3199
. : milestone, 3161,
iast_FULL (5.731 ms) : 5674, 5787
. : milestone, 5731,
iast_GLOBAL (3.595 ms) : 3528, 3661
. : milestone, 3595,
profiling (2.025 ms) : 2007, 2044
. : milestone, 2025,
tracing (1.764 ms) : 1750, 1778
. : milestone, 1764,
section candidate
no_agent (1.195 ms) : 1183, 1206
. : milestone, 1195,
iast (2.99 ms) : 2955, 3026
. : milestone, 2990,
iast_FULL (5.79 ms) : 5732, 5847
. : milestone, 5790,
iast_GLOBAL (3.541 ms) : 3484, 3598
. : milestone, 3541,
profiling (1.933 ms) : 1918, 1949
. : milestone, 1933,
tracing (1.821 ms) : 1806, 1837
. : milestone, 1821,
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.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section baseline
no_agent (1.481 ms) : 1470, 1493
. : milestone, 1481,
appsec (3.788 ms) : 3567, 4009
. : milestone, 3788,
iast (2.266 ms) : 2196, 2336
. : milestone, 2266,
iast_GLOBAL (2.297 ms) : 2228, 2367
. : milestone, 2297,
profiling (2.086 ms) : 2031, 2141
. : milestone, 2086,
tracing (2.086 ms) : 2031, 2141
. : milestone, 2086,
section candidate
no_agent (1.479 ms) : 1467, 1490
. : milestone, 1479,
appsec (3.743 ms) : 3526, 3960
. : milestone, 3743,
iast (2.265 ms) : 2195, 2336
. : milestone, 2265,
iast_GLOBAL (2.311 ms) : 2241, 2382
. : milestone, 2311,
profiling (2.104 ms) : 2048, 2161
. : milestone, 2104,
tracing (2.081 ms) : 2027, 2136
. : milestone, 2081,
Execution time for biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.60.0-SNAPSHOT~9c4389532a, baseline=1.60.0-SNAPSHOT~61376da955
dateFormat X
axisFormat %s
section baseline
no_agent (15.37 s) : 15370000, 15370000
. : milestone, 15370000,
appsec (14.591 s) : 14591000, 14591000
. : milestone, 14591000,
iast (18.071 s) : 18071000, 18071000
. : milestone, 18071000,
iast_GLOBAL (18.032 s) : 18032000, 18032000
. : milestone, 18032000,
profiling (14.754 s) : 14754000, 14754000
. : milestone, 14754000,
tracing (14.699 s) : 14699000, 14699000
. : milestone, 14699000,
section candidate
no_agent (15.537 s) : 15537000, 15537000
. : milestone, 15537000,
appsec (14.476 s) : 14476000, 14476000
. : milestone, 14476000,
iast (18.477 s) : 18477000, 18477000
. : milestone, 18477000,
iast_GLOBAL (17.782 s) : 17782000, 17782000
. : milestone, 17782000,
profiling (15.07 s) : 15070000, 15070000
. : milestone, 15070000,
tracing (14.827 s) : 14827000, 14827000
. : milestone, 14827000,
|
|
I think there is an issue with tests, I'll check tomorrow |
What Does This Do
replace global depth count with one that counts depth per request, so that we can instrument new requests and still avoid double instrumenting.
Motivation
#10383
Additional Notes
Used a ConstextStore to store the depth on the request. I'm not very happy with how verbose it is in the advice, but I don't really see a way around it.
note: test is AI generated
Contributor Checklist
type:and (comp:orinst:) labels in addition to any other useful labelsclose,fix, or any linking keywords when referencing an issueUse
solvesinstead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]
Note: Once your PR is ready to merge, add it to the merge queue by commenting
/merge./merge -ccancels the queue request./merge -f --reason "reason"skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.