From 761538c27e9fc67f6db8a375be1873cae6ed1da1 Mon Sep 17 00:00:00 2001 From: Jan Cizmar Date: Sun, 17 Dec 2023 19:05:02 +0100 Subject: [PATCH] fix: Fix Sentry logging (#2026) --- backend/api/build.gradle | 2 +- .../main/kotlin/io/tolgee/facade/ProjectWithStatsFacade.kt | 3 ++- backend/app/build.gradle | 2 +- .../io/tolgee/configuration/AsyncMethodConfiguration.kt | 6 +++--- .../io/tolgee/configuration/AsyncWebMvcConfiguration.kt | 4 ++-- backend/data/build.gradle | 2 +- .../main/kotlin/io/tolgee/batch/BatchJobActionService.kt | 2 +- backend/security/build.gradle | 3 +-- ee/backend/tests/build.gradle | 1 + settings.gradle | 4 +++- 10 files changed, 16 insertions(+), 13 deletions(-) diff --git a/backend/api/build.gradle b/backend/api/build.gradle index 8a2e1767b0..2596c38125 100644 --- a/backend/api/build.gradle +++ b/backend/api/build.gradle @@ -14,6 +14,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' id 'org.springframework.boot' apply false id "kotlin-allopen" + id "io.sentry.jvm.gradle" } group = 'io.tolgee' @@ -60,7 +61,6 @@ dependencies { * Misc */ implementation libs.commonsCodec - implementation libs.sentry implementation libs.jjwtApi implementation libs.jjwtImpl implementation libs.jjwtJackson diff --git a/backend/api/src/main/kotlin/io/tolgee/facade/ProjectWithStatsFacade.kt b/backend/api/src/main/kotlin/io/tolgee/facade/ProjectWithStatsFacade.kt index f1c6980810..1b7c0cd50c 100644 --- a/backend/api/src/main/kotlin/io/tolgee/facade/ProjectWithStatsFacade.kt +++ b/backend/api/src/main/kotlin/io/tolgee/facade/ProjectWithStatsFacade.kt @@ -86,7 +86,8 @@ class ProjectWithStatsFacade( return try { this.toBigDecimal().setScale(3, RoundingMode.HALF_UP) } catch (e: NumberFormatException) { - Sentry.captureException(e, "Failed to convert $this to BigDecimal") + Sentry.captureMessage("Failed to convert $this to BigDecimal") + Sentry.captureException(e) BigDecimal(0) } } diff --git a/backend/app/build.gradle b/backend/app/build.gradle index 244894663d..41579b93dc 100644 --- a/backend/app/build.gradle +++ b/backend/app/build.gradle @@ -16,6 +16,7 @@ plugins { id "kotlin-jpa" id "org.jetbrains.kotlin.kapt" id "kotlin-allopen" + id "io.sentry.jvm.gradle" } group = 'io.tolgee' @@ -97,7 +98,6 @@ dependencies { /** * MISC */ - implementation libs.sentry implementation libs.commonsCodec implementation libs.amazonS3 implementation libs.amazonSTS diff --git a/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncMethodConfiguration.kt b/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncMethodConfiguration.kt index 1a4a1fd41e..1e9e43abea 100644 --- a/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncMethodConfiguration.kt +++ b/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncMethodConfiguration.kt @@ -1,13 +1,13 @@ package io.tolgee.configuration -import io.sentry.spring.SentryTaskDecorator +import io.sentry.spring.jakarta.SentryTaskDecorator import org.springframework.context.annotation.Configuration -import org.springframework.scheduling.annotation.AsyncConfigurerSupport +import org.springframework.scheduling.annotation.AsyncConfigurer import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor import java.util.concurrent.Executor @Configuration -internal class AsyncMethodConfiguration : AsyncConfigurerSupport() { +class AsyncMethodConfiguration : AsyncConfigurer { override fun getAsyncExecutor(): Executor { val executor = ThreadPoolTaskExecutor() executor.setTaskDecorator(SentryTaskDecorator()) diff --git a/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncWebMvcConfiguration.kt b/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncWebMvcConfiguration.kt index ce56d98aa1..9ed3553c86 100644 --- a/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncWebMvcConfiguration.kt +++ b/backend/app/src/main/kotlin/io/tolgee/configuration/AsyncWebMvcConfiguration.kt @@ -1,6 +1,6 @@ package io.tolgee.configuration -import io.sentry.spring.SentryTaskDecorator +import io.sentry.spring.jakarta.SentryTaskDecorator import org.springframework.context.annotation.Configuration import org.springframework.core.task.AsyncTaskExecutor import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor @@ -9,7 +9,7 @@ import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer import org.springframework.web.servlet.config.annotation.WebMvcConfigurer @Configuration -internal class AsyncWebMvcConfiguration : WebMvcConfigurer { +class AsyncWebMvcConfiguration : WebMvcConfigurer { override fun configureAsyncSupport(configurer: AsyncSupportConfigurer) { configurer.setTaskExecutor(asyncExecutor()) } diff --git a/backend/data/build.gradle b/backend/data/build.gradle index e96ad2146b..b3b4c65623 100644 --- a/backend/data/build.gradle +++ b/backend/data/build.gradle @@ -20,6 +20,7 @@ plugins { id "org.jetbrains.kotlin.kapt" id "kotlin-allopen" id "org.hibernate.orm" + id "io.sentry.jvm.gradle" } group = 'io.tolgee' @@ -166,7 +167,6 @@ dependencies { implementation 'net.datafaker:datafaker:1.5.0' implementation 'jaxen:jaxen:1.2.0' implementation libs.sendInBlue - implementation libs.sentry implementation libs.hibernateTypes liquibaseRuntime libs.hibernateTypes implementation 'com.eatthepath:java-otp:0.4.0' diff --git a/backend/data/src/main/kotlin/io/tolgee/batch/BatchJobActionService.kt b/backend/data/src/main/kotlin/io/tolgee/batch/BatchJobActionService.kt index a0b1cf55c1..71b4f25af0 100644 --- a/backend/data/src/main/kotlin/io/tolgee/batch/BatchJobActionService.kt +++ b/backend/data/src/main/kotlin/io/tolgee/batch/BatchJobActionService.kt @@ -162,7 +162,7 @@ class BatchJobActionService( fn() } catch (e: Throwable) { logger.error("Error processing chunk ${executionItem.chunkExecutionId}", e) - Sentry.captureException(e, "Processing of chunk unexpectedly failed ${executionItem.chunkExecutionId}") + Sentry.captureException(e) val maxRetries = 10 if (++executionItem.managementErrorRetrials > maxRetries) { logger.error("Chunk ${executionItem.chunkExecutionId} failed $maxRetries times, failing...") diff --git a/backend/security/build.gradle b/backend/security/build.gradle index f79b8706d9..c21156307e 100644 --- a/backend/security/build.gradle +++ b/backend/security/build.gradle @@ -10,7 +10,7 @@ plugins { id 'org.jetbrains.kotlin.jvm' id 'org.springframework.boot' apply false id "kotlin-allopen" - + id "io.sentry.jvm.gradle" } group = 'io.tolgee.security' @@ -56,7 +56,6 @@ dependencies { * Misc */ implementation libs.commonsCodec - implementation libs.sentry implementation libs.jjwtApi implementation libs.jjwtImpl implementation libs.jjwtJackson diff --git a/ee/backend/tests/build.gradle b/ee/backend/tests/build.gradle index feabd8d3e5..7b5d7c49c6 100644 --- a/ee/backend/tests/build.gradle +++ b/ee/backend/tests/build.gradle @@ -12,6 +12,7 @@ plugins { id 'org.springframework.boot' apply false id "java" id "kotlin-allopen" + id "io.sentry.jvm.gradle" } apply plugin: "kotlin-allopen" diff --git a/settings.gradle b/settings.gradle index a9b018dc33..00ab12899c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,6 +23,9 @@ pluginManagement { if (requested.id.id == 'org.hibernate.orm') { useVersion(hibernateVersion) } + if(requested.id.id == 'io.sentry.jvm.gradle'){ + useVersion('4.0.0') + } } } } @@ -55,7 +58,6 @@ dependencyResolutionManagement { library('amazonSTS', "software.amazon.awssdk:sts:$amazonAwsSdkVersion") library('amazonTranslate', "software.amazon.awssdk:translate:$amazonAwsSdkVersion") library('googleCloud', "com.google.cloud:libraries-bom:24.0.0") - library('sentry', "io.sentry:sentry-spring-boot-starter:5.7.3") library('liquibaseCore', "org.liquibase:liquibase-core:4.25.0") library('liquibaseHibernate', "org.liquibase.ext:liquibase-hibernate6:4.25.0") library('liquibasePicoli', "info.picocli:picocli:4.6.3")