-
-
Notifications
You must be signed in to change notification settings - Fork 461
Use SpringServletTransactionNameProvider as fallback for Spring WebMVC
#4263
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
Merged
adinauer
merged 8 commits into
main
from
fix/use-servlet-transaction-name-provider-as-fallback
Mar 18, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
936dca6
Assume http.client for span op if not a root span
adinauer 7435268
changelog
adinauer 2beca0a
Use SpringServletTransactionNameProvider as fallback
adinauer 293191a
Merge branch 'main' into fix/use-servlet-transaction-name-provider-as…
adinauer 0d27f8b
changelog
adinauer c771cbe
review changes
adinauer a260f9d
Format code
getsentry-bot bd402ee
Merge branch 'main' into fix/use-servlet-transaction-name-provider-as…
adinauer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...karta/src/main/java/io/sentry/spring/jakarta/tracing/CombinedTransactionNameProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package io.sentry.spring.jakarta.tracing; | ||
|
|
||
| import io.sentry.protocol.TransactionNameSource; | ||
| import jakarta.servlet.http.HttpServletRequest; | ||
| import java.util.List; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Resolves transaction name using other transaction name providers by invoking them in order. If a | ||
| * provider returns no transaction name, the next one is invoked. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class CombinedTransactionNameProvider implements TransactionNameProvider { | ||
|
|
||
| private final @NotNull List<TransactionNameProvider> providers; | ||
|
|
||
| public CombinedTransactionNameProvider(final @NotNull List<TransactionNameProvider> providers) { | ||
| this.providers = providers; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable String provideTransactionName(@NotNull HttpServletRequest request) { | ||
| for (TransactionNameProvider provider : providers) { | ||
| String transactionName = provider.provideTransactionName(request); | ||
| if (transactionName != null) { | ||
| return transactionName; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| @ApiStatus.Internal | ||
| public @NotNull TransactionNameSource provideTransactionSource() { | ||
| return TransactionNameSource.CUSTOM; | ||
| } | ||
lcian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| @ApiStatus.Internal | ||
| @Override | ||
| public @NotNull TransactionNameWithSource provideTransactionNameAndSource( | ||
| @NotNull HttpServletRequest request) { | ||
| for (TransactionNameProvider provider : providers) { | ||
| String transactionName = provider.provideTransactionName(request); | ||
| if (transactionName != null) { | ||
| final @NotNull TransactionNameSource source = provider.provideTransactionSource(); | ||
| return new TransactionNameWithSource(transactionName, source); | ||
| } | ||
| } | ||
|
|
||
| return new TransactionNameWithSource(null, TransactionNameSource.CUSTOM); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ing-jakarta/src/main/java/io/sentry/spring/jakarta/tracing/TransactionNameWithSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package io.sentry.spring.jakarta.tracing; | ||
|
|
||
| import io.sentry.protocol.TransactionNameSource; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @ApiStatus.Internal | ||
| public final class TransactionNameWithSource { | ||
| private final @Nullable String transactionName; | ||
| private final @NotNull TransactionNameSource transactionNameSource; | ||
|
|
||
| public TransactionNameWithSource( | ||
| final @Nullable String transactionName, | ||
| final @NotNull TransactionNameSource transactionNameSource) { | ||
| this.transactionName = transactionName; | ||
| this.transactionNameSource = transactionNameSource; | ||
| } | ||
|
|
||
| public @Nullable String getTransactionName() { | ||
| return transactionName; | ||
| } | ||
|
|
||
| public @NotNull TransactionNameSource getTransactionNameSource() { | ||
| return transactionNameSource; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
sentry-spring/src/main/java/io/sentry/spring/tracing/CombinedTransactionNameProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package io.sentry.spring.tracing; | ||
|
|
||
| import io.sentry.protocol.TransactionNameSource; | ||
| import java.util.List; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Resolves transaction name using other transaction name providers by invoking them in order. If a | ||
| * provider returns no transaction name, the next one is invoked. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public final class CombinedTransactionNameProvider implements TransactionNameProvider { | ||
|
|
||
| private final @NotNull List<TransactionNameProvider> providers; | ||
|
|
||
| public CombinedTransactionNameProvider(final @NotNull List<TransactionNameProvider> providers) { | ||
| this.providers = providers; | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable String provideTransactionName(final @NotNull HttpServletRequest request) { | ||
lcian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for (TransactionNameProvider provider : providers) { | ||
| String transactionName = provider.provideTransactionName(request); | ||
| if (transactionName != null) { | ||
| return transactionName; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| @ApiStatus.Internal | ||
| public @NotNull TransactionNameSource provideTransactionSource() { | ||
| return TransactionNameSource.CUSTOM; | ||
| } | ||
|
|
||
| @ApiStatus.Internal | ||
| @Override | ||
| public @NotNull TransactionNameWithSource provideTransactionNameAndSource( | ||
| @NotNull HttpServletRequest request) { | ||
| for (TransactionNameProvider provider : providers) { | ||
| String transactionName = provider.provideTransactionName(request); | ||
| if (transactionName != null) { | ||
| final @NotNull TransactionNameSource source = provider.provideTransactionSource(); | ||
| return new TransactionNameWithSource(transactionName, source); | ||
| } | ||
| } | ||
|
|
||
| return new TransactionNameWithSource(null, TransactionNameSource.CUSTOM); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
sentry-spring/src/main/java/io/sentry/spring/tracing/TransactionNameWithSource.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package io.sentry.spring.tracing; | ||
|
|
||
| import io.sentry.protocol.TransactionNameSource; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| @ApiStatus.Internal | ||
| public final class TransactionNameWithSource { | ||
| private final @Nullable String transactionName; | ||
| private final @NotNull TransactionNameSource transactionNameSource; | ||
|
|
||
| public TransactionNameWithSource( | ||
| final @Nullable String transactionName, | ||
| final @NotNull TransactionNameSource transactionNameSource) { | ||
| this.transactionName = transactionName; | ||
| this.transactionNameSource = transactionNameSource; | ||
| } | ||
|
|
||
| public @Nullable String getTransactionName() { | ||
| return transactionName; | ||
| } | ||
|
|
||
| public @NotNull TransactionNameSource getTransactionNameSource() { | ||
| return transactionNameSource; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.