-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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: Allow trace instrumentation to emit log records #992
Conversation
It looks weird if the callsite also adds punctuation of its own...
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
810353a
to
1443463
Compare
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
1443463
to
eb90924
Compare
I mentioned this in Slack, but repeating here. My gut reaction is that the combination of feature flags / env vars is confusing. The goal of the env var is to be able to introduce |
@carllerche Okay, I'm happy to simplify the env var/feature flag relationship. My personal opinion is that emitting To me, it seems like there's enough interest in Since the goal of the env var is to allow libraries (such as tokio) to expose What do you think? |
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
e7038f1
to
996b7fb
Compare
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@carllerche okay, I've updated this branch so that the env var is always required to enable trace instrumentation. A warning message is printed when a subscriber would enable a span if trace instrumentation and log output are both disabled. |
a34de98
to
eb5a1a0
Compare
@carllerche I think this branch is ready to be reviewed --- I've updated the PR description to reflect the current behavior as well. |
This prevents them from resulting in `DebugValue(foo)` and so on in log messages. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This reverts commit dd99ea3. This change wasn't intended to be committed to this branch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I would merge if @seanmonstar is good with it as well (we want hyper to adopt it too).
I believe the FreeBSD CI build is failing for the same reasons described here #987 (comment) |
Okay, 3ca54ff ought to fix the FreeBSD build failing. @seanmonstar I would still love to get your approval before merging (as Carl suggested in #992 (review))... |
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
## 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>
Motivation
tokio-trace
currently offers a strategy for compatibility with thelog
crate: its macros can be dropped in as a replacement forlog
'smacros, 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 ableto emit
tokio-trace
instrumentation instead. Thetokio
runtimes areone 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 onlylog
and nottokio-trace
. It is desirable for libraries to have the option to emitboth
log
andtokio-trace
diagnostics from the same instrumentationpoints.
Solution
This branch adds a
log
feature flag to thetokio-trace
crate, whichwhen set, causes
tokio-trace
instrumentation to emit log records as wellas
tokio-trace
instrumentation.In addition, emitting
tokio-trace
instrumentation now requires compilingwith the environment variable
TOKIO_TRACE_ENABLED
set. If this is notset and
log
output is not enabled, but atokio-trace
subscriber wouldhave enabled a span, we output a warning message stating that this env
var must be set to enable
tokio-trace
.Notes
In an ideal world, we would just detect if there is an active
trace
subscriber, and emit
log
records if there is not. However, we can'tcurrently distinguish between a
NoSubscriber
and a subscriber thathas chosen not to record a particular callsite, without the downcasting
API proposed in #974. It might be worth waiting for that PR to land, and
modifying the log compat feature to emit log records if the current
subscriber is
NoSubscriber
, obviating the use of the environmentvariables in most cases.
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 theSpan
type. This was previously stored inthe
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