-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Google Cloud Function: missing Stackdriver logs when Sentry captures exceptions #3379
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
Comments
Can you provide an example of how you use the SDK? Stackdriver logs links are only provided for the automatically captured exceptions through the |
@kamilogorek really basic code module.exports = Sentry.GCPFunction.wrapEventFunction((data, context, callback) => {
console.log('Logging some tests')
console.log('Logging some more tests')
throw new Error('Testing')
}) Here's a link to an issue in our Sentry project: https://sentry.io/organizations/upandup/issues/2330399156/?project=5632160 We have 2 issues.
|
I put this all together in this one snippet to show all the unexpected cases module.exports = Sentry.GCPFunction.wrapEventFunction(
async (event, context, callback) => {
let data, dataString
try {
dataString = Buffer.from(event.data, 'base64').toString()
data = JSON.parse(dataString)
} catch (err) {
return callback(new Error(`Error parsing string: ${dataString}`))
}
console.log('Logging some tests')
console.log('Logging some more tests')
if (data.error) {
// If this is called an issue will show in Sentry but the function
// will not exit so it will crash with a timeout (unexpected).
// When the func crashes the error will show in Stackdriver
throw new Error('Testing')
}
if (data.callbackError) {
const error = new Error('Testing')
// If this is called the issue will log in Stackdriver and the
// function will exit with an error status but it will not show
// in Sentry (unexpected)
callback(error)
}
if (data.callback) {
// If this is called the function will log in Stackdriver (expected)
callback()
}
// If returned without the callback the function will crash because
// of a timeout (unexpected
}
) |
@kamilogorek @ahmedetefy can we get an update here? Pretty big issue that's been open over a week without a response |
@bsiddiqui Apologies for the late response! |
@ahmedetefy any update? it's been 2 weeks since your last message we're at a place where we have to remove sentry if we can't figure out what's going on and i'd like to avoid that if possible |
@ahmedetefy @kamilogorek it's been over 2 months without an update - is this going to be resolved? |
We have the exact same issue on our end. We have a GCP function subscribing to a Pubsub topic and crashes in it are correctly sent in Sentry. However, even though the Function crashed, Stackdriver logs do not contain any errors and the faulty executions appears like they ended correctly in StackDriver, which is clearly wrong. |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
This is absolutely still an issue. I ran into the same problem today. Sentry swallows errors and does not report anything to stackdriver/cloud logging. Most importantly: GCP will consider the function successfully completed! Example stackdriver output from a function that threw (similar to the examples above): |
Sentry team, can we reopen this issue? Those are really important issues, as basic functionalities are straight up not working... |
Could you share your handler code, possibly (at least the critical part of how the handler is set up), and possibly an example of how/where an error is thrown? |
Sure, to give you the most important parts (can't public much of the business logic):
registerCloudEventHandler:
withSentryErrorHandling:
|
Hey, so some things about this setup:
Sentry.init({...});
export async function globalHandler(evt: CloudEvent<{ message: { data: string } }>) {
const rootLogger = getLogger().child({ evt });
try {
const logger = rootLogger.child({ providerId });
await doSomeThings(logger);
} catch (err) {
rootLogger.error('Reconciler error:', err);
throw err;
}
}
registerCloudEventHandler(globalHandler);
// somewhere else
export function registerCloudEventHandler<T>(handler: CloudEventFunction<T>, options?: RegisterCloudEventHandlerOptions) {
const hardFailOptions = { ...defaultHardFailOptions, ...options?.hardFail };
const wrappedHandler = Sentry.wrapHttpFunction(handler);
functions.cloudEvent(HANDLER, exitProcessOnTimeout(hardFailWhenNeeded(wrappedHandler, hardFailOptions)));
} Importantly, you should not use/need the custom |
Package + Version
@sentry/serverless
Version:
Description
Sentry for google cloud functions swallows logs (not sent to stackdriver) if an exception is captured.
We have some code that captures an error with
Sentry.captureException
which somehow is leading to the logs from that run of the function not appearing in Stackdriver. Based on the docs I assumed Sentry would include "A link to the Stackdriver logs", implying it wouldn't swallow logs.Example issue:
https://sentry.io/organizations/upandup/issues/2324315838/?project=5632160
The text was updated successfully, but these errors were encountered: