-
-
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #944 +/- ##
==========================================
+ Coverage 81.15% 81.83% +0.68%
==========================================
Files 183 183
Lines 5878 5879 +1
Branches 1451 1451
==========================================
+ Hits 4770 4811 +41
+ Misses 692 666 -26
+ Partials 416 402 -14
Continue to review full report at Codecov.
|
bruno-garcia
left a comment
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.
Code looks good but it's missing some tests to cover the new behavior.
One outstanding point is the fact we need to make ISerializable also public. @Tyrrrz won't be back for 3 weeks to chime in but I believe he wanted to refactor things before we make those public. So either we'll wait or we need to figure this out ourselves
| /// Represents a serializable entity. | ||
| /// </summary> | ||
| internal interface ISerializable | ||
| public interface ISerializable |
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 ISerializable right now will constrain us too much. I don't like exposing Envelope either but there's no way around it if we want to expose ITransport.
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
|
I have now added a test to verify that custom transports a wrapped with a cache. The opposite (to show that no caching is used) would require either to make some properties public on the |
| ITransport transport; | ||
|
|
||
| if (_options.Transport is not null) | ||
| { | ||
| transport = _options.Transport; | ||
| } | ||
| else | ||
| { | ||
| transport = CreateHttpTransport(); | ||
| } |
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.
| ITransport transport; | |
| if (_options.Transport is not null) | |
| { | |
| transport = _options.Transport; | |
| } | |
| else | |
| { | |
| transport = CreateHttpTransport(); | |
| } | |
| var transport = _options.Transport ?? CreateHttpTransport(); |
| /// Represents a serializable entity. | ||
| /// </summary> | ||
| internal interface ISerializable | ||
| public interface ISerializable |
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 ISerializable right now will constrain us too much. I don't like exposing Envelope either but there's no way around it if we want to expose ITransport.
It's great feature! Thanks. Could you help me in one use-case? I have to develop a use-case: Send the Sentry Events from a private side throught RabbitMq to a public side and then send them to Sentry Server. What I did:
I will plesant if you help me. |
I don't think there's a straightforward way to achieve that (@bruno-garcia can correct me if I'm wrong). I think your best bet is to write the envelopes from RabbitMQ to a local directory, and pick them up via caching feature: sentry-dotnet/src/Sentry/SentryOptions.cs Lines 385 to 389 in 984b210
The files will need to be placed in a specific subdirectory as well. Assuming The file name doesn't matter, but the extension has to be Cached envelopes are flushed automatically during That said, all of this is very hacky and I'm not sure how well this will work. We probably need a proper solution for this, but currently all of the relevant interfaces and implementations are internal. |
|
Thank you for your reply. I decided to achieve this via reflections like that: ` ` |
|
Hi. Sorry this PR is open for so long. I'm taking a look now, and it seems like most of what it does has already been addressed by other PRs for other reasons, as follows:
I think to achieve the stated goals, all that needs to be done is to make I'll close this PR and open a new one with that. |
|
See #1602 |
As discussed in #941, this is a proposal to make the
ITransportconfigurable, which required to make the interface and some other classes along the path public.The transport will be wrapped with caching, if configured.