Skip to content

fix(datadog): Encode metadata error value before embedding in error field - #174

Open
doughsay wants to merge 1 commit into
Nebo15:masterfrom
doughsay:cd/encode-error-metadata-upstream
Open

fix(datadog): Encode metadata error value before embedding in error field#174
doughsay wants to merge 1 commit into
Nebo15:masterfrom
doughsay:cd/encode-error-metadata-upstream

Conversation

@doughsay

Copy link
Copy Markdown

format_error/4 embeds the raw metadata :error value into the log line, bypassing RedactorEncoder. A non-JSON-encodable term (e.g. an {:error, reason} tuple) then crashes the encoder.

This fix runs the value through encode/2 (which also applies redactors), matching how every other part of the line is built.

…ield

format_error/4 embedded the raw metadata :error value into the log line,
bypassing RedactorEncoder. A non-JSON-encodable term (e.g. an {:error,
reason} tuple) then crashed the encoder, and because maybe_merge is
left-biased the encoded copy of the metadata could not overwrite it. The
formatter crash surfaces as "FORMATTER CRASH: ..." fallback lines and the
original log event is lost entirely.

Run the value through encode/2 (which also applies redactors), matching
how every other part of the line is built.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant