RUM-2907 Allow setting custom error fingerprint#1911
Conversation
This sets up an attribute, `LogAttributes.ERROR_FINGERPRINT` that is automatically transferred to the `Error` object in `LogEvent`s. Also fixes RUM-2209 by adding the `LogEvent.Error.fingerprint` member
1e3de3a to
c195c9a
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #1911 +/- ##
===========================================
- Coverage 83.38% 83.36% -0.02%
===========================================
Files 477 477
Lines 16922 16971 +49
Branches 2514 2525 +11
===========================================
+ Hits 14109 14147 +38
- Misses 2120 2125 +5
- Partials 693 699 +6
|
0xnm
left a comment
There was a problem hiding this comment.
Looks good, but I think it is missing the following:
- We need also implementation for RUM. Is it going to be added in another PR?
- How we are going to let know the customers that they can use this attribute? Are we going to update some documentation?
I'll go back and do it for this one.
That was my plan. Do you think there's a better way? |
probably updating documentation of related API methods will be enough. |
| const val ERROR_DATABASE_PATH: String = "error.database.path" | ||
|
|
||
| /** | ||
| * Specifies a custom error fingerprint for the supplied. |
There was a problem hiding this comment.
| * Specifies a custom error fingerprint for the supplied. | |
| * Specifies a custom error fingerprint for the supplied error. |
There was a problem hiding this comment.
Also let's add a reference to RumAttributes.ERROR_FINGERPRINT in the RumMonitor APIs descriptions where applicable.
| val updatedAttributes = addExtraAttributes(event.attributes) | ||
| val isFatal = updatedAttributes | ||
| .remove(RumAttributes.INTERNAL_ERROR_IS_CRASH) as? Boolean == true || event.isFatal | ||
| val errorFingerprint = updatedAttributes.remove(RumAttributes.ERROR_FINGERPRINT) as? String |
There was a problem hiding this comment.
Should we support this attribute in the RumResourceScope as well? 🤔 there is a possibility in API to stop resource with error.
I don't have an answer for that, just thinking.
There was a problem hiding this comment.
It's a good thought, and I don't have an answer for it either. Are resource errors considered in Error Tracking and thus would they consult the fingerprint? Maybe a question for the ET team.
| assertThat(firstValue) | ||
| .apply { | ||
| hasMessage(throwableMessage) | ||
| hasStackTrace(stacktrace) | ||
| hasErrorFingerprint(fingerprint) | ||
| } |
There was a problem hiding this comment.
ideally we need to assert all properties of the event as it is done in other tests.
Or at least assert that attributes send to the backend have no RumAttributes.ERROR_FINGERPRINT
| put(RumAttributes.ERROR_FINGERPRINT, fingerprint) | ||
| } | ||
| val throwableMessage = throwable.message | ||
| check(!throwableMessage.isNullOrBlank()) { |
There was a problem hiding this comment.
better to use the assumeTrue here, I don't think we want to fail the test if test setup is not good.
but anyway, is this needed here? what changes if message is null (it is never possible by looking on ThrowableForgeryFactory) or blank?
There was a problem hiding this comment.
Since throwable.message is Stirng?, check performs the null check that allows us to no not perform the force dereference further down. I doesn't seem like assumeTrue does that.
There was a problem hiding this comment.
yes, check is smart-cast friendly. however, we don't want test to fail if pre-condition is not satisfied, and assumeTrue will allow test to continue.
Speaking about this scenario, I think it is just easier to generate non-null message manually using @StringForgery fakeMessage: String, and then things will be simpler.
|
@0xnm / @mariusc83 Added |
| writer: DataWriter<Any> | ||
| ) { | ||
| attributes.putAll(GlobalRumMonitor.get(sdkCore).getAttributes()) | ||
| val errorFingerprint = attributes.remove(RumAttributes.ERROR_FINGERPRINT) as? String |
There was a problem hiding this comment.
probably we need also to mention it in the related API of RumMonitor
9c2fb7d to
68b3fc8
Compare
What does this PR do?
This sets up attributes that are automatically transferred to the
Errorobjects for Logs and RUM.For logs, the attribute is
LogAttributes.ERROR_FINGERPRINTand sets the fingerprint in theLogEvent.Error.For RUM, the attribute is
RumAttributes.ERROR_FINGERPRINTand sets the fingerprint member inErrorEvent.ErrorAlso fixes RUM-2209 by adding the
LogEvent.Error.fingerprintmemberReview checklist (to be filled by reviewers)