@@ -9,6 +9,7 @@ use spin_world::v2::redis::{
9
9
} ;
10
10
11
11
pub use host_component:: OutboundRedisComponent ;
12
+ use tracing:: { instrument, Level } ;
12
13
13
14
struct RedisResults ( Vec < RedisResult > ) ;
14
15
@@ -70,8 +71,12 @@ impl OutboundRedis {
70
71
71
72
impl v2:: Host for OutboundRedis { }
72
73
74
+ // TODO: #[instrument(err)] is only reporting the outer error (if the guest traps), we want to mark
75
+ // the span as failed if the inner result is an error too.
76
+
73
77
#[ async_trait]
74
78
impl v2:: HostConnection for OutboundRedis {
79
+ #[ instrument( name = "spin_outbound_redis.open_connection" , skip( self ) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" ) ) ]
75
80
async fn open ( & mut self , address : String ) -> Result < Result < Resource < RedisConnection > , Error > > {
76
81
if !self . is_address_allowed ( & address) {
77
82
return Ok ( Err ( Error :: InvalidAddress ) ) ;
@@ -80,6 +85,7 @@ impl v2::HostConnection for OutboundRedis {
80
85
self . establish_connection ( address) . await
81
86
}
82
87
88
+ #[ instrument( name = "spin_outbound_redis.publish" , skip( self , connection, payload) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "PUBLISH {}" , channel) ) ) ]
83
89
async fn publish (
84
90
& mut self ,
85
91
connection : Resource < RedisConnection > ,
@@ -96,6 +102,7 @@ impl v2::HostConnection for OutboundRedis {
96
102
. await )
97
103
}
98
104
105
+ #[ instrument( name = "spin_outbound_redis.get" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "GET {}" , key) ) ) ]
99
106
async fn get (
100
107
& mut self ,
101
108
connection : Resource < RedisConnection > ,
@@ -109,6 +116,7 @@ impl v2::HostConnection for OutboundRedis {
109
116
. await )
110
117
}
111
118
119
+ #[ instrument( name = "spin_outbound_redis.set" , skip( self , connection, value) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "SET {}" , key) ) ) ]
112
120
async fn set (
113
121
& mut self ,
114
122
connection : Resource < RedisConnection > ,
@@ -123,6 +131,7 @@ impl v2::HostConnection for OutboundRedis {
123
131
. await )
124
132
}
125
133
134
+ #[ instrument( name = "spin_outbound_redis.incr" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "INCRBY {} 1" , key) ) ) ]
126
135
async fn incr (
127
136
& mut self ,
128
137
connection : Resource < RedisConnection > ,
@@ -136,6 +145,7 @@ impl v2::HostConnection for OutboundRedis {
136
145
. await )
137
146
}
138
147
148
+ #[ instrument( name = "spin_outbound_redis.del" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "DEL {}" , keys. join( " " ) ) ) ) ]
139
149
async fn del (
140
150
& mut self ,
141
151
connection : Resource < RedisConnection > ,
@@ -149,6 +159,7 @@ impl v2::HostConnection for OutboundRedis {
149
159
. await )
150
160
}
151
161
162
+ #[ instrument( name = "spin_outbound_redis.sadd" , skip( self , connection, values) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "SADD {} {}" , key, values. join( " " ) ) ) ) ]
152
163
async fn sadd (
153
164
& mut self ,
154
165
connection : Resource < RedisConnection > ,
@@ -169,6 +180,7 @@ impl v2::HostConnection for OutboundRedis {
169
180
. await )
170
181
}
171
182
183
+ #[ instrument( name = "spin_outbound_redis.smembers" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "SMEMBERS {}" , key) ) ) ]
172
184
async fn smembers (
173
185
& mut self ,
174
186
connection : Resource < RedisConnection > ,
@@ -182,6 +194,7 @@ impl v2::HostConnection for OutboundRedis {
182
194
. await )
183
195
}
184
196
197
+ #[ instrument( name = "spin_outbound_redis.srem" , skip( self , connection, values) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "SREM {} {}" , key, values. join( " " ) ) ) ) ]
185
198
async fn srem (
186
199
& mut self ,
187
200
connection : Resource < RedisConnection > ,
@@ -196,6 +209,7 @@ impl v2::HostConnection for OutboundRedis {
196
209
. await )
197
210
}
198
211
212
+ #[ instrument( name = "spin_outbound_redis.execute" , skip( self , connection) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "redis" , otel. name = format!( "{}" , command) ) ) ]
199
213
async fn execute (
200
214
& mut self ,
201
215
connection : Resource < RedisConnection > ,
0 commit comments