Skip to content

CaptureMessage inconsistency between manual capture and Debug.Log integration #2334

@bitsandfoxes

Description

@bitsandfoxes

The Problem

There are multiple ways to send an event to Sentry i.e.

  • Logging Integration automatically captures logs of a certain level
  • Unhandled Exceptions
  • Manually capturing an exception
  • Manually sending a message

These show up in the issue stream but there is inconsistency as to where the title comes from and what ends up as message.

Image

If you look at a trace it looks like Sentry pulls either the title or the message and appends them to each other.

Image

The Cause

With CaptureErrorLogEvents enabled, the SDK will automatically capture Debug.LogError() as error event. With the option to attach the stacktrace to logmessages enabled, the SDK will create and capture a "synthetic" UnityLogErrorException:

if (_options?.AttachStacktrace is true && !string.IsNullOrEmpty(stacktrace))
{
var ule = new UnityErrorLogException(message, stacktrace, _options);
var sentryEvent = new SentryEvent(ule) { Level = SentryLevel.Error };
_hub.CaptureEvent(sentryEvent);

The stack trace provided by Unity gets parsed during event processing.

public SentryException ToSentryException()

Since we're treating this as an exception we're setting the exception type, so the message shows up like an exception on the issue stream

internal static readonly string ExceptionType = "LogError";

The Proposal

We could just not set the exception type and treat this like any other message. Instead, we can let this be marked solely in the mechanism as we already do

Mechanism = new Mechanism
{
Handled = true,
Type = "unity.log"
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions