Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pretty formatter emits a leading comma in span fields #1832

Closed
hawkw opened this issue Jan 13, 2022 · 0 comments · Fixed by #1833
Closed

Pretty formatter emits a leading comma in span fields #1832

hawkw opened this issue Jan 13, 2022 · 0 comments · Fixed by #1833
Labels
crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working

Comments

@hawkw
Copy link
Member

hawkw commented Jan 13, 2022

Bug Report

Version

  • tracing-subscriber 0.3.5

Crates

  • tracing-subscriber

Description

Looks like the Pretty formatter in tracing-subscriber is currently prefixing span fields with a leading ,. This looks bad and we should fix it.

See, for example, pgcentralfoundation/pgrx#372 (comment)

image

@hawkw hawkw added kind/bug Something isn't working crate/subscriber Related to the `tracing-subscriber` crate labels Jan 13, 2022
hawkw added a commit that referenced this issue Jan 13, 2022
## Motivation

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with 
`is_empty: false` This means that when visiting a set of span fields,
we emit a leading `, ` _before_ the first field, which looks quite bad.

## Solution

This branch changes it back, and now the output looks nice again. :)

### Before

```
  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3
```

### After

```
  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,
```

Fixes: #1832

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
hawkw added a commit that referenced this issue Jan 14, 2022
## Motivation

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with 
`is_empty: false` This means that when visiting a set of span fields,
we emit a leading `, ` _before_ the first field, which looks quite bad.

## Solution

This branch changes it back, and now the output looks nice again. :)

### Before

```
  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3
```

### After

```
  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,
```

Fixes: #1832

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
hawkw added a commit that referenced this issue Jan 14, 2022
## Motivation

PR #1661 introduced a regression with the `Pretty` formatter: the
`PrettyVisitor` type was [accidentally changed][1] from being
constructed with `is_empty: true` to being constructed with 
`is_empty: false` This means that when visiting a set of span fields,
we emit a leading `, ` _before_ the first field, which looks quite bad.

## Solution

This branch changes it back, and now the output looks nice again. :)

### Before

```
  2022-01-13T17:09:04.772411Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with , yak: 2
    in fmt_pretty::yak_shave::shaving_yaks with , yaks: 3
```

### After

```
  2022-01-13T17:10:28.472525Z TRACE fmt_pretty::yak_shave: hello! I'm gonna shave a yak, excitement: "yay!"
    at examples/examples/fmt/yak_shave.rs:16 on main
    in fmt_pretty::yak_shave::shave with yak: 1
    in fmt_pretty::yak_shave::shaving_yaks with yaks: 3,
```

Fixes: #1832

[1]: 937c5d7#diff-a27a4c3564a0c2f1b7af32be0f9eec25ddfbe8b4c2be8d74e84d874b919b393bR227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate/subscriber Related to the `tracing-subscriber` crate kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant