forked from Deuxfleurs/garage
web: Ported to opentelemetry 0.18.
This commit is contained in:
parent
2d584889f2
commit
930e5f167d
1 changed files with 7 additions and 4 deletions
|
@ -11,7 +11,7 @@ use hyper::{
|
||||||
|
|
||||||
use opentelemetry::{
|
use opentelemetry::{
|
||||||
global,
|
global,
|
||||||
metrics::{Counter, ValueRecorder},
|
metrics::{Counter, Histogram},
|
||||||
trace::{FutureExt, TraceContextExt, Tracer},
|
trace::{FutureExt, TraceContextExt, Tracer},
|
||||||
Context, KeyValue,
|
Context, KeyValue,
|
||||||
};
|
};
|
||||||
|
@ -34,7 +34,7 @@ use garage_util::metrics::{gen_trace_id, RecordDuration};
|
||||||
struct WebMetrics {
|
struct WebMetrics {
|
||||||
request_counter: Counter<u64>,
|
request_counter: Counter<u64>,
|
||||||
error_counter: Counter<u64>,
|
error_counter: Counter<u64>,
|
||||||
request_duration: ValueRecorder<f64>,
|
request_duration: Histogram<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebMetrics {
|
impl WebMetrics {
|
||||||
|
@ -50,7 +50,7 @@ impl WebMetrics {
|
||||||
.with_description("Number of requests to the web endpoint resulting in errors")
|
.with_description("Number of requests to the web endpoint resulting in errors")
|
||||||
.init(),
|
.init(),
|
||||||
request_duration: meter
|
request_duration: meter
|
||||||
.f64_value_recorder("web.request_duration")
|
.f64_histogram("web.request_duration")
|
||||||
.with_description("Duration of requests to the web endpoint")
|
.with_description("Duration of requests to the web endpoint")
|
||||||
.init(),
|
.init(),
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,9 @@ impl WebServer {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
// More instrumentation
|
// More instrumentation
|
||||||
self.metrics.request_counter.add(1, &metrics_tags[..]);
|
self.metrics
|
||||||
|
.request_counter
|
||||||
|
.add(&Context::current(), 1, &metrics_tags[..]);
|
||||||
|
|
||||||
// Returning the result
|
// Returning the result
|
||||||
match res {
|
match res {
|
||||||
|
@ -144,6 +146,7 @@ impl WebServer {
|
||||||
error
|
error
|
||||||
);
|
);
|
||||||
self.metrics.error_counter.add(
|
self.metrics.error_counter.add(
|
||||||
|
&Context::current(),
|
||||||
1,
|
1,
|
||||||
&[
|
&[
|
||||||
metrics_tags[0].clone(),
|
metrics_tags[0].clone(),
|
||||||
|
|
Loading…
Reference in a new issue