diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 9758aa84de..8472b66dd9 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -68,9 +68,7 @@ object Dependencies { val slf4jApi = "org.slf4j" % "slf4j-api" % "2.0.11" // the logging interface // Metrics - val aspectjweaver = "org.aspectj" % "aspectjweaver" % "1.9.21" - val kamonCore = "io.kamon" %% "kamon-core" % "2.7.0" // Scala 3 compatible - val kamonScalaFuture = "io.kamon" %% "kamon-scala-future" % "2.7.0" // Scala 3 incompatible + val aspectjweaver = "org.aspectj" % "aspectjweaver" % "1.9.21" // input validation val commonsValidator = @@ -164,8 +162,6 @@ object Dependencies { jakartaJSON, jenaText, jwtSprayJson, - kamonCore, - kamonScalaFuture, rdf4jShacl, saxonHE, scalaGraph, diff --git a/webapi/src/main/scala/org/knora/webapi/instrumentation/InstrumentationSupport.scala b/webapi/src/main/scala/org/knora/webapi/instrumentation/InstrumentationSupport.scala deleted file mode 100644 index 126ec5d836..0000000000 --- a/webapi/src/main/scala/org/knora/webapi/instrumentation/InstrumentationSupport.scala +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright © 2021 - 2024 Swiss National Data and Service Center for the Humanities and/or DaSCH Service Platform contributors. - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.knora.webapi.instrumentation - -import com.typesafe.scalalogging.Logger -import kamon.Kamon -import org.slf4j.LoggerFactory - -import scala.concurrent.ExecutionContext -import scala.concurrent.Future -import scala.util.Success - -/** - * A set of methods used for measuring stuff that is happening. - */ -trait InstrumentationSupport { - - /** - * For convenience. Returns the metrics logger based on the current - * class name. - */ - protected lazy val metricsLogger: Logger = getMetricsLoggerForClass - - /** - * Measures the time the future needs to complete. - * - * Example: - * - * val f = tracedFuture { - * Future { - * work inside the future - * } - * } - * - * @param name the name identifying the span. - * @param future the future we want to instrument. - */ - def tracedFuture[A](name: String)(future: => Future[A])(implicit ec: ExecutionContext): Future[A] = { - - /** - * NOTE: The elapsed time of the span is saved somewhere by kamon, but - * I have no idea how to get to it and this is why I'm calculating - * it in the metricsLogger.debug line. This is a quick and dirty hack to - * have at least something. - */ - val start = System.currentTimeMillis() - Kamon.span(name) { - future.andThen { case Success(_) => - metricsLogger.debug(s"$name: {} ms", System.currentTimeMillis() - start) - } - } - } - - /** - * Based on the current class name, create a logger with the name in the - * form 'M-ClassName', e.g., 'M-CacheManager'. - * All loggers returned by this method can be configured in 'logback.xml', - * i.e., turned on or off. - */ - def getMetricsLoggerForClass: Logger = { - val simpleClassName = this.getClass.getSimpleName - Logger(LoggerFactory.getLogger(s"M-$simpleClassName")) - } -} diff --git a/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala b/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala index 4d1f91842d..0c65b900a2 100644 --- a/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala +++ b/webapi/src/main/scala/org/knora/webapi/responders/admin/ProjectsResponderADM.scala @@ -17,7 +17,6 @@ import org.knora.webapi.* import org.knora.webapi.config.AppConfig import org.knora.webapi.core.MessageHandler import org.knora.webapi.core.MessageRelay -import org.knora.webapi.instrumentation.InstrumentationSupport import org.knora.webapi.messages.IriConversions.* import org.knora.webapi.messages.* import org.knora.webapi.messages.admin.responder.permissionsmessages.* @@ -186,8 +185,7 @@ final case class ProjectsResponderADMLive( implicit private val stringFormatter: StringFormatter ) extends ProjectsResponderADM with MessageHandler - with LazyLogging - with InstrumentationSupport { + with LazyLogging { // Global lock IRI used for project creation and update private val PROJECTS_GLOBAL_LOCK_IRI = "http://rdfh.ch/projects" diff --git a/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala b/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala index 5d2121e464..c8487d68f6 100644 --- a/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala +++ b/webapi/src/main/scala/org/knora/webapi/routing/AroundDirectives.scala @@ -5,12 +5,12 @@ package org.knora.webapi.routing +import com.typesafe.scalalogging.Logger import org.apache.pekko import org.apache.pekko.http.scaladsl.model.HttpResponse import org.apache.pekko.http.scaladsl.model.StatusCodes.MethodNotAllowed import org.apache.pekko.http.scaladsl.model.StatusCodes.NotFound - -import org.knora.webapi.instrumentation.InstrumentationSupport +import org.slf4j.LoggerFactory import pekko.http.scaladsl.server.Directive0 import pekko.http.scaladsl.server.Directives.* @@ -18,7 +18,9 @@ import pekko.http.scaladsl.server.Directives.* /** * Pekko HTTP directives which can be wrapped around a [[pekko.http.scaladsl.server.Route]]]. */ -trait AroundDirectives extends InstrumentationSupport { +trait AroundDirectives { + protected lazy val metricsLogger: Logger = + Logger(LoggerFactory.getLogger(s"M-this.getClass.getSimpleName")) /** * When wrapped around a [[pekko.http.scaladsl.server.Route]], logs the time it took for the route to run.