-
-
Notifications
You must be signed in to change notification settings - Fork 226
Allow to configure the ITransport to support custom serialization scenarios #944
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
21582f4
Allow to configure the to support custom serialization scenarios
pchinery fe56c1f
Update src/Sentry/SentryOptions.cs
pchinery c7430fb
Update src/Sentry/Internal/SdkComposer.cs
pchinery fd4f23a
Add test to verify that the custom transport is cached
pchinery 00161a6
Merge branch 'main' into main
Tyrrrz c42362b
Merge branch 'main' into main
Tyrrrz 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
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 | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,14 +15,8 @@ public SdkComposer(SentryOptions options) | |||||||||||||||||||||||
| if (options.Dsn is null) throw new ArgumentException("No DSN defined in the SentryOptions"); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private ITransport CreateTransport() | ||||||||||||||||||||||||
| private HttpTransport CreateHttpTransport() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| // Override for tests | ||||||||||||||||||||||||
| if (_options.Transport is not null) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| return _options.Transport; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (_options.SentryHttpClientFactory is { }) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| _options.DiagnosticLogger?.LogDebug( | ||||||||||||||||||||||||
|
|
@@ -34,16 +28,30 @@ private ITransport CreateTransport() | |||||||||||||||||||||||
| var httpClientFactory = _options.SentryHttpClientFactory ?? new DefaultSentryHttpClientFactory(); | ||||||||||||||||||||||||
| var httpClient = httpClientFactory.Create(_options); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| var httpTransport = new HttpTransport(_options, httpClient); | ||||||||||||||||||||||||
| return new HttpTransport(_options, httpClient); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| private ITransport CreateTransport() | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| ITransport transport; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if (_options.Transport is not null) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| transport = _options.Transport; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| else | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| transport = CreateHttpTransport(); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
Comment on lines
+36
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Non-caching transport | ||||||||||||||||||||||||
| if (string.IsNullOrWhiteSpace(_options.CacheDirectoryPath)) | ||||||||||||||||||||||||
| { | ||||||||||||||||||||||||
| return httpTransport; | ||||||||||||||||||||||||
| return transport; | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // Caching transport | ||||||||||||||||||||||||
| var cachingTransport = new CachingTransport(httpTransport, _options); | ||||||||||||||||||||||||
| var cachingTransport = new CachingTransport(transport, _options); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| // If configured, flush existing cache | ||||||||||||||||||||||||
| if (_options.InitCacheFlushTimeout > TimeSpan.Zero) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
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
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.
I think this was another reason @Tyrrrz wanted to make things internal.
He had some plans to refactor this so types don't need to implement this in order to be serialized.
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.
That's most likely something that goes beyond of my understanding of the code vision of the library right now. I'm happy to help, but if there was an idea how to do this already, I might not think in the direction @Tyrrrz wanted to bring this, so I think it's better to wait for him.
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.
As a temp workaround to avoid exposing
ISerializable, let's make:EnvelopeItem.Payloadinternal (or even private? can we do that?)EnvelopeItem.ctorinternal (we won't expose a public constructor for envelope)It's ugly but I think exposing
ISerializableright now will constrain us too much. I don't like exposingEnvelopeeither but there's no way around it if we want to exposeITransport.