Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracing spans for sending queue messages #86

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading