Skip to content

Commit da90d58

Browse files
authored
feat(query): add bucket name to storage http request metrics (#17431)
* feat(query): add bucket name to storage http request metrics * z
1 parent 53b4ab9 commit da90d58

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/common/metrics/src/metrics/storage.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static OMIT_FILTER_ROWS: LazyLock<Counter> = LazyLock::new(|| register_counter("
3535
struct StorageHttpLabels {
3636
host: String,
3737
method: String,
38+
bucket: String,
3839
}
3940

4041
static STORAGE_HTTP_REQUESTS_COUNT: LazyLock<FamilyCounter<StorageHttpLabels>> =
@@ -320,9 +321,13 @@ pub fn metrics_inc_omit_filter_rows(c: u64) {
320321
}
321322

322323
/// Storage Http metrics.
323-
pub fn metrics_inc_storage_http_requests_count(host: String, method: String) {
324+
pub fn metrics_inc_storage_http_requests_count(host: String, method: String, bucket: String) {
324325
STORAGE_HTTP_REQUESTS_COUNT
325-
.get_or_create(&StorageHttpLabels { host, method })
326+
.get_or_create(&StorageHttpLabels {
327+
host,
328+
method,
329+
bucket,
330+
})
326331
.inc();
327332
}
328333

src/common/storage/src/http_client.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ impl HttpFetch for StorageHttpClient {
6060
}
6161
m => m.as_str(),
6262
};
63-
metrics_inc_storage_http_requests_count(host.to_string(), method.to_string());
63+
// get first component in path as bucket name
64+
let bucket = match url.path_segments() {
65+
Some(mut segments) => segments.next().unwrap_or("-"),
66+
None => "-",
67+
};
68+
metrics_inc_storage_http_requests_count(
69+
host.to_string(),
70+
method.to_string(),
71+
bucket.to_string(),
72+
);
6473

6574
let (parts, body) = req.into_parts();
6675

0 commit comments

Comments
 (0)