Skip to content

Commit

Permalink
fix: make kv log extraction easier (#2666)
Browse files Browse the repository at this point in the history
  • Loading branch information
dracarys18 authored Oct 30, 2023
1 parent d682471 commit 577ef1a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions crates/storage_impl/src/redis/kv_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where
let result = async {
match op {
KvOperation::Hset(value, sql) => {
logger::debug!("Operation: {operation} value: {value:?}");
logger::debug!(kv_operation= %operation, value = ?value);

redis_conn
.set_hash_fields(key, value, Some(consts::KV_TTL))
Expand All @@ -133,7 +133,7 @@ where
}

KvOperation::HSetNx(field, value, sql) => {
logger::debug!("Operation: {operation} value: {value:?}");
logger::debug!(kv_operation= %operation, value = ?value);

let result = redis_conn
.serialize_and_set_hash_field_if_not_exist(
Expand All @@ -153,7 +153,7 @@ where
}

KvOperation::SetNx(value, sql) => {
logger::debug!("Operation: {operation} value: {value:?}");
logger::debug!(kv_operation= %operation, value = ?value);

let result = redis_conn
.serialize_and_set_key_if_not_exist(key, value, Some(consts::KV_TTL.into()))
Expand All @@ -178,14 +178,14 @@ where
result
.await
.map(|result| {
logger::debug!("KvOperation {operation} succeeded");
logger::debug!(kv_operation= %operation, status="success");
let keyvalue = router_env::opentelemetry::KeyValue::new("operation", operation.clone());

metrics::KV_OPERATION_SUCCESSFUL.add(&metrics::CONTEXT, 1, &[keyvalue]);
result
})
.map_err(|err| {
logger::error!("KvOperation for {operation} failed with {err:?}");
logger::error!(kv_operation = %operation, status="error", error = ?err);
let keyvalue = router_env::opentelemetry::KeyValue::new("operation", operation);

metrics::KV_OPERATION_FAILED.add(&metrics::CONTEXT, 1, &[keyvalue]);
Expand Down

0 comments on commit 577ef1a

Please sign in to comment.