Additional span logging of counter state; trace logging of contents.

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk
2025-07-29 22:42:10 +00:00
parent 59b62b1453
commit 1bb16c8b73
9 changed files with 101 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
use std::sync::Arc;
use std::{ops::Range, sync::Arc};
use tokio::sync::{watch, watch::Sender};
use tuwunel_core::{
@@ -53,7 +53,7 @@ impl Data {
.wait_for(|retired| retired.ge(count))
.await
.map(|retired| *retired)
.map_err(|e| err!("counter channel error {e:?}"))
.map_err(|e| err!(debug_error!("counter channel error {e:?}")))
}
#[inline]
@@ -66,6 +66,9 @@ impl Data {
#[inline]
pub fn current_count(&self) -> u64 { self.counter.current() }
#[inline]
pub fn pending_count(&self) -> Range<u64> { self.counter.range() }
fn handle_retire(sender: &Sender<u64>, count: u64) -> Result {
let _prev = sender.send_replace(count);

View File

@@ -3,6 +3,7 @@ mod data;
use std::{
collections::HashMap,
fmt::Write,
ops::Range,
sync::{Arc, RwLock},
time::Instant,
};
@@ -105,22 +106,40 @@ impl crate::Service for Service {
impl Service {
#[inline]
#[tracing::instrument(level = "trace", skip(self))]
#[tracing::instrument(
level = "trace",
skip_all,
ret,
fields(pending = ?self.pending_count()),
)]
pub async fn wait_pending(&self) -> Result<u64> { self.db.wait_pending().await }
#[inline]
#[tracing::instrument(level = "trace", skip(self))]
#[tracing::instrument(
level = "trace",
skip_all,
ret,
fields(pending = ?self.pending_count()),
)]
pub async fn wait_count(&self, count: &u64) -> Result<u64> { self.db.wait_count(count).await }
#[inline]
#[must_use]
#[tracing::instrument(level = "debug", skip(self))]
#[tracing::instrument(
level = "debug",
skip_all,
fields(pending = ?self.pending_count()),
)]
pub fn next_count(&self) -> data::Permit { self.db.next_count() }
#[inline]
#[must_use]
pub fn current_count(&self) -> u64 { self.db.current_count() }
#[inline]
#[must_use]
pub fn pending_count(&self) -> Range<u64> { self.db.pending_count() }
#[inline]
#[must_use]
pub fn server_name(&self) -> &ServerName { self.server.name.as_ref() }