Skip to content
This repository was archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
Fix: tracing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Jun 5, 2022

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
1 parent 7fa4acd commit 92ccdfe
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions rusty-shared-redis/src/lib.rs
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ impl Redis {
/// Thus, I put a short timeout on each `EVALSHA` call.
const EVALSHA_TIMEOUT: time::Duration = time::Duration::from_secs(5);

#[instrument(skip_all, fields(url))]
#[instrument(skip_all, fields(url = url))]
pub async fn connect(url: &str) -> Result<Self> {
let config = {
let mut config = RedisConfig::from_url(url)?;
@@ -39,7 +39,7 @@ impl Redis {

let client = RedisClient::new(config);
connect(&client).await?;
client.client_setname("fred").await?; // FIXME: use bin crate name.
// TODO: client.client_setname("fred").await?; // FIXME: use bin crate name.
let script_hashes = load_scripts(&client).await?;

Ok(Self {
@@ -59,7 +59,7 @@ impl Redis {
Ok(this)
}

#[instrument(skip_all, fields(?key, group_name))]
#[instrument(skip_all, fields(key = ?key, group_name = group_name))]
pub async fn create_consumer_group<K: Into<RedisKey> + Debug>(
&self,
key: K,
@@ -75,7 +75,7 @@ impl Redis {
.context("failed to create the consumer group")
}

#[instrument(skip_all, fields(?key))]
#[instrument(skip_all, fields(key = ?key))]
pub async fn set_if_greater<K, V>(&self, key: K, value: V) -> Result<(bool, Option<V>)>
where
K: Debug + Into<MultipleKeys>,
@@ -93,7 +93,7 @@ impl Redis {
.context("failed to set-if-greater")
}

#[instrument(skip_all, fields(?key))]
#[instrument(skip_all, fields(key = ?key))]
pub async fn set_if_not_equal<K, V>(&self, key: K, value: V) -> Result<(bool, Option<V>)>
where
K: Debug + Into<MultipleKeys>,
4 changes: 2 additions & 2 deletions rusty-shared-telegram/src/methods.rs
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ pub trait Method: Debug + Sized + Serialize {
const NAME: &'static str;

/// Call the method on the specified connection.
#[instrument(level = "debug", skip_all, fields(method_name = Self::NAME))]
#[instrument(skip_all, fields(method_name = Self::NAME))]
async fn call(&self, api: &BotApi) -> Result<Self::Output> {
debug!(self = ?self);
let text = api
@@ -67,7 +67,7 @@ impl Method for GetUpdates {
const NAME: &'static str = "getUpdates";

/// Needs to be implemented separately because of the timeout requirement.
#[instrument(level = "debug", skip_all, fields(method_name = Self::NAME))]
#[instrument(skip_all, fields(method_name = Self::NAME))]
async fn call(&self, api: &BotApi) -> Result<Self::Output> {
debug!(self = ?self, "starting the long polling request…");
let text = api
6 changes: 3 additions & 3 deletions rusty-tractive-telegram-bot/src/bot.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ pub struct Bot {
impl Bot {
const GET_UPDATES_TIMEOUT: time::Duration = time::Duration::from_secs(60);

#[instrument(skip_all, fields(bot_user_id))]
#[instrument(skip_all, fields(bot_user_id = bot_user_id))]
pub fn new(redis: Redis, bot_api: BotApi, bot_user_id: i64) -> Self {
Self {
redis,
@@ -118,7 +118,7 @@ impl Bot {
}

/// Retrieves the bot API offset from which we should read the updates.
#[instrument(skip_all, fields(?self.offset_key))]
#[instrument(skip_all, fields(offset_key = ?self.offset_key))]
async fn get_offset(&self) -> Result<u64> {
let offset = self
.redis
@@ -130,7 +130,7 @@ impl Bot {
Ok(offset)
}

#[instrument(skip_all, fields(offset))]
#[instrument(skip_all, fields(offset = offset))]
async fn set_offset(&self, offset: u64) -> Result<()> {
self.redis
.client
2 changes: 1 addition & 1 deletion rusty-tractive-telegram-bot/src/listener.rs
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ impl Listener {
Ok(())
}

#[instrument(skip_all, fields(current_level, last_level))]
#[instrument(skip_all, fields(current_level = current_level, last_level = last_level))]
async fn on_battery_level_changed(
&self,
last_level: Option<u8>,

0 comments on commit 92ccdfe

Please sign in to comment.