Repository navigation
ref(core): Add SentryRuntime for the SDK's own collaborators #6830
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
Draft
runningcode
wants to merge
1
commit into
main
Choose a base branch
from
no/sentryruntime-foundation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+525
โ10
Draft
Changes from all commits
Commits
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
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
19 changes: 19 additions & 0 deletions
19
sentry/src/main/java/io/sentry/internal/InternalIntegration.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,19 @@ | ||
| package io.sentry.internal; | ||
|
|
||
| import io.sentry.IScopes; | ||
| import io.sentry.Integration; | ||
| import io.sentry.SentryOptions; | ||
| import org.jetbrains.annotations.ApiStatus; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| /** | ||
| * An SDK integration that needs the SDK's own collaborators. Customers create integrations before | ||
| * {@code Sentry.init}, so they can't be constructor-injected; {@code Sentry.init} hands them over | ||
| * here instead. | ||
| */ | ||
| @ApiStatus.Internal | ||
| public interface InternalIntegration extends Integration { | ||
|
|
||
| void register( | ||
| @NotNull IScopes scopes, @NotNull SentryOptions options, @NotNull SentryRuntime runtime); | ||
| } |
63 changes: 63 additions & 0 deletions
63
sentry/src/main/java/io/sentry/internal/LazySerializer.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,63 @@ | ||
| package io.sentry.internal; | ||
|
|
||
| import io.sentry.ISerializer; | ||
| import io.sentry.JsonDeserializer; | ||
| import io.sentry.SentryEnvelope; | ||
| import io.sentry.util.LazyEvaluator; | ||
| import java.io.IOException; | ||
| import java.io.InputStream; | ||
| import java.io.OutputStream; | ||
| import java.io.Reader; | ||
| import java.io.Writer; | ||
| import java.util.Map; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Creates the real serializer, which is expensive, on first use, so components can take an {@link | ||
| * ISerializer} in their constructor without creating it during init. | ||
| */ | ||
| final class LazySerializer implements ISerializer { | ||
|
|
||
| private final @NotNull LazyEvaluator<ISerializer> serializer; | ||
|
|
||
| LazySerializer(final @NotNull LazyEvaluator.Evaluator<ISerializer> serializer) { | ||
| this.serializer = new LazyEvaluator<>(serializer); | ||
| } | ||
|
|
||
| @Override | ||
| public <T, R> @Nullable T deserializeCollection( | ||
| final @NotNull Reader reader, | ||
| final @NotNull Class<T> clazz, | ||
| final @Nullable JsonDeserializer<R> elementDeserializer) { | ||
| return serializer.getValue().deserializeCollection(reader, clazz, elementDeserializer); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> @Nullable T deserialize(final @NotNull Reader reader, final @NotNull Class<T> clazz) { | ||
| return serializer.getValue().deserialize(reader, clazz); | ||
| } | ||
|
|
||
| @Override | ||
| public @Nullable SentryEnvelope deserializeEnvelope(final @NotNull InputStream inputStream) { | ||
| return serializer.getValue().deserializeEnvelope(inputStream); | ||
| } | ||
|
|
||
| @Override | ||
| public <T> void serialize(final @NotNull T entity, final @NotNull Writer writer) | ||
| throws IOException { | ||
| serializer.getValue().serialize(entity, writer); | ||
| } | ||
|
|
||
| @Override | ||
| public void serialize( | ||
| final @NotNull SentryEnvelope envelope, final @NotNull OutputStream outputStream) | ||
| throws Exception { | ||
| serializer.getValue().serialize(envelope, outputStream); | ||
| } | ||
|
|
||
| @Override | ||
| public @NotNull String serialize(final @NotNull Map<String, Object> data) throws Exception { | ||
| return serializer.getValue().serialize(data); | ||
| } | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hybrid init with profiling leaks the executor created before the runtime override
When a hybrid config supplies
runtime.executorService(...)and enables profiling,activate()creates an executor on options andinitConfigurations()submits profiling cleanup to it before the runtime replaces it;Sentry.close()closes only the replacement, leaving the original worker alive.Evidence
InternalSentrySdk.initpasses the builder to the configuration callback, so a hybrid can setruntime.executorService(...)without setting the options executor.Sentry.initcallsoptions.activate()beforeinitConfigurations()and builds the runtime afterward. With the options executor unset,activate()creates aSentryExecutorService; when profiling is enabled,initConfigurations()submits cleanup to it. Android initialization supplies a cache path, so the profiling-traces path is available.LegacyOptionsBridge.buildRuntimethen replaces the options executor with the builderโs executor without closing the previous one. The defaultSentryExecutorServicedoes not time out its core worker, andSentry.close()closes only the executor currently on options.Also found at 1 additional location
sentry/src/main/java/io/sentry/internal/LegacyOptionsBridge.java:32-43Identified by Warden ยท code-review ยท CXK-F6A