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

trace: log back-compat in tokio-trace #949

Closed
hawkw opened this issue Mar 4, 2019 · 0 comments
Closed

trace: log back-compat in tokio-trace #949

hawkw opened this issue Mar 4, 2019 · 0 comments
Assignees
Labels
C-enhancement Category: A PR with an enhancement or bugfix.

Comments

@hawkw
Copy link
Member

hawkw commented Mar 4, 2019

Description

It would be very useful if the core tokio libraries (executor, runtime, threadpool etc) emitted tokio-trace instrumentation. However, since tokio-trace-core isn't yet fully stabilized, it should not be the only way of consuming instrumentation in those libraries. As @carllerche mentioned on Gitter, we should be able to make some modifications to tokio-trace so that its Event and Span APIs could optionally emit log records in addition to or instead of tokio-trace-core instrumentation.

This way, we wouldn't break any existing logging in other tokio crates, and users could choose to opt in to tokio-trace-core instrumentation.

@hawkw hawkw added C-enhancement Category: A PR with an enhancement or bugfix. tokio-trace labels Mar 4, 2019
@hawkw hawkw added this to the tokio-trace-core 0.1 milestone Mar 4, 2019
@hawkw hawkw self-assigned this Mar 4, 2019
@hawkw hawkw removed this from the tokio-trace-core 0.1 milestone Mar 5, 2019
hawkw added a commit that referenced this issue Mar 26, 2019
## Motivation

`tokio-trace` currently offers a strategy for compatibility with the
`log` crate: its macros can be dropped in as a replacement for `log`'s
macros, and a subscriber can be used that translates trace events to log
records. However, this requires the application to be aware of
`tokio-trace` and manually set up this subscriber.

Many libraries currently emit `log` records, and would like to be able
to emit `tokio-trace` instrumentation instead. The `tokio` runtimes are
one such example. However, with the current log compatibility strategy,
replacing existing logging with trace instrumentation would break
`tokio`'s logs for any downstream user which is using only `log` and not
`tokio-trace`. It is desirable for libraries to have the option to emit
both `log` _and_ `tokio-trace` diagnostics from the same instrumentation
points.

## Solution

This branch adds a `log` feature flag to the `tokio-trace` crate, which
when set, causes `tokio-trace` instrumentation to emit log records as well
as `tokio-trace` instrumentation. 

## Notes

In order to allow spans to log their names when they are entered and 
exited even when the span is disabled, this branch adds an 
`&'static Metadata` to the `Span` type. This was previously stored in
the `Inner` type and was thus only present when the span was enabled.
This makes disabled spans one word longer, but enabled spans remain
the same size.

Fixes: #949

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@hawkw hawkw added this to the tokio-trace v0.1 milestone Mar 27, 2019
hawkw added a commit that referenced this issue Jun 25, 2019
## Motivation

`tokio-trace` currently offers a strategy for compatibility with the
`log` crate: its macros can be dropped in as a replacement for `log`'s
macros, and a subscriber can be used that translates trace events to log
records. However, this requires the application to be aware of
`tokio-trace` and manually set up this subscriber.

Many libraries currently emit `log` records, and would like to be able
to emit `tokio-trace` instrumentation instead. The `tokio` runtimes are
one such example. However, with the current log compatibility strategy,
replacing existing logging with trace instrumentation would break
`tokio`'s logs for any downstream user which is using only `log` and not
`tokio-trace`. It is desirable for libraries to have the option to emit
both `log` _and_ `tokio-trace` diagnostics from the same instrumentation
points.

## Solution

This branch adds a `log` feature flag to the `tokio-trace` crate, which
when set, causes `tokio-trace` instrumentation to emit log records as well
as `tokio-trace` instrumentation. 

## Notes

In order to allow spans to log their names when they are entered and 
exited even when the span is disabled, this branch adds an 
`&'static Metadata` to the `Span` type. This was previously stored in
the `Inner` type and was thus only present when the span was enabled.
This makes disabled spans one word longer, but enabled spans remain
the same size.

Fixes: #949

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: A PR with an enhancement or bugfix.
Projects
None yet
Development

No branches or pull requests

1 participant