This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new d50cf17ede [KYUUBI #6615] Make Jetty sending server version in
response configurable
d50cf17ede is described below
commit d50cf17edeb12e6eb4da22575f82ba7579d4a3be
Author: zhang_yao <[email protected]>
AuthorDate: Tue Dec 24 21:16:39 2024 +0800
[KYUUBI #6615] Make Jetty sending server version in response configurable
# :mag: Description
## Issue References ๐
This pull request fixes #6615
## Describe Your Solution ๐ง
Add a config item that controls whether Jetty should send its version in
response.
This is an additional patch which enables/disables sending Jetty version
for prometheus reporter.
Sending Jetty version could be disabled by calling
HttpConfiguration::setSendServerVersion(false)
## Types of changes :bookmark:
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
Compiled and tested manually.
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklist ๐
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
**Be nice. Be informative.**
Closes #6685 from paul8263/KYUUBI-6615-patch.
Closes #6615
0638a5116 [zhang_yao] [KYUUBI #6615] Make Jetty sending server version in
response configurable
Authored-by: zhang_yao <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../kyuubi/metrics/PrometheusReporterService.scala | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git
a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/PrometheusReporterService.scala
b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/PrometheusReporterService.scala
index ab014caf14..e62e219090 100644
---
a/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/PrometheusReporterService.scala
+++
b/kyuubi-metrics/src/main/scala/org/apache/kyuubi/metrics/PrometheusReporterService.scala
@@ -21,11 +21,12 @@ import com.codahale.metrics.MetricRegistry
import io.prometheus.client.CollectorRegistry
import io.prometheus.client.dropwizard.DropwizardExports
import io.prometheus.client.exporter.MetricsServlet
-import org.eclipse.jetty.server.Server
+import org.eclipse.jetty.server.{HttpConfiguration, HttpConnectionFactory,
Server, ServerConnector}
import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}
import org.apache.kyuubi.KyuubiException
import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiConf.FRONTEND_JETTY_SEND_VERSION_ENABLED
import org.apache.kyuubi.service.AbstractService
class PrometheusReporterService(registry: MetricRegistry)
@@ -35,12 +36,21 @@ class PrometheusReporterService(registry: MetricRegistry)
// VisibleForTesting
private[metrics] var httpServer: Server = _
+ private[metrics] var httpServerConnector: ServerConnector = _
@volatile protected var isStarted = false
override def initialize(conf: KyuubiConf): Unit = {
val port = conf.get(MetricsConf.METRICS_PROMETHEUS_PORT)
val contextPath = conf.get(MetricsConf.METRICS_PROMETHEUS_PATH)
- httpServer = new Server(port)
+ val jettyVersionEnabled = conf.get(FRONTEND_JETTY_SEND_VERSION_ENABLED)
+
+ val httpConf = new HttpConfiguration()
+ httpConf.setSendServerVersion(jettyVersionEnabled)
+ httpServer = new Server()
+ httpServerConnector = new ServerConnector(httpServer, new
HttpConnectionFactory(httpConf))
+ httpServerConnector.setPort(port)
+ httpServer.addConnector(httpServerConnector)
+
val context = new ServletContextHandler
context.setContextPath("/")
httpServer.setHandler(context)
@@ -56,6 +66,7 @@ class PrometheusReporterService(registry: MetricRegistry)
if (!isStarted) {
try {
httpServer.start()
+ httpServerConnector.start()
info(s"Prometheus metrics HTTP server has started at
${httpServer.getURI}.")
} catch {
case rethrow: Exception =>
@@ -78,12 +89,14 @@ class PrometheusReporterService(registry: MetricRegistry)
private def stopHttpServer(): Unit = {
if (httpServer != null) {
try {
+ httpServerConnector.stop()
httpServer.stop()
info("Prometheus metrics HTTP server has stopped.")
} catch {
case err: Exception => error("Cannot safely stop prometheus metrics
HTTP server", err)
} finally {
httpServer = null
+ httpServerConnector = null
}
}
}