@@ -2,7 +2,7 @@ use super::{Cas, SwapError};
22use anyhow:: { Context , Result } ;
33use spin_core:: { async_trait, wasmtime:: component:: Resource } ;
44use spin_resource_table:: Table ;
5- use spin_telemetry:: OpenTelemetrySpanExt as _ ;
5+ use spin_telemetry:: traces :: { self , Fault } ;
66use spin_world:: v2:: key_value;
77use spin_world:: wasi:: keyvalue as wasi_keyvalue;
88use std:: { collections:: HashSet , sync:: Arc } ;
@@ -72,10 +72,7 @@ impl KeyValueDispatch {
7272 pub fn get_store < T : ' static > ( & self , store : Resource < T > ) -> anyhow:: Result < & Arc < dyn Store > > {
7373 let res = self . stores . get ( store. rep ( ) ) . context ( "invalid store" ) ;
7474 if let Err ( err) = & res {
75- let current_span = tracing:: Span :: current ( ) ;
76- current_span. set_status ( spin_telemetry:: opentelemetry:: trace:: Status :: error (
77- err. to_string ( ) ,
78- ) ) ;
75+ traces:: mark_as_error ( err, Some ( Fault :: Host ) ) ;
7976 }
8077 res
8178 }
@@ -190,12 +187,11 @@ impl key_value::HostStore for KeyValueDispatch {
190187
191188/// Make sure that infrastructure related errors are tracked in the current span.
192189fn track_error_on_span ( err : Error ) -> Error {
193- if let Error :: Other ( _) | Error :: StoreTableFull = & err {
194- let current_span = tracing:: Span :: current ( ) ;
195- current_span. set_status ( spin_telemetry:: opentelemetry:: trace:: Status :: error (
196- err. to_string ( ) ,
197- ) ) ;
198- }
190+ let fault = match err {
191+ Error :: NoSuchStore | Error :: AccessDenied => Fault :: Guest ,
192+ Error :: StoreTableFull | Error :: Other ( _) => Fault :: Host ,
193+ } ;
194+ traces:: mark_as_error ( & err, Some ( fault) ) ;
199195 err
200196}
201197
0 commit comments