LukeMathWalker / LukeMathWalker/tracing-bunyan-formatter

Preventing certain fields of a span being logged with BunyanFormattingLayer

Open
#16 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement good first issue
Dominant language
Rust
Stars
112
Forks
44
PR merge metrics
No merged PRs in 30d

Description

Quick question, is it possible to configure `BunyanFormattingLayer` to prevent logging certain fields to the console?

My use case is as follows. I have a panic hook set up with [`color-eyre`](https://lib.rs/crates/color-eyre) that gives me a fancy backtrace (with colors and stuff) whenever a panic occurs in my web app. I use `tracing::error(error_report = %panic_report)` to log the fancy backtrace generated by `color-eyre` to the `BunyanFormattingLayer`. The problem is, I want these logs to **only** appear in the context of an external observability solution, such as [Jaeger](https://www.jaegertracing.io/), so **not** in the console.

So right now my panic logs in the console look like this: (without the newlines)

```json
{
"v": 0,
"name": "",
"msg": "[REQUEST - EVENT] Lazy instance has previously been poisoned",
"level": 50,
"hostname": "",
"pid": 34264,
"time": "2022-07-17T11:32:18Z",
"target": "panic_hook",
"line": 20,
"file": "",
"error_report": ""
}
```

So the extremely long backtrace is polluting my logs.

My question is: is it possible to prevent the "error_report" field from appearing in the logs, while still having it available to external observability solutions?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at BunyanFormattingLayer and inspect how event fields such as error_report are selected for console output while remaining available to external observability solutions. Done means determining or documenting a way to exclude that field from console logs without removing it from other outputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
observability
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.