@@ -5,6 +5,7 @@ use spin_locked_app::MetadataKey;
55use spin_world:: v2:: key_value;
66use std:: { collections:: HashSet , sync:: Arc } ;
77use table:: Table ;
8+ use tracing:: { instrument, Level } ;
89
910pub const KEY_VALUE_STORES_KEY : MetadataKey < Vec < String > > = MetadataKey :: new ( "key_value_stores" ) ;
1011
@@ -79,6 +80,7 @@ impl key_value::Host for KeyValueDispatch {}
7980
8081#[ async_trait]
8182impl key_value:: HostStore for KeyValueDispatch {
83+ #[ instrument( name = "spin_key_value.open" , skip( self ) , err( level = Level :: INFO ) , fields( otel. kind = "client" , kv. backend=self . manager. summary( & name) . unwrap_or( "unknown" . to_string( ) ) ) ) ]
8284 async fn open ( & mut self , name : String ) -> Result < Result < Resource < key_value:: Store > , Error > > {
8385 Ok ( async {
8486 if self . allowed_stores . contains ( & name) {
@@ -94,6 +96,7 @@ impl key_value::HostStore for KeyValueDispatch {
9496 . await )
9597 }
9698
99+ #[ instrument( name = "spin_key_value.get" , skip( self , store) , err( level = Level :: INFO ) , fields( otel. kind = "client" ) ) ]
97100 async fn get (
98101 & mut self ,
99102 store : Resource < key_value:: Store > ,
@@ -103,6 +106,7 @@ impl key_value::HostStore for KeyValueDispatch {
103106 Ok ( store. get ( & key) . await )
104107 }
105108
109+ #[ instrument( name = "spin_key_value.set" , skip( self , store, value) , err( level = Level :: INFO ) , fields( otel. kind = "client" ) ) ]
106110 async fn set (
107111 & mut self ,
108112 store : Resource < key_value:: Store > ,
@@ -113,6 +117,7 @@ impl key_value::HostStore for KeyValueDispatch {
113117 Ok ( store. set ( & key, & value) . await )
114118 }
115119
120+ #[ instrument( name = "spin_key_value.delete" , skip( self , store) , err( level = Level :: INFO ) , fields( otel. kind = "client" ) ) ]
116121 async fn delete (
117122 & mut self ,
118123 store : Resource < key_value:: Store > ,
@@ -122,6 +127,7 @@ impl key_value::HostStore for KeyValueDispatch {
122127 Ok ( store. delete ( & key) . await )
123128 }
124129
130+ #[ instrument( name = "spin_key_value.exists" , skip( self , store) , err( level = Level :: INFO ) , fields( otel. kind = "client" ) ) ]
125131 async fn exists (
126132 & mut self ,
127133 store : Resource < key_value:: Store > ,
@@ -131,6 +137,7 @@ impl key_value::HostStore for KeyValueDispatch {
131137 Ok ( store. exists ( & key) . await )
132138 }
133139
140+ #[ instrument( name = "spin_key_value.get_keys" , skip( self , store) , err( level = Level :: INFO ) , fields( otel. kind = "client" ) ) ]
134141 async fn get_keys (
135142 & mut self ,
136143 store : Resource < key_value:: Store > ,
0 commit comments