-
Notifications
You must be signed in to change notification settings - Fork 301
WebSocket support for Netty #8632
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
base: master
Are you sure you want to change the base?
Conversation
// Server pipeline handlers | ||
if (handler instanceof HttpServerCodec) { | ||
toAdd = new HttpServerTracingHandler(); | ||
toAdd2 = MaybeBlockResponseHandler.INSTANCE; | ||
toAdd3 = new WebSocketServerTracingHandler(); |
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.
Improvement required - we don't need a WebSocket handler if there is no websocket handshake
86e499d
to
fad934c
Compare
fad934c
to
e619f2a
Compare
BenchmarksStartupParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 66 metrics, 5 unstable metrics. Startup time reports for petclinicgantt
title petclinic - global startup overhead: candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.005 s) : 0, 1005343
Total [baseline] (10.495 s) : 0, 10494979
Agent [candidate] (1.012 s) : 0, 1011932
Total [candidate] (10.537 s) : 0, 10536897
section appsec
Agent [baseline] (1.147 s) : 0, 1146764
Total [baseline] (10.673 s) : 0, 10673157
Agent [candidate] (1.15 s) : 0, 1150283
Total [candidate] (10.643 s) : 0, 10642528
section iast
Agent [baseline] (1.144 s) : 0, 1143573
Total [baseline] (10.821 s) : 0, 10820990
Agent [candidate] (1.146 s) : 0, 1146187
Total [candidate] (10.844 s) : 0, 10843774
section profiling
Agent [baseline] (1.254 s) : 0, 1254034
Total [baseline] (10.762 s) : 0, 10762063
Agent [candidate] (1.252 s) : 0, 1252256
Total [candidate] (10.775 s) : 0, 10774634
gantt
title petclinic - break down per module: candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (670.104 ms) : 0, 670104
BytebuddyAgent [candidate] (673.099 ms) : 0, 673099
GlobalTracer [baseline] (240.369 ms) : 0, 240369
GlobalTracer [candidate] (241.787 ms) : 0, 241787
AppSec [baseline] (54.659 ms) : 0, 54659
AppSec [candidate] (55.07 ms) : 0, 55070
Debugger [baseline] (6.154 ms) : 0, 6154
Debugger [candidate] (6.951 ms) : 0, 6951
Remote Config [baseline] (702.336 µs) : 0, 702
Remote Config [candidate] (719.067 µs) : 0, 719
Telemetry [baseline] (9.896 ms) : 0, 9896
Telemetry [candidate] (10.773 ms) : 0, 10773
section appsec
BytebuddyAgent [baseline] (687.043 ms) : 0, 687043
BytebuddyAgent [candidate] (689.38 ms) : 0, 689380
GlobalTracer [baseline] (235.83 ms) : 0, 235830
GlobalTracer [candidate] (236.983 ms) : 0, 236983
IAST [baseline] (21.845 ms) : 0, 21845
IAST [candidate] (21.876 ms) : 0, 21876
AppSec [baseline] (174.928 ms) : 0, 174928
AppSec [candidate] (175.24 ms) : 0, 175240
Debugger [baseline] (5.902 ms) : 0, 5902
Debugger [candidate] (5.889 ms) : 0, 5889
Remote Config [baseline] (632.328 µs) : 0, 632
Remote Config [candidate] (638.997 µs) : 0, 639
Telemetry [baseline] (8.154 ms) : 0, 8154
Telemetry [candidate] (7.762 ms) : 0, 7762
section iast
BytebuddyAgent [baseline] (795.884 ms) : 0, 795884
BytebuddyAgent [candidate] (796.654 ms) : 0, 796654
GlobalTracer [baseline] (231.07 ms) : 0, 231070
GlobalTracer [candidate] (232.011 ms) : 0, 232011
IAST [baseline] (22.818 ms) : 0, 22818
IAST [candidate] (22.995 ms) : 0, 22995
AppSec [baseline] (56.018 ms) : 0, 56018
AppSec [candidate] (56.612 ms) : 0, 56612
Debugger [baseline] (5.844 ms) : 0, 5844
Debugger [candidate] (5.874 ms) : 0, 5874
Remote Config [baseline] (572.076 µs) : 0, 572
Remote Config [candidate] (587.425 µs) : 0, 587
Telemetry [baseline] (7.874 ms) : 0, 7874
Telemetry [candidate] (7.864 ms) : 0, 7864
section profiling
BytebuddyAgent [baseline] (661.715 ms) : 0, 661715
BytebuddyAgent [candidate] (661.929 ms) : 0, 661929
GlobalTracer [baseline] (375.082 ms) : 0, 375082
GlobalTracer [candidate] (374.533 ms) : 0, 374533
AppSec [baseline] (54.374 ms) : 0, 54374
AppSec [candidate] (53.609 ms) : 0, 53609
Debugger [baseline] (6.102 ms) : 0, 6102
Debugger [candidate] (6.08 ms) : 0, 6080
Remote Config [baseline] (649.959 µs) : 0, 650
Remote Config [candidate] (634.575 µs) : 0, 635
Telemetry [baseline] (8.16 ms) : 0, 8160
Telemetry [candidate] (8.174 ms) : 0, 8174
ProfilingAgent [baseline] (97.877 ms) : 0, 97877
ProfilingAgent [candidate] (97.218 ms) : 0, 97218
Profiling [baseline] (97.902 ms) : 0, 97902
Profiling [candidate] (97.242 ms) : 0, 97242
Startup time reports for insecure-bankgantt
title insecure-bank - global startup overhead: candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section tracing
Agent [baseline] (1.003 s) : 0, 1002957
Total [baseline] (8.609 s) : 0, 8608588
Agent [candidate] (1.021 s) : 0, 1021432
Total [candidate] (8.713 s) : 0, 8712640
section iast
Agent [baseline] (1.135 s) : 0, 1134704
Total [baseline] (9.163 s) : 0, 9163263
Agent [candidate] (1.143 s) : 0, 1143044
Total [candidate] (9.231 s) : 0, 9231354
section iast_HARDCODED_SECRET_DISABLED
Agent [baseline] (1.138 s) : 0, 1137615
Total [baseline] (9.195 s) : 0, 9195280
Agent [candidate] (1.132 s) : 0, 1131800
Total [candidate] (9.172 s) : 0, 9172056
section iast_TELEMETRY_OFF
Agent [baseline] (1.136 s) : 0, 1136410
Total [baseline] (9.17 s) : 0, 9169790
Agent [candidate] (1.132 s) : 0, 1131669
Total [candidate] (9.223 s) : 0, 9222896
gantt
title insecure-bank - break down per module: candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section tracing
BytebuddyAgent [baseline] (668.327 ms) : 0, 668327
BytebuddyAgent [candidate] (681.693 ms) : 0, 681693
GlobalTracer [baseline] (239.08 ms) : 0, 239080
GlobalTracer [candidate] (242.437 ms) : 0, 242437
AppSec [baseline] (54.776 ms) : 0, 54776
AppSec [candidate] (55.154 ms) : 0, 55154
Debugger [baseline] (6.852 ms) : 0, 6852
Debugger [candidate] (6.223 ms) : 0, 6223
Remote Config [baseline] (712.923 µs) : 0, 713
Remote Config [candidate] (713.327 µs) : 0, 713
Telemetry [baseline] (9.959 ms) : 0, 9959
Telemetry [candidate] (11.514 ms) : 0, 11514
section iast
BytebuddyAgent [baseline] (789.009 ms) : 0, 789009
BytebuddyAgent [candidate] (794.664 ms) : 0, 794664
GlobalTracer [baseline] (229.218 ms) : 0, 229218
GlobalTracer [candidate] (231.302 ms) : 0, 231302
IAST [baseline] (22.828 ms) : 0, 22828
IAST [candidate] (22.825 ms) : 0, 22825
AppSec [baseline] (56.021 ms) : 0, 56021
AppSec [candidate] (56.343 ms) : 0, 56343
Debugger [baseline] (5.808 ms) : 0, 5808
Debugger [candidate] (5.857 ms) : 0, 5857
Remote Config [baseline] (589.811 µs) : 0, 590
Remote Config [candidate] (586.742 µs) : 0, 587
Telemetry [baseline] (7.855 ms) : 0, 7855
Telemetry [candidate] (7.968 ms) : 0, 7968
section iast_HARDCODED_SECRET_DISABLED
BytebuddyAgent [baseline] (790.213 ms) : 0, 790213
BytebuddyAgent [candidate] (786.419 ms) : 0, 786419
GlobalTracer [baseline] (230.13 ms) : 0, 230130
GlobalTracer [candidate] (229.384 ms) : 0, 229384
IAST [baseline] (22.692 ms) : 0, 22692
IAST [candidate] (22.664 ms) : 0, 22664
AppSec [baseline] (56.744 ms) : 0, 56744
AppSec [candidate] (55.834 ms) : 0, 55834
Debugger [baseline] (5.89 ms) : 0, 5890
Debugger [candidate] (5.813 ms) : 0, 5813
Remote Config [baseline] (593.682 µs) : 0, 594
Remote Config [candidate] (579.622 µs) : 0, 580
Telemetry [baseline] (7.957 ms) : 0, 7957
Telemetry [candidate] (7.833 ms) : 0, 7833
section iast_TELEMETRY_OFF
BytebuddyAgent [baseline] (789.426 ms) : 0, 789426
BytebuddyAgent [candidate] (784.668 ms) : 0, 784668
GlobalTracer [baseline] (230.4 ms) : 0, 230400
GlobalTracer [candidate] (229.96 ms) : 0, 229960
IAST [baseline] (22.58 ms) : 0, 22580
IAST [candidate] (22.319 ms) : 0, 22319
AppSec [baseline] (56.308 ms) : 0, 56308
AppSec [candidate] (56.97 ms) : 0, 56970
Debugger [baseline] (5.932 ms) : 0, 5932
Debugger [candidate] (5.941 ms) : 0, 5941
Remote Config [baseline] (606.363 µs) : 0, 606
Remote Config [candidate] (598.678 µs) : 0, 599
Telemetry [baseline] (7.731 ms) : 0, 7731
Telemetry [candidate] (7.866 ms) : 0, 7866
LoadParameters
See matching parameters
SummaryFound 0 performance improvements and 0 performance regressions! Performance is the same for 12 metrics, 18 unstable metrics. Request duration reports for petclinicgantt
title petclinic - request duration [CI 0.99] : candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section baseline
no_agent (1.35 ms) : 1330, 1370
. : milestone, 1350,
appsec (1.729 ms) : 1706, 1753
. : milestone, 1729,
appsec_no_iast (1.721 ms) : 1697, 1745
. : milestone, 1721,
code_origins (1.671 ms) : 1641, 1701
. : milestone, 1671,
iast (1.52 ms) : 1495, 1545
. : milestone, 1520,
profiling (1.524 ms) : 1498, 1549
. : milestone, 1524,
tracing (1.486 ms) : 1462, 1511
. : milestone, 1486,
section candidate
no_agent (1.334 ms) : 1314, 1355
. : milestone, 1334,
appsec (1.73 ms) : 1706, 1753
. : milestone, 1730,
appsec_no_iast (1.706 ms) : 1683, 1730
. : milestone, 1706,
code_origins (1.674 ms) : 1647, 1701
. : milestone, 1674,
iast (1.519 ms) : 1495, 1543
. : milestone, 1519,
profiling (1.512 ms) : 1487, 1537
. : milestone, 1512,
tracing (1.491 ms) : 1467, 1516
. : milestone, 1491,
Request duration reports for insecure-bankgantt
title insecure-bank - request duration [CI 0.99] : candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section baseline
no_agent (377.832 µs) : 358, 397
. : milestone, 378,
iast (522.599 µs) : 500, 545
. : milestone, 523,
iast_FULL (723.689 µs) : 700, 747
. : milestone, 724,
iast_GLOBAL (574.544 µs) : 551, 599
. : milestone, 575,
iast_HARDCODED_SECRET_DISABLED (514.937 µs) : 492, 538
. : milestone, 515,
iast_INACTIVE (468.729 µs) : 446, 491
. : milestone, 469,
iast_TELEMETRY_OFF (513.394 µs) : 490, 537
. : milestone, 513,
tracing (466.215 µs) : 444, 489
. : milestone, 466,
section candidate
no_agent (379.809 µs) : 360, 400
. : milestone, 380,
iast (515.034 µs) : 492, 538
. : milestone, 515,
iast_FULL (728.21 µs) : 705, 751
. : milestone, 728,
iast_GLOBAL (566.46 µs) : 543, 590
. : milestone, 566,
iast_HARDCODED_SECRET_DISABLED (513.13 µs) : 490, 537
. : milestone, 513,
iast_INACTIVE (463.591 µs) : 441, 486
. : milestone, 464,
iast_TELEMETRY_OFF (499.293 µs) : 476, 522
. : milestone, 499,
tracing (462.426 µs) : 440, 485
. : milestone, 462,
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 biojavagantt
title biojava - execution time [CI 0.99] : candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section baseline
no_agent (15.44 s) : 15440000, 15440000
. : milestone, 15440000,
appsec (15.163 s) : 15163000, 15163000
. : milestone, 15163000,
iast (18.663 s) : 18663000, 18663000
. : milestone, 18663000,
iast_GLOBAL (18.35 s) : 18350000, 18350000
. : milestone, 18350000,
profiling (14.962 s) : 14962000, 14962000
. : milestone, 14962000,
tracing (15.352 s) : 15352000, 15352000
. : milestone, 15352000,
section candidate
no_agent (15.2 s) : 15200000, 15200000
. : milestone, 15200000,
appsec (15.108 s) : 15108000, 15108000
. : milestone, 15108000,
iast (18.815 s) : 18815000, 18815000
. : milestone, 18815000,
iast_GLOBAL (18.279 s) : 18279000, 18279000
. : milestone, 18279000,
profiling (15.656 s) : 15656000, 15656000
. : milestone, 15656000,
tracing (15.012 s) : 15012000, 15012000
. : milestone, 15012000,
Execution time for tomcatgantt
title tomcat - execution time [CI 0.99] : candidate=1.49.0-SNAPSHOT~c817fc9228, baseline=1.49.0-SNAPSHOT~d306e1530b
dateFormat X
axisFormat %s
section baseline
no_agent (1.478 ms) : 1466, 1489
. : milestone, 1478,
appsec (2.393 ms) : 2346, 2441
. : milestone, 2393,
iast (2.156 ms) : 2098, 2215
. : milestone, 2156,
iast_GLOBAL (2.215 ms) : 2155, 2275
. : milestone, 2215,
profiling (2.015 ms) : 1969, 2062
. : milestone, 2015,
tracing (1.995 ms) : 1949, 2041
. : milestone, 1995,
section candidate
no_agent (1.48 ms) : 1469, 1492
. : milestone, 1480,
appsec (2.39 ms) : 2343, 2437
. : milestone, 2390,
iast (2.166 ms) : 2107, 2225
. : milestone, 2166,
iast_GLOBAL (2.199 ms) : 2140, 2258
. : milestone, 2199,
profiling (2.001 ms) : 1955, 2047
. : milestone, 2001,
tracing (1.99 ms) : 1945, 2036
. : milestone, 1990,
|
5870c70
to
1ab91db
Compare
3357f5c
to
e816b50
Compare
ca61b9e
to
5922b70
Compare
Debugger benchmarksParameters
See matching parameters
SummaryFound 5 performance improvements and 0 performance regressions! Performance is the same for 4 metrics, 6 unstable metrics.
See unchanged results
Request duration reports for reportsgantt
title reports - request duration [CI 0.99] : candidate=None, baseline=None
dateFormat X
axisFormat %s
section baseline
noprobe (319.62 µs) : 278, 362
. : milestone, 320,
basic (311.725 µs) : 302, 321
. : milestone, 312,
loop (10.827 ms) : 10801, 10853
. : milestone, 10827,
section candidate
noprobe (310.8 µs) : 284, 337
. : milestone, 311,
basic (309.257 µs) : 302, 317
. : milestone, 309,
loop (10.154 ms) : 10114, 10194
. : milestone, 10154,
|
HttpServerResponseTracingHandler.INSTANCE, | ||
MaybeBlockResponseHandler.INSTANCE); | ||
} else if (handler instanceof WebSocketServerProtocolHandler) { | ||
if (pipeline.get(HttpServerTracingHandler.class) != 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.
the websocket insturmentation should be disabled by default. I suggest to check also against InstrumenterConfig.isWebsocketTracingEnabled()
NettyPipelineHelper.addHandlerAfter( | ||
pipeline, | ||
"HttpServerRequestTracingHandler#0", | ||
WebSocketServerRequestTracingHandler.INSTANCE); |
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.
check if websocket is enabled
NettyPipelineHelper.addHandlerAfter( | ||
pipeline, | ||
"HttpServerResponseTracingHandler#0", | ||
WebSocketServerResponseTracingHandler.INSTANCE); |
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.
to be checked if websocket is enabled
NettyPipelineHelper.addHandlerAfter( | ||
pipeline, | ||
"datadog.trace.instrumentation.netty40.server.HttpServerTracingHandler", | ||
new WebSocketServerTracingHandler()); |
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.
to be added only if websocket tracing is enabled
addHandlerAfter( | ||
pipeline, | ||
"datadog.trace.instrumentation.netty38.server.HttpServerTracingHandler", | ||
new WebSocketServerTracingHandler(contextStore)); |
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.
to be added only if websocket tracing is enabled
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.
The main changes concern the fact the websocket handlers have to be added only if the websocket tracing is enabled. Other than this it looks ok. It would be nice to have another review since I coauthored part of that
Hi! 👋 Thanks for your pull request! 🎉 To help us review it, please make sure to:
If you need help, please check our contributing guidelines. |
@Override | ||
void messageReceived(ChannelHandlerContext ctx, MessageEvent msg) throws Exception { | ||
if (msg.getMessage() instanceof HttpRequest) { | ||
def request = msg.getMessage() as HttpRequest | ||
|
||
def upgradeHeader = request.headers().get("Upgrade") |
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.
Should the header name be lowercase or capitalized?
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've checked, internally it's doing case insensitive comparison, during the search, but probably you are right and we might keep low case here for clarity.
|
||
@Override | ||
void setSplitChunksAfter(int size) { | ||
// not supported |
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.
Why not? Is it not needed for testing?
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
What Does This Do
WebSocket Server instrumentation for Netty, versions 3.8, 4.0 and 4.1+
For the tests, used Netty WebSocket Client with fragmentation support (instead of OkHttp)
Motivation
Additional Notes
Contributor Checklist
type:
and (comp:
orinst:
) labels in addition to any usefull labelsclose
,fix
or any linking keywords when referencing an issue.Use
solves
instead, and assign the PR milestone to the issueJira ticket: [PROJ-IDENT]