-
-
Notifications
You must be signed in to change notification settings - Fork 225
CaptureFeedback now returns a SentryId #4613
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
base: version6
Are you sure you want to change the base?
Conversation
/// <param name="hint">An optional hint providing high level context for the source of the event</param> | ||
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null); | ||
/// <returns>The SentryId of the captured feedback, if successful. SentryId.Empty if feedback capture fails.</returns> | ||
public SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null); |
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.
Arguably this could be called TryCaptureFeedback
now but I don't think that's consistent with the other SDKs (or the CaptureEvent
method)... so for consistency I've left it as is.
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 was also wondering about the other SentryId
-returning Capture*
-methods 🤔
Both other SentryId
-returning Capture*
-methods
SentryId CaptureEvent
SentryId CaptureCheckIn
do return SentryId.Empty
when unsuccessful.
If I get that right, then bool Try*
-methods should communicate the "main-exceptional" flow when returning false
, not every reason for completing unsuccessfully.
E.g. Dictionary<TKey, TValue>.TryAdd
only returns false
when "An item with the same key has already been added.". But it still throws if null
is passed as a key.
What would be the "main-error" that TryCaptureFeedback
would communicate?
- Hub not enabled
- Message is null or empty
- Envelope not enqueued
TryCaptureEvent
would also have multiple failure cases
- Event is null
- Event dropped via Exception-Filters
- Event dropped via Event-Processor
- Event dropped via
SetBeforeSend
- Event dropped by sampling
- Event not enqueued
Hmm ... we could return something like a "CaptureEventStatus" struct
or enum
.
Similar to BCL methods returning OperationStatus when it comes to buffers.
Or am I dramatically overthinking this?
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.
Also ... I guess we're a bit inconsistent with void
vs bool
, too:
void CaptureTransaction
void CaptureSession
Could (or should) these be bool
-returning as well?
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.
Could (or should) these be bool-returning as well?
I think @bitsandfoxes wanted a SentryId on this, since it's not just SDK user facing but SDK user's user facing... so the SDK user could actually want to report success/failure of this method to the app user.
That's probably not the case for CaptureTransaction
or CaptureSession
. The SDK user is highly unlikely to do anything with any hypothetical return value for those functions. They're really just best effort.
What would be the "main-error" that TryCaptureFeedback would communicate?
This is probably the main one:
sentry-dotnet/src/Sentry/SentryClient.cs
Lines 91 to 95 in 0cda3df
if (string.IsNullOrEmpty(feedback.Message)) | |
{ | |
_options.LogWarning("Feedback dropped due to empty message."); | |
return SentryId.Empty; | |
} |
DisabledHub
is possible, if an empty string was used for the DSN when initialising the SDK.
I think failure to enqueue the envelope would only happen if we'd disposed of the SentryClient (which would only happen when shutting down the app)... so a vanishingly small chance of that happening when the app is capturing user feedback (and no chance to do anything with that error code if/when it did happen).
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'd argue to not name it Try*
but instead that the static API is mostly intended as fire & forget. The return values are not intended to be used to control the flow or have the option to recover from a failure.
Consider the following
- User calls
CaptureEvent
- Capture "fails" due to: SDK not initialized, dropped due to filtering, beforeSend, processor?
- What do we expect the user to do now?
If they need the ID for some reason they should have it, but prepending the capture methods with a Try*
implies some sort of recovery mechanism to me that does not exist.
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.
@bitsandfoxes agree re the method name.
Is there any value in changing the result type from SentryId to CaptureFeedbackResult
(to be able to distinguish failure reasons) or is this overkill do you think? See this comment above - I think there are only really two possible reasons for failure.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## version6 #4613 +/- ##
===========================================
Coverage ? 73.10%
===========================================
Files ? 479
Lines ? 17388
Branches ? 3435
===========================================
Hits ? 12711
Misses ? 3818
Partials ? 859 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
{ | ||
if (_isDisposed == 1) | ||
{ | ||
_options.LogWarning("Enqueue envelope failed: disposed client"); |
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.
_options.LogWarning("Enqueue envelope failed: disposed client"); | |
_options.LogWarning("Enqueue envelope failed. Client is disposed."); |
/// <param name="hint">An optional hint providing high level context for the source of the event</param> | ||
public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null); | ||
/// <returns>The SentryId of the captured feedback, if successful. SentryId.Empty if feedback capture fails.</returns> | ||
public SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null); |
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'd argue to not name it Try*
but instead that the static API is mostly intended as fire & forget. The return values are not intended to be used to control the flow or have the option to recover from a failure.
Consider the following
- User calls
CaptureEvent
- Capture "fails" due to: SDK not initialized, dropped due to filtering, beforeSend, processor?
- What do we expect the user to do now?
If they need the ID for some reason they should have it, but prepending the capture methods with a Try*
implies some sort of recovery mechanism to me that does not exist.
This looks great from the SDK for Unity POV. |
SentrySdk.CaptureFeedback
now returns aSentryId
that indicates either the id of the newly captured feedback (when the call succeeds) orSentryId.Empty
when capturing feedback fails.Resolves #4319
CaptureFeedback
#4319Note
I could see SDK users wanting to know what the error is, if capturing fails... so maybe we need to build a mechanism in to allow this? Perhaps we should be returning a more complex type than just SentryId then... some CaptureFeedbackResult type or something that includes success/failure and optionally an error code and/or message.