aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/api_server.rs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 8502d9d8..a6bf5a44 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -16,7 +16,7 @@ use opentelemetry::{
use garage_util::data::*;
use garage_util::error::Error as GarageError;
-use garage_util::metrics::RecordDuration;
+use garage_util::metrics::{gen_trace_id, RecordDuration};
use garage_model::garage::Garage;
use garage_model::key_table::Key;
@@ -110,16 +110,12 @@ async fn handler(
debug!("{:?}", req);
let tracer = opentelemetry::global::tracer("garage");
- let trace_id = gen_uuid();
let span = tracer
.span_builder("S3 API call (unknown)")
- .with_trace_id(
- opentelemetry::trace::TraceId::from_hex(&hex::encode(&trace_id.as_slice()[..16]))
- .unwrap(),
- )
+ .with_trace_id(gen_trace_id())
.with_attributes(vec![
KeyValue::new("method", format!("{}", req.method())),
- KeyValue::new("uri", req.uri().path().to_string()),
+ KeyValue::new("uri", req.uri().to_string()),
])
.start(&tracer);
@@ -177,9 +173,14 @@ async fn handler_stage2(
let (endpoint, bucket_name) = Endpoint::from_request(&req, bucket_name.map(ToOwned::to_owned))?;
debug!("Endpoint: {:?}", endpoint);
- Context::current()
- .span()
- .update_name::<String>(format!("S3 API {}", endpoint.name()));
+ let current_context = Context::current();
+ let current_span = current_context.span();
+ current_span.update_name::<String>(format!("S3 API {}", endpoint.name()));
+ current_span.set_attribute(KeyValue::new("endpoint", endpoint.name()));
+ current_span.set_attribute(KeyValue::new(
+ "bucket",
+ bucket_name.clone().unwrap_or_default(),
+ ));
let metrics_tags = &[KeyValue::new("api_endpoint", endpoint.name())];