Skip to content

Commit 7b9c543

Browse files
committed
fix(subscriber): remove unused AggregatorHandle and fix other lints
A number of new or updated Clippy lints in Rust 1.80.0 need to be fixed. An update to the `dead_code` pointed out that the `AggregatorHandle` is not used, and it is not constructable from outside the crate because it has a private field. This struct was introduced in #451 as part of the `Server::into_parts` method. Originally, this method was going to return the `AggregatorHandle`, which wrapped the join handle from the task where the `Aggregator` had been spawned. This was later replaced by returning the `Aggregator` itself, which the user had the obligation to spawn themselves. However, it seems that the `AggregatorHandle` wasn't removed, even though it was never used. A new lint is the one for unexpected `--cfg` items. We now need to declare those in `Cargo.toml`. An update to `needless_borrows_for_generic_args` causes a false positive changing a `&mut` to a move, which we can't do as the same value is used afterwards.
1 parent 9205e15 commit 7b9c543

File tree

4 files changed

+11
-36
lines changed

4 files changed

+11
-36
lines changed

console-subscriber/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ futures = "0.3"
6363
http = "1.1"
6464
tower-http = { version = "0.5", features = ["cors"] }
6565

66+
[lints.rust.unexpected_cfgs]
67+
level = "warn"
68+
check-cfg = [ 'cfg(tokio_unstable)', 'cfg(console_without_tokio_unstable)' ]
69+
6670
[package.metadata.docs.rs]
6771
all-features = true
6872
rustdoc-args = ["--cfg", "docsrs"]

console-subscriber/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ runtime][Tokio] is considered *experimental*. In order to use
9494
level].
9595

9696
+ If you're using the [`console_subscriber::init()`][init] or
97-
[`console_subscriber::Builder`][builder] APIs, these targets are enabled
98-
automatically.
97+
[`console_subscriber::Builder`][builder] APIs, these targets are enabled
98+
automatically.
9999

100100
+ If you are manually configuring the `tracing` subscriber using the
101-
[`EnvFilter`] or [`Targets`] filters from [`tracing-subscriber`], add
102-
`"tokio=trace,runtime=trace"` to your filter configuration.
101+
[`EnvFilter`] or [`Targets`] filters from [`tracing-subscriber`], add
102+
`"tokio=trace,runtime=trace"` to your filter configuration.
103103

104104
+ Also, ensure you have not enabled any of the [compile time filter
105105
features][compile_time_filters] in your `Cargo.toml`.

console-subscriber/src/lib.rs

-32
Original file line numberDiff line numberDiff line change
@@ -1187,38 +1187,6 @@ pub struct ServerParts {
11871187
pub aggregator: Aggregator,
11881188
}
11891189

1190-
/// Aggregator handle.
1191-
///
1192-
/// This object is returned from [`Server::into_parts`]. It can be
1193-
/// used to abort the aggregator task.
1194-
///
1195-
/// The aggregator collects the traces that implement the async runtime
1196-
/// being observed and prepares them to be served by the gRPC server.
1197-
///
1198-
/// Normally, if the server, started with [`Server::serve`] or
1199-
/// [`Server::serve_with`] stops for any reason, the aggregator is aborted,
1200-
/// hoewver, if the server was started with the [`InstrumentServer`] returned
1201-
/// from [`Server::into_parts`], then it is the responsibility of the user
1202-
/// of the API to stop the aggregator task by calling [`abort`] on this
1203-
/// object.
1204-
///
1205-
/// [`abort`]: fn@crate::AggregatorHandle::abort
1206-
pub struct AggregatorHandle {
1207-
join_handle: JoinHandle<()>,
1208-
}
1209-
1210-
impl AggregatorHandle {
1211-
/// Aborts the task running this aggregator.
1212-
///
1213-
/// To avoid having a disconnected aggregator running forever, this
1214-
/// method should be called when the [`tonic::transport::Server`] started
1215-
/// with the [`InstrumentServer`] also returned from [`Server::into_parts`]
1216-
/// stops running.
1217-
pub fn abort(&mut self) {
1218-
self.join_handle.abort();
1219-
}
1220-
}
1221-
12221190
#[tonic::async_trait]
12231191
impl proto::instrument::instrument_server::Instrument for Server {
12241192
type WatchUpdatesStream =

console-subscriber/src/record.rs

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ fn record_io(file: File, rx: Receiver<Event>) -> io::Result<()> {
8383
use std::io::{BufWriter, Write};
8484

8585
fn write<T: Serialize>(mut file: &mut BufWriter<File>, val: &T) -> io::Result<()> {
86+
// Clippy throws a false positive here. We can't actually pass the owned `file` to
87+
// `to_writer` because we need it again in the line blow.
88+
#[allow(clippy::needless_borrows_for_generic_args)]
8689
serde_json::to_writer(&mut file, val)?;
8790
file.write_all(b"\n")
8891
}

0 commit comments

Comments
 (0)