Skip to content

Commit aca9f7f

Browse files
Malletscursoragent
andcommitted
Fix clippy warnings
- Replace .increment() with .inc_by() on LazyCounter call sites in azure_blob_storage and opendal_storage. - Derive Default for TelemetryHandle instead of manual impl. - Auto-fix minor clippy lints in metastore, tower metrics, and split_table. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 0a148d2 commit aca9f7f

6 files changed

Lines changed: 10 additions & 25 deletions

File tree

quickwit/quickwit-common/src/tower/metrics.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ impl<F> PinnedDrop for ResponseFuture<F> {
151151
}
152152

153153
impl<F, T, E> Future for ResponseFuture<F>
154-
where
155-
F: Future<Output = Result<T, E>>,
154+
where F: Future<Output = Result<T, E>>
156155
{
157156
type Output = Result<T, E>;
158157

quickwit/quickwit-metastore/src/metastore/postgres/metrics.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use std::sync::LazyLock;
16-
17-
use quickwit_metrics::{Gauge, LazyGauge, gauge, lazy_gauge};
15+
use quickwit_metrics::{LazyGauge, lazy_gauge};
1816

1917
pub(super) static ACQUIRE_CONNECTIONS: LazyGauge = lazy_gauge!(
2018
name: "acquire_connections",

quickwit/quickwit-storage/src/object_storage/azure_blob_storage.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl AzureBlobStorage {
241241
payload: Box<dyn crate::PutPayload>,
242242
) -> StorageResult<()> {
243243
crate::metrics::OBJECT_STORAGE_PUT_PARTS.inc();
244-
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.increment(payload.len());
244+
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.inc_by(payload.len());
245245
retry(&self.retry_params, || async {
246246
let data = Bytes::from(payload.read_all().await?.to_vec());
247247
let hash = azure_storage_blobs::prelude::Hash::from(md5::compute(&data[..]).0);
@@ -275,7 +275,7 @@ impl AzureBlobStorage {
275275
let moved_blob_client = blob_client.clone();
276276
let moved_payload = payload.clone();
277277
crate::metrics::OBJECT_STORAGE_PUT_PARTS.inc();
278-
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.increment(range.end - range.start);
278+
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.inc_by(range.end - range.start);
279279
async move {
280280
retry(&self.retry_params, || async {
281281
// zero pad block ids to make them sortable as strings
@@ -372,7 +372,7 @@ impl Storage for AzureBlobStorage {
372372
.compat();
373373
let mut body_stream_reader = BufReader::new(chunk_response_body_stream);
374374
let num_bytes_copied = tokio::io::copy_buf(&mut body_stream_reader, output).await?;
375-
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.increment(num_bytes_copied);
375+
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.inc_by(num_bytes_copied);
376376
}
377377
output.flush().await?;
378378
Ok(())
@@ -571,7 +571,7 @@ async fn download_all(
571571
segments.push(bytes);
572572
}
573573
}
574-
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.increment(total_num_bytes as u64);
574+
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.inc_by(total_num_bytes as u64);
575575
Ok(coalesce_segments(segments, total_num_bytes))
576576
}
577577

quickwit/quickwit-storage/src/opendal_storage/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl Storage for OpendalStorage {
9494
.compat_write();
9595
tokio::io::copy(&mut payload_reader, &mut storage_writer).await?;
9696
storage_writer.get_mut().close().await?;
97-
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.increment(payload.len());
97+
crate::metrics::OBJECT_STORAGE_UPLOAD_NUM_BYTES.inc_by(payload.len());
9898
Ok(())
9999
}
100100

@@ -108,7 +108,7 @@ impl Storage for OpendalStorage {
108108
.await?
109109
.compat();
110110
let num_bytes_copied = tokio::io::copy(&mut storage_reader, output).await?;
111-
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.increment(num_bytes_copied);
111+
crate::metrics::OBJECT_STORAGE_DOWNLOAD_NUM_BYTES.inc_by(num_bytes_copied);
112112
output.flush().await?;
113113
Ok(())
114114
}

quickwit/quickwit-storage/src/split_cache/split_table.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,7 @@ impl SplitTable {
154154
Status::Downloading { .. } => &mut self.downloading_splits,
155155
Status::OnDisk { num_bytes } => {
156156
self.on_disk_bytes -= num_bytes;
157-
SEARCHER_SPLIT_CACHE
158-
.cache_metrics
159-
.in_cache_count
160-
.dec();
157+
SEARCHER_SPLIT_CACHE.cache_metrics.in_cache_count.dec();
161158
SEARCHER_SPLIT_CACHE
162159
.cache_metrics
163160
.in_cache_num_bytes

quickwit/quickwit-telemetry-exporters/src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,13 @@ pub fn do_nothing_env_filter_reload_fn() -> EnvFilterReloadFn {
4141
Arc::new(|_| Ok(()))
4242
}
4343

44+
#[derive(Default)]
4445
pub struct TelemetryHandle {
4546
tracer_provider: Option<SdkTracerProvider>,
4647
logger_provider: Option<SdkLoggerProvider>,
4748
meter_provider: Option<SdkMetricsProvider>,
4849
}
4950

50-
impl Default for TelemetryHandle {
51-
fn default() -> Self {
52-
TelemetryHandle {
53-
tracer_provider: None,
54-
logger_provider: None,
55-
meter_provider: None,
56-
}
57-
}
58-
}
59-
6051
impl TelemetryHandle {
6152
pub fn shutdown(self) -> anyhow::Result<()> {
6253
if let Some(tracer_provider) = self.tracer_provider {

0 commit comments

Comments
 (0)