Skip to content

Commit f9d9a39

Browse files
Malletscursoragent
andcommitted
Rename LabelNames constants from *_LABELS to *_LABEL_NAMES
Disambiguates LabelNames<N> (name-only templates) from Labels<N> (name+value pairs) at the call site. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 5877c82 commit f9d9a39

14 files changed

Lines changed: 47 additions & 48 deletions

File tree

quickwit/quickwit-control-plane/src/metrics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub(crate) static OPEN_SHARDS: LazyLock<Gauge> =
5151
pub(crate) static CLOSED_SHARDS: LazyLock<Gauge> =
5252
LazyLock::new(|| gauge!(parent: SHARDS, "state" => "closed"));
5353

54-
pub(crate) const INDEX_ID_LABELS: LabelNames<1> = label_names!("index_id");
54+
pub(crate) const INDEX_ID_LABEL_NAMES: LabelNames<1> = label_names!("index_id");
5555

5656
static INDEXED_SHARDS: LazyLock<Gauge> = LazyLock::new(|| {
5757
gauge!(

quickwit/quickwit-control-plane/src/model/shard_table.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use quickwit_proto::ingest::{Shard, ShardState};
2727
use quickwit_proto::types::{IndexUid, NodeId, ShardId, SourceId, SourceUid};
2828
use tracing::{error, info, warn};
2929

30-
use crate::metrics::{CLOSED_SHARDS, INDEX_ID_LABELS, OPEN_SHARDS};
30+
use crate::metrics::{CLOSED_SHARDS, INDEX_ID_LABEL_NAMES, OPEN_SHARDS};
3131

3232
/// Limits the number of scale up operations that can happen to a source to 5 per minute.
3333
const SCALING_UP_RATE_LIMITER_SETTINGS: RateLimiterSettings = RateLimiterSettings {
@@ -464,7 +464,7 @@ impl ShardTable {
464464
// can update the metrics for this specific index.
465465
if index_label == index_id {
466466
let shard_stats = table_entry.shards_stats();
467-
let labels = label_values!(INDEX_ID_LABELS => index_label.to_string());
467+
let labels = label_values!(INDEX_ID_LABEL_NAMES => index_label.to_string());
468468
gauge!(parent: OPEN_SHARDS, labels: [labels]).set(shard_stats.num_open_shards as f64);
469469
gauge!(parent: CLOSED_SHARDS, labels: [labels])
470470
.set(shard_stats.num_closed_shards as f64);
@@ -481,7 +481,7 @@ impl ShardTable {
481481
num_closed_shards += 1;
482482
}
483483
}
484-
let labels = label_values!(INDEX_ID_LABELS => index_label.to_string());
484+
let labels = label_values!(INDEX_ID_LABEL_NAMES => index_label.to_string());
485485
gauge!(parent: OPEN_SHARDS, labels: [labels]).set(num_open_shards as f64);
486486
gauge!(parent: CLOSED_SHARDS, labels: [labels]).set(num_closed_shards as f64);
487487
}

quickwit/quickwit-jaeger/src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ use tracing::field::Empty;
5353
use tracing::{Span as RuntimeSpan, debug, error, instrument, warn};
5454

5555
use crate::metrics::{
56-
FETCHED_SPANS_TOTAL, FETCHED_TRACES_TOTAL, OPERATION_INDEX_ERROR_LABELS,
57-
OPERATION_INDEX_LABELS, REQUEST_DURATION_SECONDS, REQUEST_ERRORS_TOTAL,
56+
FETCHED_SPANS_TOTAL, FETCHED_TRACES_TOTAL, OPERATION_INDEX_ERROR_LABEL_NAMES,
57+
OPERATION_INDEX_LABEL_NAMES, REQUEST_DURATION_SECONDS, REQUEST_ERRORS_TOTAL,
5858
TRANSFERRED_BYTES_TOTAL,
5959
};
6060

@@ -421,13 +421,13 @@ impl JaegerService {
421421
current_span.record("num_bytes", num_bytes_total);
422422

423423
let labels = label_values!(
424-
OPERATION_INDEX_LABELS => operation_name, OTEL_TRACES_INDEX_ID
424+
OPERATION_INDEX_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID
425425
);
426426
counter!(parent: FETCHED_TRACES_TOTAL, labels: [labels]).increment(num_traces);
427427

428428
let elapsed = request_start.elapsed().as_secs_f64();
429429
let err_labels = label_values!(
430-
OPERATION_INDEX_ERROR_LABELS =>
430+
OPERATION_INDEX_ERROR_LABEL_NAMES =>
431431
operation_name, OTEL_TRACES_INDEX_ID, "false"
432432
);
433433
histogram!(parent: REQUEST_DURATION_SECONDS, labels: [err_labels]).record(elapsed);
@@ -437,18 +437,18 @@ impl JaegerService {
437437
}
438438

439439
pub(crate) fn record_error(operation_name: &'static str, request_start: Instant) {
440-
let labels = label_values!(OPERATION_INDEX_LABELS => operation_name, OTEL_TRACES_INDEX_ID);
440+
let labels = label_values!(OPERATION_INDEX_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID);
441441
counter!(parent: REQUEST_ERRORS_TOTAL, labels: [labels]).increment(1);
442442

443443
let elapsed = request_start.elapsed().as_secs_f64();
444444
let err_labels = label_values!(
445-
OPERATION_INDEX_ERROR_LABELS => operation_name, OTEL_TRACES_INDEX_ID, "true"
445+
OPERATION_INDEX_ERROR_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID, "true"
446446
);
447447
histogram!(parent: REQUEST_DURATION_SECONDS, labels: [err_labels]).record(elapsed);
448448
}
449449

450450
pub(crate) fn record_send(operation_name: &'static str, num_spans: usize, num_bytes: usize) {
451-
let labels = label_values!(OPERATION_INDEX_LABELS => operation_name, OTEL_TRACES_INDEX_ID);
451+
let labels = label_values!(OPERATION_INDEX_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID);
452452
counter!(parent: FETCHED_SPANS_TOTAL, labels: [labels]).increment(num_spans as u64);
453453
counter!(parent: TRANSFERRED_BYTES_TOTAL, labels: [labels]).increment(num_bytes as u64);
454454
}

quickwit/quickwit-jaeger/src/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use std::sync::LazyLock;
1717
use quickwit_common::metrics::exponential_buckets;
1818
use quickwit_metrics::{Counter, Histogram, LabelNames, counter, histogram, label_names};
1919

20-
pub(crate) const OPERATION_INDEX_LABELS: LabelNames<2> = label_names!("operation", "index");
21-
pub(crate) const OPERATION_INDEX_ERROR_LABELS: LabelNames<3> =
20+
pub(crate) const OPERATION_INDEX_LABEL_NAMES: LabelNames<2> = label_names!("operation", "index");
21+
pub(crate) const OPERATION_INDEX_ERROR_LABEL_NAMES: LabelNames<3> =
2222
label_names!("operation", "index", "error");
2323

2424
pub(crate) static REQUESTS_TOTAL: LazyLock<Counter> = LazyLock::new(|| {

quickwit/quickwit-jaeger/src/v1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use quickwit_proto::jaeger::storage::v1::{
2929
use tonic::{Request, Response, Status};
3030

3131
use crate::metrics::{
32-
OPERATION_INDEX_ERROR_LABELS, OPERATION_INDEX_LABELS, REQUEST_DURATION_SECONDS,
32+
OPERATION_INDEX_ERROR_LABEL_NAMES, OPERATION_INDEX_LABEL_NAMES, REQUEST_DURATION_SECONDS,
3333
REQUEST_ERRORS_TOTAL, REQUESTS_TOTAL,
3434
};
3535
use crate::{JaegerService, SpanStream};

quickwit/quickwit-jaeger/src/v2.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ use tracing::field::Empty;
5252
use tracing::{Span as RuntimeSpan, debug, error, instrument};
5353

5454
use crate::metrics::{
55-
FETCHED_TRACES_TOTAL, OPERATION_INDEX_ERROR_LABELS, OPERATION_INDEX_LABELS,
55+
FETCHED_TRACES_TOTAL, OPERATION_INDEX_ERROR_LABEL_NAMES, OPERATION_INDEX_LABEL_NAMES,
5656
REQUEST_DURATION_SECONDS, REQUEST_ERRORS_TOTAL, REQUESTS_TOTAL,
5757
};
5858
use crate::{
@@ -433,12 +433,12 @@ async fn stream_otel_spans_impl(
433433

434434
record_send(operation_name, num_spans, num_bytes);
435435

436-
let labels = label_values!(OPERATION_INDEX_LABELS => operation_name, OTEL_TRACES_INDEX_ID);
436+
let labels = label_values!(OPERATION_INDEX_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID);
437437
counter!(parent: FETCHED_TRACES_TOTAL, labels: [labels]).increment(trace_ids.len() as u64);
438438

439439
let elapsed = request_start.elapsed().as_secs_f64();
440440
let err_labels = label_values!(
441-
OPERATION_INDEX_ERROR_LABELS => operation_name, OTEL_TRACES_INDEX_ID, "false"
441+
OPERATION_INDEX_ERROR_LABEL_NAMES => operation_name, OTEL_TRACES_INDEX_ID, "false"
442442
);
443443
histogram!(parent: REQUEST_DURATION_SECONDS, labels: [err_labels]).record(elapsed);
444444

quickwit/quickwit-metrics/examples/http_service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ static HTTP_ACTIVE_CONNECTIONS_BY_REGION: LazyLock<Gauge> = LazyLock::new(|| {
8383

8484
// ─── LabelNames<N> examples ───
8585

86-
const ROUTE_LABELS: LabelNames<2> = label_names!("method", "path");
86+
const ROUTE_LABEL_NAMES: LabelNames<2> = label_names!("method", "path");
8787

8888
fn record_request(method: &'static str, path: &'static str, duration: f64, size: f64) {
89-
let route = label_values!(ROUTE_LABELS => method, path);
89+
let route = label_values!(ROUTE_LABEL_NAMES => method, path);
9090
histogram!(parent: HTTP_REQUEST_DURATION, labels: [route]).record(duration);
9191
histogram!(parent: HTTP_RESPONSE_SIZE, labels: [route]).record(size);
9292
counter!(parent: HTTP_REQUESTS_TOTAL, labels: [route]).increment(1);
9393
}
9494

9595
fn record_dynamic_request(method: String, path: String, duration: f64) {
96-
let route = label_values!(ROUTE_LABELS => method, path);
96+
let route = label_values!(ROUTE_LABEL_NAMES => method, path);
9797
histogram!(parent: HTTP_REQUEST_DURATION, labels: [route]).record(duration);
9898
}
9999

quickwit/quickwit-metrics/src/labels.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616
//!
1717
//! Labels can be created in two ways:
1818
//!
19-
//! - **[`labels!`]** — inline key-value pairs. Keys are always static
20-
//! literals; values can be static literals (const-compatible, zero
21-
//! allocation) or dynamic expressions (`Into<SharedString>`).
19+
//! - **[`labels!`]** — inline key-value pairs. Keys are always static literals; values can be
20+
//! static literals (const-compatible, zero allocation) or dynamic expressions
21+
//! (`Into<SharedString>`).
2222
//!
23-
//! - **[`label_names!`] + [`label_values!`]** — separate the label *names*
24-
//! (a const [`LabelNames<N>`]) from the *values*. This avoids repeating
25-
//! the same label names at every call site and lets a single
26-
//! [`Labels<N>`] be shared across counter, gauge, and histogram
23+
//! - **[`label_names!`] + [`label_values!`]** — separate the label *names* (a const
24+
//! [`LabelNames<N>`]) from the *values*. This avoids repeating the same label names at every call
25+
//! site and lets a single [`Labels<N>`] be shared across counter, gauge, and histogram
2726
//! extensions.
2827
2928
use metrics::SharedString;

quickwit/quickwit-opentelemetry/src/otlp/logs.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ use super::{
4141
};
4242
use crate::otlp::extract_attributes;
4343
use crate::otlp::metrics::{
44-
INGESTED_BYTES_TOTAL, INGESTED_LOG_RECORDS_TOTAL, OTLP_GRPC_ERROR_LABELS, OTLP_GRPC_LABELS,
45-
REQUEST_DURATION_SECONDS, REQUEST_ERRORS_TOTAL, REQUESTS_TOTAL,
44+
INGESTED_BYTES_TOTAL, INGESTED_LOG_RECORDS_TOTAL, OTLP_GRPC_ERROR_LABEL_NAMES,
45+
OTLP_GRPC_LABEL_NAMES, REQUEST_DURATION_SECONDS, REQUEST_ERRORS_TOTAL, REQUESTS_TOTAL,
4646
};
4747

4848
pub const OTEL_LOGS_INDEX_ID: &str = "otel-logs-v0_9";
@@ -243,7 +243,7 @@ impl OtlpGrpcLogsService {
243243
let num_bytes = doc_batch.num_bytes() as u64;
244244
self.store_logs(index_id.clone(), doc_batch).await?;
245245

246-
let labels = label_values!(OTLP_GRPC_LABELS => "logs", index_id, "grpc", "protobuf");
246+
let labels = label_values!(OTLP_GRPC_LABEL_NAMES => "logs", index_id, "grpc", "protobuf");
247247
counter!(parent: INGESTED_LOG_RECORDS_TOTAL, labels: [labels]).increment(num_log_records);
248248
counter!(parent: INGESTED_BYTES_TOTAL, labels: [labels]).increment(num_bytes);
249249

@@ -317,7 +317,7 @@ impl OtlpGrpcLogsService {
317317
let start = std::time::Instant::now();
318318

319319
let labels =
320-
label_values!(OTLP_GRPC_LABELS => "logs", index_id.clone(), "grpc", "protobuf");
320+
label_values!(OTLP_GRPC_LABEL_NAMES => "logs", index_id.clone(), "grpc", "protobuf");
321321
counter!(parent: REQUESTS_TOTAL, labels: [labels]).increment(1);
322322
let (export_res, is_error) = match self.export_inner(request, index_id.clone()).await {
323323
ok @ Ok(_) => (ok, "false"),
@@ -327,8 +327,7 @@ impl OtlpGrpcLogsService {
327327
}
328328
};
329329
let elapsed = start.elapsed().as_secs_f64();
330-
let error_labels =
331-
label_values!(OTLP_GRPC_ERROR_LABELS => "logs", index_id, "grpc", "protobuf", is_error);
330+
let error_labels = label_values!(OTLP_GRPC_ERROR_LABEL_NAMES => "logs", index_id, "grpc", "protobuf", is_error);
332331
histogram!(parent: REQUEST_DURATION_SECONDS, labels: [error_labels]).record(elapsed);
333332

334333
export_res

quickwit/quickwit-opentelemetry/src/otlp/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use std::sync::LazyLock;
1717
use quickwit_common::metrics::exponential_buckets;
1818
use quickwit_metrics::{Counter, Histogram, LabelNames, counter, histogram, label_names};
1919

20-
pub(crate) const OTLP_GRPC_LABELS: LabelNames<4> =
20+
pub(crate) const OTLP_GRPC_LABEL_NAMES: LabelNames<4> =
2121
label_names!("service", "index", "transport", "format");
22-
pub(crate) const OTLP_GRPC_ERROR_LABELS: LabelNames<5> =
22+
pub(crate) const OTLP_GRPC_ERROR_LABEL_NAMES: LabelNames<5> =
2323
label_names!("service", "index", "transport", "format", "error");
2424

2525
pub(crate) static REQUESTS_TOTAL: LazyLock<Counter> = LazyLock::new(|| {

0 commit comments

Comments
 (0)