Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version to sentryClientName used in auth header #2596

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}

Expand Down Expand Up @@ -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 ""
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
}

Expand Down Expand Up @@ -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 ""
}
}