@@ -3,6 +3,7 @@ use std::sync::Arc;
3
3
4
4
use async_trait:: async_trait;
5
5
6
+ use spin_factor_observe:: ObserveContext ;
6
7
use spin_factors:: wasmtime:: component:: Resource ;
7
8
use spin_factors:: { anyhow, SelfInstanceBuilder } ;
8
9
use spin_world:: v1:: sqlite as v1;
@@ -16,6 +17,7 @@ pub struct InstanceState {
16
17
allowed_databases : Arc < HashSet < String > > ,
17
18
connections : table:: Table < Box < dyn Connection > > ,
18
19
get_connection_creator : ConnectionCreatorGetter ,
20
+ observe_context : ObserveContext ,
19
21
}
20
22
21
23
impl InstanceState {
@@ -35,11 +37,13 @@ impl InstanceState {
35
37
pub fn new (
36
38
allowed_databases : Arc < HashSet < String > > ,
37
39
get_connection_creator : ConnectionCreatorGetter ,
40
+ observe_context : ObserveContext ,
38
41
) -> Self {
39
42
Self {
40
43
allowed_databases,
41
44
connections : table:: Table :: new ( 256 ) ,
42
45
get_connection_creator,
46
+ observe_context,
43
47
}
44
48
}
45
49
@@ -66,6 +70,8 @@ impl v2::Host for InstanceState {
66
70
impl v2:: HostConnection for InstanceState {
67
71
#[ instrument( name = "spin_sqlite.open" , skip( self ) , err( level = Level :: INFO ) , fields( otel. kind = "client" , db. system = "sqlite" , sqlite. backend = Empty ) ) ]
68
72
async fn open ( & mut self , database : String ) -> Result < Resource < v2:: Connection > , v2:: Error > {
73
+ self . observe_context . reparent_tracing_span ( ) ;
74
+
69
75
if !self . allowed_databases . contains ( & database) {
70
76
return Err ( v2:: Error :: AccessDenied ) ;
71
77
}
@@ -90,6 +96,8 @@ impl v2::HostConnection for InstanceState {
90
96
query : String ,
91
97
parameters : Vec < v2:: Value > ,
92
98
) -> Result < v2:: QueryResult , v2:: Error > {
99
+ self . observe_context . reparent_tracing_span ( ) ;
100
+
93
101
let conn = match self . get_connection ( connection) {
94
102
Ok ( c) => c,
95
103
Err ( err) => return Err ( err) ,
0 commit comments