-
Notifications
You must be signed in to change notification settings - Fork 721
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
backport 9 commits from master
#2174
Conversation
This patch adds a bit more context around why we are creating a smaller scope for the spans, and also what happens when we call `global::shutdown_tracer_provider()` (that comment was copied from the`rust-opentelemetry` repo). Co-authored-by: Eliza Weisman <eliza@buoyant.io>
* fix use of `cargo --list` in bin/publish * fix shellcheck lints in bin/publish * set -euo pipefail * fix cargo hack exit status check * fix wrong emptystring args * prompt before installing cargo-hack Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Adds inherent `downcast_ref` and `is` inherent methods to: - `dyn Subscriber + Send` - `dyn Subscriber + Sync` - `dyn Subscriber + Send + Sync` - `Layered` These additional implementations reduce the circumstances in which one must cast to `dyn Subscriber` (which, previously, was the only type for which `downcast_ref` and `is` were available).
Adds tracing-logfmt crate to the related crates section
10bf03a
to
b37aaf8
Compare
I intended to backport #2159 as well, but unfortunately, it will probably be more involved to make it work on |
## Motivation Currently, it is rather difficult to record `String`s as field values, even though `&str` is a primitive `Value` type. For example, this code does not currently compile: ```rust let my_string = String::from("hello world!"); tracing::debug!(my_string); ``` Instead, it is necessary to explicitly call `String::as_str` or a similar conversion method: ```rust let my_string = String::from("hello world!"); tracing::debug!(my_string = my_string.as_str()); ``` This is unfortunate, as it makes a fairly straightforward, commomplace task (recording a `String` as a field) unnecessarily verbose. ## Solution This branch adds an `impl Value for String` in `tracing-core`. The impl simply calls `String::as_str` and then calls `record_str`. Because `Value` takes an `&self`, and there are preexisting `impl<T: Value> Value` for `&T` and `&mut T`, the string is not consumed, and `&String` or `&mut String`s can also be used as `Value`s. I've also added tests validating that this actually works.
#2161) These broader impls supersede the previous impls where the inner type was a `dyn Subscriber`. With these generic impls, you no longer must (but still can, if you wish) cast the inner type of a boxed or arc'd subscriber to `dyn Subscriber` to use it as a `Subscriber`.
## Motivation I've received a request at work to record 128-bit integers and realized that we should probably support recording them. ## Solution Added two methods to the `Visit` trait, `record_i128` and `record_u128`. However, I didn't add the size conversions present for 64-bit integers, as 128-bit integers are, at this time, more specialized.
## Motivation Allow filter layers to filter on the contents of events (see #2007). ## Solution This branch adds a new `Subscriber::event_enabled` method, taking an `Event` and returning `bool`. This is called before the `Subscriber::event` method, and if it returns `false`, `Subscriber::event` is not called. For simple subscriber (e.g. not using `Layer`s), the `event_enabled` method is not particulary necessary, as the subscriber can just skip the `event` call. However, this branch also adds a new `Layer::event_enabled` method, with the signature: ```rust fn event_enabled(&self, event: &Event<'_>, ctx: Context<'_, S>) -> bool; ``` This is called before `Layer::on_event`, and if `event_enabled` returns `false`, `on_event` is not called (nor is `Subscriber::event`). This allows filter `Layer`s to filter out an `Event` based on its fields. Closes #2007
In many cases, new releases of a dependency can break compatibility with `tracing`'s minimum supported Rust version (MSRV). It shouldn't be necessary for a `tracing` crate to bump its MSRV when a dependency does, as users on older Rust versions should be able to depend on older versions of that crate explicitly and avoid bumping. Instead, we should probably just run our MSRV checks with minimal dependency versions. This way, we don't need to bump our MSRV when the latest version of a dependency does, unless we actually *need* to pick up that new version. This branch changes the `check_msrv` CI jobs to do that. I also did some minor dependency editing to actually make tracing build with `-Zminimal-versions`. Note that `tracing-futures` is currently excluded from the MSRV build because it depends on a really ancient version of Tokio that pulls in broken deps. We should probably drop support for Tokio 0.1 and release a new version of that crate, but for now, we have to skip it from the CI job temporarily. Signed-off-by: Eliza Weisman <eliza@buoyant.io>
b37aaf8
to
0231ad6
Compare
This backports the following changes from
master
tov0.1.x
:event_enabled
to filter events on fields (Add Subscribe::event_enabled to conditionally dis/enable events based on fields #2008)impl<S: Subscriber + ?Sized> Subscriber
forBox<S>
,Arc<S>
(tracing-core: impl<C: Collect + ?Sized> Collect for Box<C>, Arc<C> #2161)impl field::Value for String
(core:impl field::Value for String
#2164)downcast_ref
&is
methods (tracing-core,tracing-subscriber: moredowncast_ref
&is
methods #2160)bin/publish
shell script fixes (chore:bin/publish
shell script fixes #2162)In particular, PR #2171 fixes the CI build.