send build_id to sentry as well + fix some minor issues

This commit is contained in:
Ivan Blinkov 2020-06-24 00:27:04 +03:00
parent 45d1ca2567
commit 3ed76a388e
5 changed files with 17 additions and 5 deletions

View File

@ -298,7 +298,14 @@ private:
stack_trace.toStringEveryLine([&](const std::string & s) { LOG_FATAL(log, s); }); stack_trace.toStringEveryLine([&](const std::string & s) { LOG_FATAL(log, s); });
/// Send crash report to developers (if configured) /// Send crash report to developers (if configured)
SentryWriter::onFault(sig, info, context, stack_trace);
#if defined(__ELF__) && !defined(__FreeBSD__)
const String & build_id_hex = DB::SymbolIndex::instance().getBuildIDHex();
#else
String build_id_hex{};
#endif
SentryWriter::onFault(sig, info, context, stack_trace, build_id_hex);
/// When everything is done, we will try to send these error messages to client. /// When everything is done, we will try to send these error messages to client.
if (thread_ptr) if (thread_ptr)

View File

@ -161,7 +161,7 @@ void SentryWriter::shutdown()
#endif #endif
} }
void SentryWriter::onFault(int sig, const siginfo_t & info, const ucontext_t & context, const StackTrace & stack_trace) void SentryWriter::onFault(int sig, const siginfo_t & info, const ucontext_t & context, const StackTrace & stack_trace, const String & build_id_hex)
{ {
#if USE_SENTRY #if USE_SENTRY
auto * logger = &Poco::Logger::get("SentryWriter"); auto * logger = &Poco::Logger::get("SentryWriter");
@ -171,6 +171,10 @@ void SentryWriter::onFault(int sig, const siginfo_t & info, const ucontext_t & c
sentry_value_t event = sentry_value_new_message_event(SENTRY_LEVEL_FATAL, "fault", error_message.c_str()); sentry_value_t event = sentry_value_new_message_event(SENTRY_LEVEL_FATAL, "fault", error_message.c_str());
sentry_set_tag("signal", strsignal(sig)); sentry_set_tag("signal", strsignal(sig));
sentry_set_extra("signal_number", sentry_value_new_int32(sig)); sentry_set_extra("signal_number", sentry_value_new_int32(sig));
if (!build_id_hex.empty())
{
sentry_set_tag("build_id", build_id_hex.c_str());
}
setExtras(); setExtras();
/// Prepare data for https://develop.sentry.dev/sdk/event-payloads/stacktrace/ /// Prepare data for https://develop.sentry.dev/sdk/event-payloads/stacktrace/

View File

@ -27,6 +27,7 @@ public:
int sig, int sig,
const siginfo_t & info, const siginfo_t & info,
const ucontext_t & context, const ucontext_t & context,
const StackTrace & stack_trace const StackTrace & stack_trace,
const String & build_id_hex
); );
}; };

View File

@ -308,7 +308,7 @@ const StackTrace::FramePointers & StackTrace::getFramePointers() const
return frame_pointers; return frame_pointers;
} }
static void toStringEveryLineImpl(const void * const * frame_pointers, size_t offset, size_t size, std::function<void(const std::string &)> callback) static void toStringEveryLineImpl(const StackTrace::FramePointers & frame_pointers, size_t offset, size_t size, std::function<void(const std::string &)> callback)
{ {
if (size == 0) if (size == 0)
return callback("<Empty trace>"); return callback("<Empty trace>");

View File

@ -54,7 +54,7 @@ public:
std::string toString() const; std::string toString() const;
static std::string toString(void ** frame_pointers, size_t offset, size_t size); static std::string toString(void ** frame_pointers, size_t offset, size_t size);
static void symbolize(const void * const * frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames); static void symbolize(const FramePointers & frame_pointers, size_t offset, size_t size, StackTrace::Frames & frames);
void toStringEveryLine(std::function<void(const std::string &)> callback) const; void toStringEveryLine(std::function<void(const std::string &)> callback) const;
protected: protected: