From f17822c69ca6c00df19b40263814d804c6d96486 Mon Sep 17 00:00:00 2001 From: Milan Boers Date: Thu, 10 Apr 2025 14:05:36 +0200 Subject: [PATCH 1/3] Make RequestDetailsResolver public --- sentry/api/sentry.api | 6 ++++ .../io/sentry/RequestDetailsResolver.java | 30 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sentry/api/sentry.api b/sentry/api/sentry.api index 796284690d8..d9824943b88 100644 --- a/sentry/api/sentry.api +++ b/sentry/api/sentry.api @@ -2174,6 +2174,12 @@ public final class io/sentry/RequestDetails { public fun getUrl ()Ljava/net/URL; } +public final class io/sentry/RequestDetailsResolver { + public fun (Lio/sentry/SentryOptions;)V + public fun (Ljava/lang/String;Ljava/lang/String;)V + public fun resolve ()Lio/sentry/RequestDetails; +} + public final class io/sentry/SamplingContext { public fun (Lio/sentry/TransactionContext;Lio/sentry/CustomSamplingContext;)V public fun (Lio/sentry/TransactionContext;Lio/sentry/CustomSamplingContext;Ljava/lang/Double;Ljava/util/Map;)V diff --git a/sentry/src/main/java/io/sentry/RequestDetailsResolver.java b/sentry/src/main/java/io/sentry/RequestDetailsResolver.java index bba4dc19ac0..97dfc8318b4 100644 --- a/sentry/src/main/java/io/sentry/RequestDetailsResolver.java +++ b/sentry/src/main/java/io/sentry/RequestDetailsResolver.java @@ -4,24 +4,39 @@ import java.net.URI; import java.util.HashMap; import java.util.Map; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** Resolves {@link RequestDetails}. */ -final class RequestDetailsResolver { +@ApiStatus.Experimental +public final class RequestDetailsResolver { /** HTTP Header for the user agent. */ private static final String USER_AGENT = "User-Agent"; /** HTTP Header for the authentication to Sentry. */ private static final String SENTRY_AUTH = "X-Sentry-Auth"; - private final @NotNull SentryOptions options; + private final @NotNull Dsn dsn; + private final @Nullable String sentryClientName; + public RequestDetailsResolver( + final @NotNull String dsn, final @Nullable String sentryClientName) { + Objects.requireNonNull(dsn, "dsn is required"); + + this.dsn = new Dsn(dsn); + this.sentryClientName = sentryClientName; + } + + @ApiStatus.Internal public RequestDetailsResolver(final @NotNull SentryOptions options) { - this.options = Objects.requireNonNull(options, "options is required"); + Objects.requireNonNull(options, "options is required"); + + this.dsn = options.retrieveParsedDsn(); + this.sentryClientName = options.getSentryClientName(); } @NotNull - RequestDetails resolve() { - final Dsn dsn = options.retrieveParsedDsn(); + public RequestDetails resolve() { final URI sentryUri = dsn.getSentryUri(); final String envelopeUrl = sentryUri.resolve(sentryUri.getPath() + "/envelope/").toString(); @@ -33,15 +48,14 @@ RequestDetails resolve() { + SentryClient.SENTRY_PROTOCOL_VERSION + "," + "sentry_client=" - + options.getSentryClientName() + + sentryClientName + "," + "sentry_key=" + publicKey + (secretKey != null && secretKey.length() > 0 ? (",sentry_secret=" + secretKey) : ""); - final String userAgent = options.getSentryClientName(); final Map headers = new HashMap<>(); - headers.put(USER_AGENT, userAgent); + headers.put(USER_AGENT, sentryClientName); headers.put(SENTRY_AUTH, authHeader); return new RequestDetails(envelopeUrl, headers); From 0600e596a99bb1ebc5cbac1af28cb7227a8164f1 Mon Sep 17 00:00:00 2001 From: lcian Date: Mon, 28 Apr 2025 11:43:25 +0200 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88fbeb38206..978fc32d38d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - Set `-Dio.opentelemetry.context.contextStorageProvider=io.sentry.opentelemetry.SentryContextStorageProvider` on your `java` command - Sentry will then wrap the other `ContextStorageProvider` that has been configured by loading it through SPI - If no other `ContextStorageProvider` is available or there are problems loading it, we fall back to using `SentryOtelThreadLocalStorage` +- Make `RequestDetailsResolver` public ([#4326](https://github.com/getsentry/sentry-java/pull/4326)) + - `RequestDetailsResolver` is now public and has an additional constructor, making it easier to use a custom `TransportFactory` ### Fixes From a63f8e515a1eedeb7a2cc95cd0b97898de3b77c2 Mon Sep 17 00:00:00 2001 From: Lorenzo Cian Date: Mon, 28 Apr 2025 11:54:47 +0200 Subject: [PATCH 3/3] correct changelog --- CHANGELOG.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 978fc32d38d..4495100edb4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## Unreleased + +### Features + +- Make `RequestDetailsResolver` public ([#4326](https://github.com/getsentry/sentry-java/pull/4326)) + - `RequestDetailsResolver` is now public and has an additional constructor, making it easier to use a custom `TransportFactory` + ## 8.10.0 ### Features @@ -9,9 +16,7 @@ - Set `-Dio.opentelemetry.context.contextStorageProvider=io.sentry.opentelemetry.SentryContextStorageProvider` on your `java` command - Sentry will then wrap the other `ContextStorageProvider` that has been configured by loading it through SPI - If no other `ContextStorageProvider` is available or there are problems loading it, we fall back to using `SentryOtelThreadLocalStorage` -- Make `RequestDetailsResolver` public ([#4326](https://github.com/getsentry/sentry-java/pull/4326)) - - `RequestDetailsResolver` is now public and has an additional constructor, making it easier to use a custom `TransportFactory` - + ### Fixes - Update profile chunk rate limit and client report ([#4353](https://github.com/getsentry/sentry-java/pull/4353))