You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A clear and concise description of what the bug is. Documentation indicates that if we do not return a payload a given request will not be sent to the apm server. This is true in some cases but not all.
The filter function is synchronous and should return the manipulated payload object. If a filter function doesn’t return any value or returns a falsy value, the remaining filter functions will not be called and the payload will not be sent to the APM Server.
There is also an issue with the sampled property not being the same everywhere which is confusing.
In this case the app will crash any time that an error occurs within the request. Below is the general steps to make the error occur and details along the way
/**
* Filter to only send sampled results to the APM Server
*/
apm.addFilter(payload => {
console.log('\n--- Filter ---\n');
console.log(JSON.stringify(payload, null, 2));
if (typeof payload.sampled === 'boolean' && !payload.sampled) {
/*
CASE 1
When this occurs the data result looks similar to below.
Returning here when not sampling works as expected and does
not produce any errors.
*/
return;
}
if (
typeof payload.transaction?.sampled === 'boolean' &&
!payload.transaction.sampled
) {
/*
CASE 2
When an error occurs, the `transaction.sampled` is where
the data is, but regardless, if this filter ever returns
undefined it will cause the app to crash completely.
*/
return;
}
return payload;
});
[CASE 1]: First Filter Works
It first provides the given payload. If I return undefined for this then it does not crash the application. However, this is a tiny data payload, my goal is to completely ignore anything that is not sampled.
Describe the bug
A clear and concise description of what the bug is. Documentation indicates that if we do not return a payload a given request will not be sent to the apm server. This is true in some cases but not all.
There is also an issue with the
sampled
property not being the same everywhere which is confusing.See #151 for more context
To Reproduce
In this case the app will crash any time that an error occurs within the request. Below is the general steps to make the error occur and details along the way
[CASE 1]: First Filter Works
It first provides the given payload. If I return undefined for this then it does not crash the application. However, this is a tiny data payload, my goal is to completely ignore anything that is not sampled.
[CASE 2]
transaction.type
ofrequest
CrashesIn this case, returning
undefined
crashes the app with the following stacktraceThe text was updated successfully, but these errors were encountered: