From 71f8af5ccbbc3c95cb1cdadc13f11d36e0e2aa4d Mon Sep 17 00:00:00 2001 From: Claire Dagan Date: Thu, 9 Jan 2025 15:03:06 +0100 Subject: [PATCH 1/2] [Tech] Add environment and version in Sentry config --- .../fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt | 10 +++++++--- infra/configurations/application-dev.properties | 2 ++ infra/configurations/application-prod.properties | 2 ++ infra/remote/docker-compose.yml | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt index 65f673bd19..f37706f3e3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt @@ -6,8 +6,7 @@ import org.slf4j.LoggerFactory import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.boot.runApplication -@SpringBootApplication -class MonitorFishApplication +@SpringBootApplication class MonitorFishApplication fun main(args: Array) { val ctx = runApplication(*args) @@ -15,11 +14,16 @@ fun main(args: Array) { val isSentryEnabled: String? = ctx.environment.getProperty("monitorfish.sentry.enabled") val sentryDsn: String? = ctx.environment.getProperty("sentry.dsn") + val sentryEnvironment: String? = ctx.environment.getProperty("monitorfish.sentry.environment") + val sentryVersion: String? = ctx.environment.getProperty("monitorfish.sentry.version") if (isSentryEnabled == "true") { Sentry.init { options -> options.dsn = sentryDsn - // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. + options.environment = sentryEnvironment + options.release = sentryVersion + // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance + // monitoring. // We recommend adjusting this value in production. options.tracesSampleRate = 1.0 } diff --git a/infra/configurations/application-dev.properties b/infra/configurations/application-dev.properties index 8bb2b8eb24..4ff2f1df45 100644 --- a/infra/configurations/application-dev.properties +++ b/infra/configurations/application-dev.properties @@ -8,6 +8,8 @@ monitorfish.database.missionsActionsChunkSize=100 host.ip=http://monitorfish-test.csam.e2.rie.gouv.fr monitorenv.api=http://monitorenv.kadata.fr monitorfish.sentry.enabled=true +monitorfish.sentry.environment=integration +monitorfish.sentry.version=${MONITORFISH_VERSION} sentry.dsn= monitorfish.oidc.enabled=true diff --git a/infra/configurations/application-prod.properties b/infra/configurations/application-prod.properties index 098d39ac34..ec07d8d5b3 100644 --- a/infra/configurations/application-prod.properties +++ b/infra/configurations/application-prod.properties @@ -8,6 +8,8 @@ monitorfish.database.missionsActionsChunkSize=100 host.ip=http://monitorfish.din.developpement-durable.gouv.fr monitorenv.url=https://monitorenv.din.developpement-durable.gouv.fr monitorfish.sentry.enabled=true +monitorfish.sentry.environment=production +monitorfish.sentry.version=${MONITORFISH_VERSION} sentry.dsn=https://a5f3272efa794bb9ada2ffea90f2fec5@sentry.incubateur.net/8 monitorfish.oidc.enabled=false diff --git a/infra/remote/docker-compose.yml b/infra/remote/docker-compose.yml index 1130facef1..8e39af4fcf 100644 --- a/infra/remote/docker-compose.yml +++ b/infra/remote/docker-compose.yml @@ -26,6 +26,7 @@ services: - MONITORFISH_HTTP_PROXY_HOST=$MONITORFISH_HTTP_PROXY_HOST - MONITORFISH_HTTP_PROXY_PORT=$MONITORFISH_HTTP_PROXY_PORT - MONITORFISH_HTTP_NON_PROXY_HOSTS=$MONITORFISH_HTTP_NON_PROXY_HOSTS + - MONITORFISH_VERSION=$MONITORFISH_VERSION - ENV_DB_URL=jdbc:postgresql://db:5432/$POSTGRES_DB?user=$POSTGRES_USER&password=$POSTGRES_PASSWORD - FRONTEND_GEOSERVER_REMOTE_URL=$MONITORFISH_GEOSERVER_REMOTE_URL - FRONTEND_GEOSERVER_LOCAL_URL=$MONITORFISH_GEOSERVER_LOCAL_URL From c70ba5f2d258c78b287f5816fc88e29f6c19bfb1 Mon Sep 17 00:00:00 2001 From: Loup Theron Date: Mon, 13 Jan 2025 09:48:20 +0100 Subject: [PATCH 2/2] Refactor envs and use existing envs --- .../fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt | 6 +++--- infra/configurations/application-dev.properties | 2 -- infra/configurations/application-prod.properties | 2 -- infra/remote/docker-compose.yml | 1 + 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt index f37706f3e3..03fdf9e7b3 100644 --- a/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt +++ b/backend/src/main/kotlin/fr/gouv/cnsp/monitorfish/MonitorFishApplication.kt @@ -14,14 +14,14 @@ fun main(args: Array) { val isSentryEnabled: String? = ctx.environment.getProperty("monitorfish.sentry.enabled") val sentryDsn: String? = ctx.environment.getProperty("sentry.dsn") - val sentryEnvironment: String? = ctx.environment.getProperty("monitorfish.sentry.environment") - val sentryVersion: String? = ctx.environment.getProperty("monitorfish.sentry.version") + val sentryEnvironment: String? = ctx.environment.getProperty("monitorfish.sentry.env") + val version: String? = ctx.environment.getProperty("monitorfish.version") if (isSentryEnabled == "true") { Sentry.init { options -> options.dsn = sentryDsn options.environment = sentryEnvironment - options.release = sentryVersion + options.release = version // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance // monitoring. // We recommend adjusting this value in production. diff --git a/infra/configurations/application-dev.properties b/infra/configurations/application-dev.properties index 4ff2f1df45..8bb2b8eb24 100644 --- a/infra/configurations/application-dev.properties +++ b/infra/configurations/application-dev.properties @@ -8,8 +8,6 @@ monitorfish.database.missionsActionsChunkSize=100 host.ip=http://monitorfish-test.csam.e2.rie.gouv.fr monitorenv.api=http://monitorenv.kadata.fr monitorfish.sentry.enabled=true -monitorfish.sentry.environment=integration -monitorfish.sentry.version=${MONITORFISH_VERSION} sentry.dsn= monitorfish.oidc.enabled=true diff --git a/infra/configurations/application-prod.properties b/infra/configurations/application-prod.properties index ec07d8d5b3..098d39ac34 100644 --- a/infra/configurations/application-prod.properties +++ b/infra/configurations/application-prod.properties @@ -8,8 +8,6 @@ monitorfish.database.missionsActionsChunkSize=100 host.ip=http://monitorfish.din.developpement-durable.gouv.fr monitorenv.url=https://monitorenv.din.developpement-durable.gouv.fr monitorfish.sentry.enabled=true -monitorfish.sentry.environment=production -monitorfish.sentry.version=${MONITORFISH_VERSION} sentry.dsn=https://a5f3272efa794bb9ada2ffea90f2fec5@sentry.incubateur.net/8 monitorfish.oidc.enabled=false diff --git a/infra/remote/docker-compose.yml b/infra/remote/docker-compose.yml index 8e39af4fcf..e2d29fe9f7 100644 --- a/infra/remote/docker-compose.yml +++ b/infra/remote/docker-compose.yml @@ -45,6 +45,7 @@ services: - MONITORFISH_API_PROTECTED_PATHS=$MONITORFISH_API_PROTECTED_PATHS - MONITORFISH_API_PROTECTED_PUBLIC_PATHS=$MONITORFISH_API_PROTECTED_PUBLIC_PATHS - MONITORFISH_SCHEDULING_ENABLED=$MONITORFISH_SCHEDULING_ENABLED + - MONITORFISH_SENTRY_ENV=$MONITORFISH_SENTRY_ENV - FRONTEND_SENTRY_ENV=$MONITORFISH_SENTRY_ENV - SENTRY_DSN=$MONITORFISH_SENTRY_DSN - FRONTEND_SENTRY_DSN=$MONITORFISH_SENTRY_DSN