-
Notifications
You must be signed in to change notification settings - Fork 42
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
Error property in log and RUM context
is stripped of properties
#731
Comments
Hi @max-nicholson! 👋 thank you for reaching out :) As a reference I will paste the arguments that all the export type LogWithErrorArguments = [
message: string,
errorKind?: string,
errorMessage?: string,
stacktrace?: string,
context?: object,
fingerprint?: string,
source?: ErrorSource
]; And its simplified overload: export type LogArguments = [message: string, context?: object]; In your case, you want to keep track of all the error properties, by passing it inside the context. I believe the problem is that, as the context has to be serializable in order to reach the native layer, it might be received as an empty object because What can you do?If that's the root of the issue, you could write your serialize function once and use it on the errors that you want to report, as you mentioned in your description e.g function serializeError(error: Error) {
return {
'error.name': error.name,
'error.customProperty': error.customProperty,
'error.cause': {
'message': error.cause.message,
'stack': error.cause.stack,
'name': error.cause.name,
'customProperty': error.cause.customProperty,
},
} This would work because you are retrieving the values of the non-enumerable properties of the error, and you are manually inserting them into your context object. What can we do?
I'd be glad if you could confirm that this is indeed the problem and in the meantime we will plan some improvements, and keep you posted on the topic and on future evolutions of our SDK. Does it sound good to you? :) |
Hi @marco-saia-datadog, yes that's correct. The main gotcha with the current behaviour is that you need nested key dotpaths (e.g. "error.name", "error.customProperty") vs. simply converting the {
"foo:" {
"bar": "baz"
}
} works, but {
"error": {
"message": "foo",
"bar": "baz"
}
} does not. This also doesn't match the behaviour of Either your 2. proposal, or aligning the behaviour to the browser-logs i.e. allowing {
"error": {
"message": "foo",
"bar": "baz"
}
} would make sense to me. |
Describe the bug
DdLogs.[level]
andDdRum.addAction
strips properties fromcontext.error
Using latest minor version of "@datadog/mobile-react-native", through "expo-datadog"
On Android
With a basic error
When they reach the Log Explorer, these will have no
@error.*
attributes whatsoeverWhen they reach the Log Explorer, these will have an
@error.message
,@error.stack
and@error.kind
, but no otherError
propertiesError.cause
is also stripped, as are any custom properties if using a custom Error (the below will have no@error.*
attributes in Log Explorer)On iOS
We get a little more than on Android, but still not much
Most we only get:
For a custom error class, then we see slightly more e.g. an Urql Network error (https://github.com/urql-graphql/urql) appears in Log Explorer like
Notes
The only workaround I found to ensure all "error" properties were kept was the following:
but this feels like this should be a responsibility of the library, not the caller
Reproduction steps
The following test passes + the differing behaviour between Android and iOS suggests it's in the native module side rather than this SDK
SDK logs
No response
Expected behavior
DdLogs.[level] and DdRum.addAction should preserve all (built-in and custom) properties on an
error
property on thecontext
argumentAffected SDK versions
2.4.3
Latest working SDK version
N/A
Did you confirm if the latest SDK version fixes the bug?
Yes
Integration Methods
Yarn
React Native Version
0.73.6
Package.json Contents
{
"dependencies": {
"expo-datadog": "51.0.2",
"react-native": "0.73.6",
"@datadog/mobile-react-native": "2.4.3"
}
}
iOS Setup
No response
Android Setup
No response
Device Information
No response
Other relevant information
No response
The text was updated successfully, but these errors were encountered: