LukeMathWalker / LukeMathWalker/tracing-bunyan-formatter

Possible log field collision when used with `tracing-actix-web`

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This issue takes over from https://github.com/LukeMathWalker/tracing-actix-web/issues/1

When we define a tracing instrument that has fields also present in the `info_span!` used in [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web), the collision results in the `tracing-actix-web` fields getting silently overwritten when logged out by this crate (potentially by other logs too, I'm not too sure!).

Here is the `info_span!` from [`tracing-actix-web`](https://github.com/LukeMathWalker/tracing-actix-web/blob/master/src/lib.rs#L136):

```rust
let span = tracing::info_span!(
"Request",
request_path = %req.path(),
user_agent = %user_agent,
client_ip_address = %req.connection_info().realip_remote_addr().unwrap_or(""),
request_id = %Uuid::new_v4(),
status_code = tracing::field::Empty,
);
```

### Example

If we e.g. use the following macro in our code:

```rust
#[tracing::instrument(
name = "Adding a new subscriber",
skip(payload, pool),
fields(
request_id=%Uuid::new_v4(),
email = %payload.email,
name = %payload.name
)
)]
```

We'll have a collision on `request_id`, and we'll only see the `request_id` defined in our instrument in the resulting logs, and not the one from `tracing-actix-web`. This means we can potentially lose visibility in our logs (or just make it a bit more complex).

### Expected Behaviour

As discussed in https://github.com/LukeMathWalker/tracing-actix-web/issues/1, a good outcome might be for this crate to throw a warning on such a collision.

### Thanks

For the excellent crate!

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 with the linked tracing-actix-web src/lib.rs info_span! definition and trace how tracing-bunyan-formatter processes span fields. Investigate what happens when an instrument field such as request_id collides with an existing field. Done should include a warning for the collision while retaining clear visibility of the relevant fields in formatted logs.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
observability-sre
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.