Skip to content

Conversation

multani
Copy link
Owner

@multani multani commented Jul 13, 2025

The stacktrace for an error was formatted as:

${message}
${stacktrace}

I'm pretty sure I saw that documented in Google Cloud's documentation when I initially implemented this feature, but I can't find it anymore and the current documentation from
https://cloud.google.com/error-reporting/docs/formatting-error-messages#log-error now says:

To log an error event that is a stack trace, write the error event as
one of these types:
[...]

  • A jsonPayload that includes a message, stack_trace, or
    exception field.

    You can specify more than one of those fields. If more than one of
    those fields is specified, then the order of evaluation is: stack_trace,
    then exception, and then message.

    If the message field is evaluated and if it isn't empty, then the
    stack trace is captured only when the field contains a stack trace in
    one of the supported programming language formats. The stack trace isn't
    captured by Error Reporting when an unsupported format is used.

    If your error event is formatted as a ReportedErrorEvent object,
    then copy its fields to the jsonPayload. For more information and an
    example, see Log an error that is formatted as a ReportedErrorEvent
    object.

There's no mention of this weird ${message}\n${stacktrace} format anymore, so let's get rid of it.

Fix: #96

The stacktrace for an error was formatted as:

    ${message}
    ${stacktrace}

I'm pretty sure I saw that documented in Google Cloud's documentation
when I initially implemented this feature, but I can't find it anymore
and the current documentation from
https://cloud.google.com/error-reporting/docs/formatting-error-messages#log-error
now says:

> To log an error event that is a stack trace, write the error event as
> one of these types:
> [...]
>
> * A `jsonPayload` that includes a `message`, `stack_trace`, or
>   `exception` field.
>
>   You can specify more than one of those fields. If more than one of
>   those fields is specified, then the order of evaluation is: `stack_trace`,
>   then `exception`, and then `message`.
>
>   If the `message` field is evaluated and if it isn't empty, then the
>   stack trace is captured only when the field contains a stack trace in
>   one of the supported programming language formats. The stack trace isn't
>   captured by Error Reporting when an unsupported format is used.
>
>   If your error event is formatted as a `ReportedErrorEvent` object,
>   then copy its fields to the `jsonPayload`. For more information and an
>   example, see Log an error that is formatted as a ReportedErrorEvent
>   object.

There's no mention of this weird `${message}\n${stacktrace}` anymore, so
let's get rid of it.
@multani multani self-assigned this Jul 13, 2025
@multani multani added the bug Something isn't working label Jul 13, 2025
@multani multani merged commit 1210c2c into main Jul 13, 2025
6 checks passed
@multani multani deleted the fix-error-reporting branch July 13, 2025 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

message\nexception appears to be the incorrect format for stack_trace to render the trace

1 participant