Skip to content

Commit 6eb783d

Browse files
committed
feat(trigger-redis): Add tracing to trigger-redis
Signed-off-by: Caleb Schoepp <[email protected]>
1 parent ee31ddf commit 6eb783d

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

crates/trigger-redis/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ tokio = { version = "1.23", features = ["full"] }
2424

2525
[dev-dependencies]
2626
spin-testing = { path = "../testing" }
27+
28+
[lints]
29+
workspace = true

crates/trigger-redis/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use spin_core::{async_trait, InstancePre};
1111
use spin_trigger::{cli::NoArgs, TriggerAppEngine, TriggerExecutor};
1212
use std::collections::HashMap;
1313
use std::sync::Arc;
14+
use tracing::{instrument, Level};
1415

1516
use crate::spin::SpinRedisExecutor;
1617

@@ -110,6 +111,9 @@ impl TriggerExecutor for RedisTrigger {
110111

111112
impl RedisTrigger {
112113
// Handle the message.
114+
#[instrument(name = "spin_trigger_redis.handle_message", skip(self, channel_components, msg),
115+
err(level = Level::INFO), fields(otel.name = format!("{} receive", msg.get_channel_name()),
116+
otel.kind = "consumer", messaging.operation = "receive", messaging.system = "redis"))]
113117
async fn handle(
114118
&self,
115119
address: &str,

crates/trigger-redis/src/spin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use async_trait::async_trait;
33
use spin_core::Instance;
44
use spin_trigger::TriggerAppEngine;
55
use spin_world::v1::redis_types::{Error, Payload};
6+
use tracing::{instrument, Level};
67

78
use crate::{RedisExecutor, RedisTrigger, Store};
89

@@ -11,6 +12,7 @@ pub struct SpinRedisExecutor;
1112

1213
#[async_trait]
1314
impl RedisExecutor for SpinRedisExecutor {
15+
#[instrument(name = "spin_trigger_redis.execute_wasm", skip(self, engine, payload), err(level = Level::INFO), fields(otel.name = format!("execute_wasm_component {}", component_id)))]
1416
async fn execute(
1517
&self,
1618
engine: &TriggerAppEngine<RedisTrigger>,

0 commit comments

Comments
 (0)