Backtrace allows the submission of file attachments along side crash and error reports to provide more context into a fault. There are various methods that can be used depending on how you are integrating your applications into Backtrace. This article will provide an overview of the supported ways to upload file attachments.

HTTP Submission of Minidumps and File Attachments

Backtrace provides a generic mechanism to accept crash reports and error submissions over HTTP(S). Most minidump generators have a built-in mechanism to upload minidumps and optional attachments to a specified HTTP(S) endpoint, but not all. 

If your integration path to Backtrace does not provide a way to upload minidump files and attachments to Backtrace, you can use our generic HTTP submission methods. You have two options

1. Multipart POST submission where the config.json attachment is included with the initial crash submission 

curl -v -F "upload_file=@example_minidump.dmp" -F "attachment_config.json=@config.json; type=application/json" -H "Expect:" "https://testing.company.com:6098/post?format=minidump&token=ttttt"

2. After the crash is submitted, a subsequent call can be made to attach additional files. In the following example, we attach the config.json to object 5 that already exists in Backtrace.

curl -v --data-binary @config.json -H "Expect:" -H "Content-Type:application/json" "https://testing.company.com:6098/post?token=ttttt&object=5&attachment_name=config.json"

Please review our HTTP Submission of Minidump article for more details on how to attach files.

Breakpad

Breakpad is an open source library initially developed by Google for cross platform C/C++ crash reporting. It is a popular choice for Windows, Mac and Linux environments, including servers, desktop apps, and embedded devices. For customers who use Breakpad with Backtrace, you can leverage the library's files parameter to specify the set of file paths to be uploaded. 

files["upload_file_minidump"] = descriptor.path();
files["attachment_log"] = "/var/log/myApp.log";
files["attachment_cpuinfo"] = "/proc/cpuinfo";

See the Breakpad Integration Guide for more details on how to use the files parameter to upload attachments with your crash reports.

Crashpad

Crashpad is another open source library initially developed by Google as a successor to the Breakpad library. Backtrace has built and released a set of binaries of Crashpad for Windows (64 and 32 bit) that include an ability to upload file attachments. Check out http://get.backtrace.io/crashpad/builds/ to download the binaries for your OS.

To provide you with the ability to upload files, we have implemented a new handler to make file attachments just as simple as setting up any other piece of metadata to come alongside the crash.

Here’s what it looks like:

bool StartHandlerForBacktrace(
  const base::FilePath& handler,
  const base::FilePath& database,
  const base::FilePath& metrics_dir,
  const std::string& url,
  const std::map<std::string, std::string>& annotations,
  const std::vector<std::string>& arguments,
  const std::map<std::string, std::string>& file_attachments,
  bool restartable,
  bool asynchronous_start
)

This new handler is very similar to StartHandler, with the addition of the file_attachments parameter. file_attachments is a map of attachment namepath, allowing convenient inclusion of file attachments (i.e. the log file) with the crash dump.

More details can be found in the Crashpad Integration Guide

As we move forward, Backtrace plans to work with the upstream Crashpad team to implement file attachment support in the master branch. 

C# and Unity

Backtrace supports crash and exception reporting from applications written in C# using our C# reporting library or Unity-Plugin. Using our BacktraceReport object, developers can specify a list of attachmentPaths to submit alongside the crash or exception report.

var report = new BacktraceReport(
  exception: exception,
  attributes: new Dictionary<string, object>() { { "key", "value" } },
  attachmentPaths: new List<string>() { @"file_path_1", @"file_path_2"}
);

Find more details, please see the C# reporting library readme file here.

Questions?

Feel free to reach out if you have additional questions.

Did this answer your question?