[KYUUBI #7045] Expose jetty metrics
### Why are the changes needed? Expose the jetty metrics to help detect issue. Refer: https://metrics.dropwizard.io/4.2.0/manual/jetty.html ### How was this patch tested? <img width="1425" alt="image" src="https://github.com/user-attachments/assets/ac8c9a48-eaa1-48ee-afec-6f33980d4270" /> <img width="1283" alt="image" src="https://github.com/user-attachments/assets/c2fa444b-6337-4662-832b-3d02f206bd13" /> ### Was this patch authored or co-authored using generative AI tooling? No. Closes #7045 from turboFei/metrics_jetty. Closes #7045 122b93f3d [Wang, Fei] metrics 45a73e7cd [Wang, Fei] metrics Authored-by: Wang, Fei <fwang12@ebay.com> Signed-off-by: Wang, Fei <fwang12@ebay.com>
This commit is contained in:
parent
3e638b61c3
commit
4cbff4d192
@ -129,7 +129,9 @@ log4j-core/2.24.3//log4j-core-2.24.3.jar
|
||||
log4j-layout-template-json/2.24.3//log4j-layout-template-json-2.24.3.jar
|
||||
log4j-slf4j-impl/2.24.3//log4j-slf4j-impl-2.24.3.jar
|
||||
logging-interceptor/3.12.12//logging-interceptor-3.12.12.jar
|
||||
metrics-annotation/4.2.26//metrics-annotation-4.2.26.jar
|
||||
metrics-core/4.2.26//metrics-core-4.2.26.jar
|
||||
metrics-jetty9/4.2.26//metrics-jetty9-4.2.26.jar
|
||||
metrics-jmx/4.2.26//metrics-jmx-4.2.26.jar
|
||||
metrics-json/4.2.26//metrics-json-4.2.26.jar
|
||||
metrics-jvm/4.2.26//metrics-jvm-4.2.26.jar
|
||||
|
||||
@ -95,4 +95,7 @@ object MetricsConstants {
|
||||
final val METADATA_REQUEST_TOTAL = METADATA_REQUEST + "total"
|
||||
final val METADATA_REQUEST_FAIL = METADATA_REQUEST + "failed"
|
||||
final val METADATA_REQUEST_RETRYING = METADATA_REQUEST + "retrying"
|
||||
|
||||
final private val JETTY = KYUUBI + "jetty."
|
||||
final val JETTY_API_V1 = JETTY + "api.v1"
|
||||
}
|
||||
|
||||
@ -105,6 +105,8 @@ object MetricsSystem {
|
||||
|
||||
@volatile private var maybeSystem: Option[MetricsSystem] = None
|
||||
|
||||
private[kyuubi] def getMetricsRegistry: Option[MetricRegistry] = maybeSystem.map(_.registry)
|
||||
|
||||
def tracing[T](func: MetricsSystem => T): Unit = {
|
||||
maybeSystem.foreach(func(_))
|
||||
}
|
||||
|
||||
@ -218,6 +218,11 @@
|
||||
<artifactId>jetty-proxy</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-jetty9</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.test-framework</groupId>
|
||||
<artifactId>jersey-test-framework-core</artifactId>
|
||||
|
||||
@ -31,8 +31,8 @@ import org.eclipse.jetty.servlet.{ErrorPageErrorHandler, FilterHolder}
|
||||
import org.apache.kyuubi.{KyuubiException, Utils}
|
||||
import org.apache.kyuubi.config.KyuubiConf
|
||||
import org.apache.kyuubi.config.KyuubiConf._
|
||||
import org.apache.kyuubi.metrics.{MetricsConstants, MetricsSystem}
|
||||
import org.apache.kyuubi.metrics.MetricsConstants.OPERATION_BATCH_PENDING_MAX_ELAPSE
|
||||
import org.apache.kyuubi.metrics.MetricsSystem
|
||||
import org.apache.kyuubi.server.api.v1.ApiRootResource
|
||||
import org.apache.kyuubi.server.http.authentication.{AuthenticationFilter, KyuubiHttpAuthenticationFactory}
|
||||
import org.apache.kyuubi.server.ui.{JettyServer, JettyUtils}
|
||||
@ -118,7 +118,9 @@ class KyuubiRestFrontendService(override val serverable: Serverable)
|
||||
val holder = new FilterHolder(new AuthenticationFilter(conf))
|
||||
contextHandler.addFilter(holder, "/v1/*", EnumSet.allOf(classOf[DispatcherType]))
|
||||
val authenticationFactory = new KyuubiHttpAuthenticationFactory(conf)
|
||||
server.addHandler(authenticationFactory.httpHandlerWrapperFactory.wrapHandler(contextHandler))
|
||||
server.addHandler(authenticationFactory.httpHandlerWrapperFactory.wrapHandler(
|
||||
contextHandler,
|
||||
Some(MetricsConstants.JETTY_API_V1)))
|
||||
|
||||
val proxyHandler = ApiRootResource.getEngineUIProxyHandler(this)
|
||||
server.addHandler(authenticationFactory.httpHandlerWrapperFactory.wrapHandler(proxyHandler))
|
||||
|
||||
@ -20,6 +20,7 @@ package org.apache.kyuubi.server.http.authentication
|
||||
import java.security.PrivilegedAction
|
||||
import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
|
||||
|
||||
import com.codahale.metrics.jetty9.InstrumentedHandler
|
||||
import org.apache.hadoop.security.UserGroupInformation
|
||||
import org.eclipse.jetty.server.{Handler, Request}
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper
|
||||
@ -44,8 +45,8 @@ class KyuubiHttpAuthenticationFactory(conf: KyuubiConf) {
|
||||
new HttpHandlerWrapperFactory(ugi, kerberosEnabled)
|
||||
|
||||
class HttpHandlerWrapperFactory(ugi: UserGroupInformation, kerberosEnabled: Boolean) {
|
||||
def wrapHandler(handler: Handler): HandlerWrapper = {
|
||||
new HandlerWrapper {
|
||||
def wrapHandler(handler: Handler, metricPrefix: Option[String] = None): HandlerWrapper = {
|
||||
val handlerWrapper = new HandlerWrapper {
|
||||
_handler = handler
|
||||
|
||||
override def handle(
|
||||
@ -91,6 +92,14 @@ class KyuubiHttpAuthenticationFactory(conf: KyuubiConf) {
|
||||
handler.start()
|
||||
}
|
||||
}
|
||||
|
||||
(MetricsSystem.getMetricsRegistry, metricPrefix) match {
|
||||
case (Some(metricRegistry), Some(prefix)) =>
|
||||
val instrumentedHandler = new InstrumentedHandler(metricRegistry, prefix)
|
||||
instrumentedHandler.setHandler(handlerWrapper)
|
||||
instrumentedHandler
|
||||
case _ => handlerWrapper
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
pom.xml
6
pom.xml
@ -693,6 +693,12 @@
|
||||
<version>${codahale.metrics.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-jetty9</artifactId>
|
||||
<version>${codahale.metrics.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user