From 1baf97a0f4e0948f14d13eff78c2202565a4fd68 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 9 Mar 2023 11:05:36 +0100 Subject: [PATCH 1/2] Add version to sentryClientName --- .../src/main/java/io/sentry/log4j2/SentryAppender.java | 3 ++- .../src/main/java/io/sentry/logback/SentryAppender.java | 3 ++- .../spring/boot/jakarta/SentryAutoConfiguration.java | 3 ++- .../spring/boot/jakarta/SentryAutoConfigurationTest.kt | 9 +-------- .../io/sentry/spring/boot/SentryAutoConfiguration.java | 3 ++- .../io/sentry/spring/boot/SentryAutoConfigurationTest.kt | 9 +-------- 6 files changed, 10 insertions(+), 20 deletions(-) diff --git a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java index 1fdd55e997..dd557ed833 100644 --- a/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java +++ b/sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java @@ -121,7 +121,8 @@ public void start() { if (debug != null) { options.setDebug(debug); } - options.setSentryClientName(BuildConfig.SENTRY_LOG4J2_SDK_NAME); + options.setSentryClientName( + BuildConfig.SENTRY_LOG4J2_SDK_NAME + "/" + BuildConfig.VERSION_NAME); options.setSdkVersion(createSdkVersion(options)); if (contextTags != null) { for (final String contextTag : contextTags) { diff --git a/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java b/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java index 40a2c72e11..a8f074b018 100644 --- a/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java +++ b/sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java @@ -50,7 +50,8 @@ public void start() { if (!Sentry.isEnabled()) { if (options.getDsn() == null || !options.getDsn().endsWith("_IS_UNDEFINED")) { options.setEnableExternalConfiguration(true); - options.setSentryClientName(BuildConfig.SENTRY_LOGBACK_SDK_NAME); + options.setSentryClientName( + BuildConfig.SENTRY_LOGBACK_SDK_NAME + "/" + BuildConfig.VERSION_NAME); options.setSdkVersion(createSdkVersion(options)); Optional.ofNullable(transportFactory).ifPresent(options::setTransportFactory); try { diff --git a/sentry-spring-boot-starter-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java b/sentry-spring-boot-starter-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java index 411c826c87..2a0def3722 100644 --- a/sentry-spring-boot-starter-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java +++ b/sentry-spring-boot-starter-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java @@ -115,7 +115,8 @@ static class HubConfiguration { } }); - options.setSentryClientName(BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME); + options.setSentryClientName( + BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME + "/" + BuildConfig.VERSION_NAME); options.setSdkVersion(createSdkVersion(options)); addPackageAndIntegrationInfo(); if (options.getTracesSampleRate() == null && options.getEnableTracing() == null) { diff --git a/sentry-spring-boot-starter-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt b/sentry-spring-boot-starter-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt index 0d2729eedf..0d7e363732 100644 --- a/sentry-spring-boot-starter-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-starter-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt @@ -244,7 +244,7 @@ class SentryAutoConfigurationTest { fun `sets sentryClientName property on SentryOptions`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .run { - assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot${optionalJakartaPrefix()}") + assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot.jakarta/${BuildConfig.VERSION_NAME}") } } @@ -924,11 +924,4 @@ class SentryAutoConfigurationTest { val userFilter = this.getBean("sentryUserFilter", FilterRegistrationBean::class.java).filter as SentryUserFilter return userFilter.sentryUserProviders } - - private fun optionalJakartaPrefix(): String { - if (this.javaClass.packageName.endsWith("jakarta")) { - return ".jakarta" - } - return "" - } } diff --git a/sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java b/sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java index 6e252c7eb2..c4183c002a 100644 --- a/sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java +++ b/sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java @@ -115,7 +115,8 @@ static class HubConfiguration { } }); - options.setSentryClientName(BuildConfig.SENTRY_SPRING_BOOT_SDK_NAME); + options.setSentryClientName( + BuildConfig.SENTRY_SPRING_BOOT_SDK_NAME + "/" + BuildConfig.VERSION_NAME); options.setSdkVersion(createSdkVersion(options)); addPackageAndIntegrationInfo(); if (options.getTracesSampleRate() == null && options.getEnableTracing() == null) { diff --git a/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt b/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt index abddd107d7..b9e858b8e2 100644 --- a/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt +++ b/sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt @@ -244,7 +244,7 @@ class SentryAutoConfigurationTest { fun `sets sentryClientName property on SentryOptions`() { contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj") .run { - assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot${optionalJakartaPrefix()}") + assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot/${BuildConfig.VERSION_NAME}") } } @@ -924,11 +924,4 @@ class SentryAutoConfigurationTest { val userFilter = this.getBean("sentryUserFilter", FilterRegistrationBean::class.java).filter as SentryUserFilter return userFilter.sentryUserProviders } - - private fun optionalJakartaPrefix(): String { - if (this.javaClass.packageName.endsWith("jakarta")) { - return ".jakarta" - } - return "" - } } From 5a48309688e19fa9fb994c7350417255237eb0d3 Mon Sep 17 00:00:00 2001 From: Alexander Dinauer Date: Thu, 9 Mar 2023 11:13:34 +0100 Subject: [PATCH 2/2] Add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7612ef19b..a3baa5d589 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Fixes - Deprecate reportFullDisplayed in favor of reportFullyDisplayed ([#2585](https://github.com/getsentry/sentry-java/pull/2585)) +- Add version to sentryClientName used in auth header ([#2596](https://github.com/getsentry/sentry-java/pull/2596)) ## 6.15.0