-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Adopt Tracing #1410
Adopt Tracing #1410
Conversation
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
i only see four or five instances of using a |
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.
🙋🏻♀️
first, the parent span context of an event can actually be set in two ways: it can be explicitly passed in via let span = tracing::info_span!(...);
tracing::info!(parent: &span, ...); and let span = tracing::info_span!(...);
let _entered = span.enter();
// ...
tracing::info!(...); will result in equivalent formatting for the event. as i mentioned in #1410 (comment), i used a mix of second, the reason that parents are not set everywhere is just because i started the process of replacing Rocket's current indentation-based logging contexts with spans, but didn't really have time to finish it. i made the change to some of the primary files in core, and then (in the interests of getting a PR up sooner rather than later) did the rest of the change via find-and-replace so that the code would still compile. the hope was that the parts of the codebase i did get to could be used as a model for other Rocket contributors to make the same changes elsewhere. i'm happy to finish applying this transformation, but i got busy with other responsibilities and, after speaking with @SergioBenitez and @jebrosen, we decided that it was better to at least open a PR now, at least to start socializing the changes to other contributors. if we'd rather merge it in one go, i'm happy to keep the PR open while i update the rest of Rocket to use the same style. |
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
On the subject of logging levels, I would be slightly in favor of renaming some of I think the log output formatting at this point is pretty close to "good enough", and it's at least as good and in some ways better than current
|
What does this mean for the state of "support" messages in the current PR?
I agree. Perhaps we should simply use the names native to log/tracing. |
There's existing machinery for normalizing the |
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
I believe this is unchanged: "support" messages are not specially surfaced either before or after this PR. AFAICT the main obstacle is setting only support messages to log at a more verbose level than the global limit; neither
In that vein, does this look appropriate?
If we're concerned about compatibility, we could also accept Then either in this PR or separately we could, if we wish, downgrade some
I haven't forgotten this! |
Hmm, that seems like a bug in the |
* The "Support" log level is like "Critical" ('warn' level or above), but additionally logs any events with the 'rocket::suport' target at 'info' level or above.
The "wrong" behavior with |
Oh, whoops! Glad it wasn't an upstream bug! :) |
… with other log levels
Calling 'enter()' directly inside an async function doesn't work properly, but that's easy to forget. The 'in_scope()' API can't be misused in this way, it automatically perfectly delineates which messages the span actually includes, and it saves several 'let' statements.
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.
I'm pretty happy with this. Here are the last few things I think this needs at this point:
- A rebase to get CI passing.
- Consider changing the hash used to disambiguate requests in the log, and/or the way it is formatted. Span
Id
s generated byRegistry
are a multi-level bit-packed generation index, and I threw something ad-hoc together that seemed to look nice on 64-bit systems. - A review from @SergioBenitez
- Any remaining touchups on docs, and re-exports.
- Potentially re-export the entire
tracing
andtracing-subscriber
crates, like is done forfutures
,tokio
, andfigment
today.
- Potentially re-export the entire
Anything that I could do to help this along? I've locally merged |
@felipesere This is currently waiting on me to merge a big change before we rebase this on master. |
Okay, after forever, I am now ready to review this, pending a rebase on/fix-up for Really excited for this. |
I have tentatively pushed this to my fork to run CI and pick up any obvious mistakes (master...jebrosen:tracing-rebase-202103). Due to merge commits and the recent changes in |
Whatever makes life easier for you two! |
@jebrosen Just checking in: should I be reviewing something somewhere? |
Moved to #1579. |
This branch begins the process of migrating Rocket from using the
log
crate for diagnostics to using
tracing
.The motivation for switching from
log
totracing
was discussed indetail on issue #21, in particular, in this comment and later. In
summary,
tracing
allows detailed tracking of contexts in programs,including asynchronous ones. This is essentially a structured,
machine-readable form of the contexts that Rocket's current logging
system conveys through indentation. Additionally,
tracing
data can beconsumed to emit data in a wide variety of formats, and is
backward-compatible with libraries that use the
log
crate.This branch begins the migration by doing the following:
trace
module with re-exports of coretracing
APIstracing_subscriber::Layer
implementation that performs"Rocket-style" log formatting for
tracing
spans and events, andsetting it as the default unless a
tracing
subscriber is set bythe user
log
macros with theirtracing
equivalents.
Furthermore, I've begun the process of converting the existing logging
to more idiomatic
tracing
. I've addedtracing
spans to severaltop-level scopes in Rocket, converted some log messages to structured
events, and replaced some existing uses of indentation with
tracing
spans. Hopefully, this can serve as an example for others to continue
the migration and add tracing instrumentation in new code.
When possible, I've tried to keep the logging format as close to
Rocket's existing logging. I've made a few tweaks to help communicate
more of the structured data that
tracing
diagnostics record, butthe emoji and stuff are all still there. Of course, I am open to making
additional changes to the default format if desired.
I've also re-exported some core
tracing
APIs to try to provide a`batteries-included experience, which seems in keeping with Rocket's
philosophy. If other folks like this, we can add more re-exports; if
we don't, it's fine to remove them.
Potential future work that this PR unlocks includes:
tracing
instrumentation.using
tracing-opentelemetry
and trace propagationheaders like
b3
.Server-Timing
] headers usingtracing
data (similar totide-server-timing
).tracing-error
).tracing
's#[instrument]
attribute work together.Enjoy, and please let me know if there are any questions!