Skip to content

Commit

Permalink
Add tracing spans for sending queue messages (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte authored May 17, 2024
1 parent 94bf7bb commit 62ca8fa
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions omniqueue/src/backends/azure_queue_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ impl AqsProducer {
self.send_raw_scheduled(payload, Duration::ZERO).await
}

#[tracing::instrument(
name = "send",
skip_all,
fields(
payload_size = payload.len(),
delay = (delay > Duration::ZERO).then(|| tracing::field::debug(delay))
)
)]
pub async fn send_raw_scheduled(&self, payload: &str, delay: Duration) -> Result<()> {
self.client
.put_message(payload)
Expand Down
5 changes: 5 additions & 0 deletions omniqueue/src/backends/gcp_pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ impl GcpPubSubProducer {
})
}

#[tracing::instrument(
name = "send",
skip_all,
fields(payload_size = payload.len())
)]
pub async fn send_raw(&self, payload: &[u8]) -> Result<()> {
let msg = PubsubMessage {
data: payload.to_vec(),
Expand Down
10 changes: 10 additions & 0 deletions omniqueue/src/backends/rabbitmq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ impl RabbitMqProducer {
Ok(())
}

#[tracing::instrument(
name = "send",
skip_all,
fields(payload_size = payload.len())
)]
pub async fn send_raw(&self, payload: &[u8]) -> Result<()> {
self.send_raw_with_headers(payload, None).await
}
Expand All @@ -173,6 +178,11 @@ impl RabbitMqProducer {
self.send_raw(&payload).await
}

#[tracing::instrument(
name = "send",
skip_all,
fields(payload_size = payload.len(), delay)
)]
pub async fn send_raw_scheduled(&self, payload: &[u8], delay: Duration) -> Result<()> {
let mut headers = FieldTable::default();

Expand Down
10 changes: 10 additions & 0 deletions omniqueue/src/backends/redis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ pub struct RedisProducer<M: ManageConnection> {
}

impl<R: RedisConnection> RedisProducer<R> {
#[tracing::instrument(
name = "send",
skip_all,
fields(payload_size = payload.len())
)]
pub async fn send_raw(&self, payload: &[u8]) -> Result<()> {
if self.use_redis_streams {
streams::send_raw(self, payload).await
Expand All @@ -546,6 +551,11 @@ impl<R: RedisConnection> RedisProducer<R> {
self.send_raw(&payload).await
}

#[tracing::instrument(
name = "send",
skip_all,
fields(payload_size = payload.len(), delay)
)]
pub async fn send_raw_scheduled(&self, payload: &[u8], delay: Duration) -> Result<()> {
let timestamp = unix_timestamp(SystemTime::now() + delay).map_err(QueueError::generic)?;

Expand Down
8 changes: 8 additions & 0 deletions omniqueue/src/backends/sqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ impl SqsProducer {
self.send_raw(&payload).await
}

#[tracing::instrument(
name = "send",
skip_all,
fields(
payload_size = payload.len(),
delay = (delay > Duration::ZERO).then(|| tracing::field::debug(delay))
)
)]
pub async fn send_raw_scheduled(&self, payload: &str, delay: Duration) -> Result<()> {
if payload.len() > MAX_PAYLOAD_SIZE {
return Err(QueueError::PayloadTooLarge {
Expand Down

0 comments on commit 62ca8fa

Please sign in to comment.