Skip to content

Commit dd03aa1

Browse files
authored
Add version to sentryClientName used in auth header (#2596)
1 parent 7c33bc1 commit dd03aa1

File tree

7 files changed

+11
-20
lines changed

7 files changed

+11
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Fixes
1010

1111
- Deprecate reportFullDisplayed in favor of reportFullyDisplayed ([#2585](https://github.com/getsentry/sentry-java/pull/2585))
12+
- Add version to sentryClientName used in auth header ([#2596](https://github.com/getsentry/sentry-java/pull/2596))
1213

1314
## 6.15.0
1415

sentry-log4j2/src/main/java/io/sentry/log4j2/SentryAppender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public void start() {
121121
if (debug != null) {
122122
options.setDebug(debug);
123123
}
124-
options.setSentryClientName(BuildConfig.SENTRY_LOG4J2_SDK_NAME);
124+
options.setSentryClientName(
125+
BuildConfig.SENTRY_LOG4J2_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
125126
options.setSdkVersion(createSdkVersion(options));
126127
if (contextTags != null) {
127128
for (final String contextTag : contextTags) {

sentry-logback/src/main/java/io/sentry/logback/SentryAppender.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ public void start() {
5050
if (!Sentry.isEnabled()) {
5151
if (options.getDsn() == null || !options.getDsn().endsWith("_IS_UNDEFINED")) {
5252
options.setEnableExternalConfiguration(true);
53-
options.setSentryClientName(BuildConfig.SENTRY_LOGBACK_SDK_NAME);
53+
options.setSentryClientName(
54+
BuildConfig.SENTRY_LOGBACK_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
5455
options.setSdkVersion(createSdkVersion(options));
5556
Optional.ofNullable(transportFactory).ifPresent(options::setTransportFactory);
5657
try {

sentry-spring-boot-starter-jakarta/src/main/java/io/sentry/spring/boot/jakarta/SentryAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ static class HubConfiguration {
115115
}
116116
});
117117

118-
options.setSentryClientName(BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME);
118+
options.setSentryClientName(
119+
BuildConfig.SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
119120
options.setSdkVersion(createSdkVersion(options));
120121
addPackageAndIntegrationInfo();
121122
if (options.getTracesSampleRate() == null && options.getEnableTracing() == null) {

sentry-spring-boot-starter-jakarta/src/test/kotlin/io/sentry/spring/boot/jakarta/SentryAutoConfigurationTest.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class SentryAutoConfigurationTest {
244244
fun `sets sentryClientName property on SentryOptions`() {
245245
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj")
246246
.run {
247-
assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot${optionalJakartaPrefix()}")
247+
assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot.jakarta/${BuildConfig.VERSION_NAME}")
248248
}
249249
}
250250

@@ -924,11 +924,4 @@ class SentryAutoConfigurationTest {
924924
val userFilter = this.getBean("sentryUserFilter", FilterRegistrationBean::class.java).filter as SentryUserFilter
925925
return userFilter.sentryUserProviders
926926
}
927-
928-
private fun optionalJakartaPrefix(): String {
929-
if (this.javaClass.packageName.endsWith("jakarta")) {
930-
return ".jakarta"
931-
}
932-
return ""
933-
}
934927
}

sentry-spring-boot-starter/src/main/java/io/sentry/spring/boot/SentryAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ static class HubConfiguration {
115115
}
116116
});
117117

118-
options.setSentryClientName(BuildConfig.SENTRY_SPRING_BOOT_SDK_NAME);
118+
options.setSentryClientName(
119+
BuildConfig.SENTRY_SPRING_BOOT_SDK_NAME + "/" + BuildConfig.VERSION_NAME);
119120
options.setSdkVersion(createSdkVersion(options));
120121
addPackageAndIntegrationInfo();
121122
if (options.getTracesSampleRate() == null && options.getEnableTracing() == null) {

sentry-spring-boot-starter/src/test/kotlin/io/sentry/spring/boot/SentryAutoConfigurationTest.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class SentryAutoConfigurationTest {
244244
fun `sets sentryClientName property on SentryOptions`() {
245245
contextRunner.withPropertyValues("sentry.dsn=http://key@localhost/proj")
246246
.run {
247-
assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot${optionalJakartaPrefix()}")
247+
assertThat(it.getBean(SentryOptions::class.java).sentryClientName).isEqualTo("sentry.java.spring-boot/${BuildConfig.VERSION_NAME}")
248248
}
249249
}
250250

@@ -924,11 +924,4 @@ class SentryAutoConfigurationTest {
924924
val userFilter = this.getBean("sentryUserFilter", FilterRegistrationBean::class.java).filter as SentryUserFilter
925925
return userFilter.sentryUserProviders
926926
}
927-
928-
private fun optionalJakartaPrefix(): String {
929-
if (this.javaClass.packageName.endsWith("jakarta")) {
930-
return ".jakarta"
931-
}
932-
return ""
933-
}
934927
}

0 commit comments

Comments
 (0)