clintropolis opened a new pull request #9594: Fix double count ssl connection 
metrics
URL: https://github.com/apache/druid/pull/9594
 
 
   
   ### Description
   This PR fixes an issue where the `jetty/numOpenConnections` metric is double 
counted for SSL connections due to the way _all_ `ConnectionFactory` instances 
are wrapped in `JettyMonitoringConnectionFactory` in `JettyServerModule` 
initialization, instead of what I believe to be the correct usage of only 
monitoring the default `ConnectionFactory` for the `ServerConnector`. 
   
   The TLS `ServerConnector` is constructed with 2 `ConnectionFactory` 
instances:
   
   ```
   ...
         final ServerConnector connector = new ServerConnector(
             server,
             new SslConnectionFactory(sslContextFactory, HTTP_1_1_STRING),
             new HttpConnectionFactory(httpsConfiguration)
         );
   ...
   ```
   
   It is my understanding (and observation using the debugger) that _both_ 
create a connection, the `SslConnectionFactory` to un-encrypt the request 
connection, and the `HttpConnectionFactory` to do HTTP stuff to the now 
un-encrypted connection. However, since both of these were prior to this PR 
wrapped in `JettyMonitoringConnectionFactory`, a single TLS connection would 
count as 2 active connections, despite only 1 request being made. This PR 
modifies `JettyServerModule` to now only monitor the `ConnectionFactory` with 
the same protocol as the default `ServerConnector` protocol to correctly single 
count the connection.
   
   The added test `JettyTest.testNumConnectionsMetricHttps` fails without the 
modifications to `JettyServerModule`. The keystore/truststore in the test 
resources were generated in the same manner as used in the integration tests.
   
   
   <hr>
   
   This PR has:
   - [ ] been self-reviewed.
   - [x] added comments explaining the "why" and the intent of the code 
wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths.
   - [x] been tested in a test Druid cluster.
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not 
all of these items apply to every PR. Remove the items which are not done or 
not relevant to the PR. None of the items from the checklist above are strictly 
necessary, but it would be very helpful if you at least self-review the PR. -->
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `JettyServerModule`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to