diff --git a/.github/workflows/scala.yml b/.github/workflows/scala.yml index adbd7ba5..acd7ae86 100644 --- a/.github/workflows/scala.yml +++ b/.github/workflows/scala.yml @@ -9,13 +9,19 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up JDK 1.8 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: 1.8 + distribution: temurin + java-version: 8 + cache: sbt - name: Run tests - run: sbt test + run: sbt clean coverage test coverageReport + - name: Codacy Coverage Reporter + uses: codacy/codacy-coverage-reporter-action@89d6c85cfafaec52c72b6c5e8b2878d33104c699 + with: + project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} diff --git a/Dockerfile b/Dockerfile index da1c38f0..ca1a53e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,8 @@ RUN yum update -y && yum install openssl -y RUN bash aws-certs.sh WORKDIR /opt/api +COPY sentry.properties . +COPY sentry-opentelemetry-agent.jar . COPY target/scala-2.13/dpla-api.jar . EXPOSE 8080 -CMD ["java", "-jar", "/opt/api/dpla-api.jar"] \ No newline at end of file +CMD ["java", "-javaagent:sentry-opentelemetry-agent.jar", "-jar", "/opt/api/dpla-api.jar"] \ No newline at end of file diff --git a/build.sbt b/build.sbt index f6a30e8d..ac3c4985 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,17 @@ lazy val akkaHttpVersion = "10.4.0" lazy val akkaVersion = "2.7.0" +lazy val openTelemetrySpecific = { + val version = "1.45.0" + Seq( + "io.opentelemetry" % "opentelemetry-bom" % version pomOnly(), + "io.opentelemetry" % "opentelemetry-api" % version, + "io.opentelemetry" % "opentelemetry-sdk" % version, + "io.opentelemetry" % "opentelemetry-sdk-extension-autoconfigure" % version, + "io.opentelemetry" % "opentelemetry-exporter-otlp" % version + ) +} + lazy val root = (project in file(".")) .configs(IntegrationTest) .settings( @@ -34,7 +45,8 @@ lazy val root = (project in file(".")) "com.typesafe.akka" %% "akka-http-testkit" % akkaHttpVersion % IntegrationTest, "com.typesafe.akka" %% "akka-actor-testkit-typed" % akkaVersion % IntegrationTest, "org.scalatest" %% "scalatest" % "3.2.11" % IntegrationTest - ) + ) ++ openTelemetrySpecific, + ) ThisBuild / assemblyMergeStrategy := { diff --git a/project/plugins.sbt b/project/plugins.sbt index 754df1a1..b4d3aa56 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,2 +1,3 @@ addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0") \ No newline at end of file +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") \ No newline at end of file diff --git a/sentry-opentelemetry-agent.jar b/sentry-opentelemetry-agent.jar new file mode 100644 index 00000000..6e7513fb Binary files /dev/null and b/sentry-opentelemetry-agent.jar differ diff --git a/sentry.properties b/sentry.properties new file mode 100644 index 00000000..57aa8ac9 --- /dev/null +++ b/sentry.properties @@ -0,0 +1,2 @@ +traces-sample-rate=1.0 +enable-tracing=true \ No newline at end of file diff --git a/src/main/scala/dpla/api/Routes.scala b/src/main/scala/dpla/api/Routes.scala index d930e5a5..42fc492c 100644 --- a/src/main/scala/dpla/api/Routes.scala +++ b/src/main/scala/dpla/api/Routes.scala @@ -40,7 +40,7 @@ class Routes( system.settings.config.getDuration("application.routes.askTimeout") ) - val log: Logger = LoggerFactory.getLogger("dpla.ebookapi.Routes") + val log: Logger = LoggerFactory.getLogger(getClass) // Requests are send to the appropriate register for processing. diff --git a/src/main/scala/dpla/api/RunApp.scala b/src/main/scala/dpla/api/RunApp.scala index 97bf8f99..8f91ca1c 100644 --- a/src/main/scala/dpla/api/RunApp.scala +++ b/src/main/scala/dpla/api/RunApp.scala @@ -96,7 +96,7 @@ object RunApp { Behaviors.empty } - ActorSystem[Nothing](rootBehavior, "HelloAkkaHttpServer") + ActorSystem[Nothing](rootBehavior, "DPLA API Server") //#server-bootstrapping } }