Custom client + inline source code stack traces?

I’ve written a custom Sentry client for a C++ Linux-based server that provides stack traces with filenames and line numbers. Sentry displays the stack trace as expected.

I would like for Sentry to also display the source code inline with the stack trace, as I’ve seen it do for other platforms, but I can’t figure out how to make this happen.

I’ve uploaded my source files with sentry-cli like:

sentry-cli releases files $RELEASE upload src/foo/bar/example.c++ foo/bar/example.c++

Meanwhile, my client uses the “stacktrace” interface to report stack traces. A frame will report the filename as exactly foo/bar/example.c++ along with a line number. But, Sentry doesn’t show the source code inline.

Is there a trick to making this work? The docs are not very clear.

Hi,

I am assuming you are not talking about native crashes as in Sentry + custom native client + stack traces, but rather that you’re already sending a JSON payload to Sentry.

The source code is sent as part of the event! The relevant keys in the frame are pre_context (lines before the crashing line), post_context (lines after the crashing line) and context_line (the line where it crashed). See https://docs.sentry.io/clientdev/interfaces/stacktrace/ for an example.

Hi @untitaker,

Thanks for commenting. Yes, I’m sending JSON – my server is not crashing, it’s just logging exceptions.

Since my app is C++, I don’t have the code available at runtime, so there’s no way for me to fill in those fields from my Sentry client. Is there really no way for Sentry to cross-reference with code on the server side? My Go-using colleagues seem to be able to get inline code in their stack traces, despite Go being a compiled language like C++…