Skip to content

Commit

Permalink
Set all datastore spans back to trace level
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-cattermole committed Jun 7, 2024
1 parent b9764e3 commit 37f6cd0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions limitador/src/storage/redis/redis_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use redis::{AsyncCommands, RedisError};
use std::collections::HashSet;
use std::str::FromStr;
use std::time::Duration;
use tracing::{debug_span, Instrument};
use tracing::{trace_span, Instrument};

// Note: this implementation does not guarantee exact limits. Ensuring that we
// never go over the limits would hurt performance. This implementation
Expand All @@ -37,7 +37,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {

match con
.get::<String, Option<i64>>(key_for_counter(counter))
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
{
Some(val) => Ok(u64::try_from(val).unwrap_or(0) + delta <= counter.max_value()),
Expand All @@ -55,7 +55,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
.arg(counter.window().as_secs())
.arg(delta)
.invoke_async::<_, _>(&mut con)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?;

Ok(())
Expand All @@ -82,7 +82,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
let script_res: Vec<Option<i64>> = {
script_invocation
.invoke_async(&mut con)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};
if let Some(res) = is_limited(counters, delta, script_res) {
Expand All @@ -93,7 +93,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
redis::cmd("MGET")
.arg(counter_keys.clone())
.query_async(&mut con)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};

Expand All @@ -119,7 +119,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
.arg(counter.window().as_secs())
.arg(delta)
.invoke_async::<_, _>(&mut con)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
}

Expand All @@ -135,7 +135,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
for limit in limits {
let counter_keys = {
con.smembers::<String, HashSet<String>>(key_for_counters_of_limit(&limit))
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};

Expand All @@ -151,14 +151,14 @@ impl AsyncCounterStorage for AsyncRedisStorage {
// unnecessarily.
let option = {
con.get::<String, Option<i64>>(counter_key.clone())
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};
if let Some(val) = option {
counter.set_remaining(limit.max_value() - u64::try_from(val).unwrap_or(0));
let ttl: i64 = {
con.ttl(&counter_key)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};
counter.set_expires_in(Duration::from_secs(u64::try_from(ttl).unwrap_or(0)));
Expand All @@ -175,7 +175,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
async fn delete_counters(&self, limits: HashSet<Limit>) -> Result<(), StorageErr> {
for limit in limits {
self.delete_counters_associated_with_limit(&limit)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
}
Ok(())
Expand All @@ -186,7 +186,7 @@ impl AsyncCounterStorage for AsyncRedisStorage {
let mut con = self.conn_manager.clone();
redis::cmd("FLUSHDB")
.query_async(&mut con)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?;
Ok(())
}
Expand All @@ -213,13 +213,13 @@ impl AsyncRedisStorage {

let counter_keys = {
con.smembers::<String, HashSet<String>>(key_for_counters_of_limit(limit))
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?
};

for counter_key in counter_keys {
con.del(counter_key)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await?;
}

Expand Down
4 changes: 2 additions & 2 deletions limitador/src/storage/redis/redis_cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tracing::{debug_span, error, info, warn, Instrument};
use tracing::{error, info, trace_span, warn, Instrument};

// This is just a first version.
//
Expand Down Expand Up @@ -310,7 +310,7 @@ async fn update_counters<C: ConnectionLike>(
// The redis crate is not working with tables, thus the response will be a Vec of counter values
let script_res: Vec<i64> = match script_invocation
.invoke_async(redis_conn)
.instrument(debug_span!("datastore"))
.instrument(trace_span!("datastore"))
.await
{
Ok(res) => res,
Expand Down

0 comments on commit 37f6cd0

Please sign in to comment.