File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
instrumentation/opentelemetry-instrumentation-sqlalchemy/tests Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -227,3 +227,30 @@ async def run():
227227 )
228228
229229 asyncio .get_event_loop ().run_until_complete (run ())
230+
231+ def test_uninstrument (self ):
232+ engine = create_engine ("sqlite:///:memory:" )
233+ SQLAlchemyInstrumentor ().instrument (
234+ engine = engine ,
235+ tracer_provider = self .tracer_provider ,
236+ )
237+ cnx = engine .connect ()
238+ cnx .execute ("SELECT 1 + 1;" ).fetchall ()
239+ spans = self .memory_exporter .get_finished_spans ()
240+
241+ self .assertEqual (len (spans ), 2 )
242+ # first span - the connection to the db
243+ self .assertEqual (spans [0 ].name , "connect" )
244+ self .assertEqual (spans [0 ].kind , trace .SpanKind .CLIENT )
245+ # second span - the query itself
246+ self .assertEqual (spans [1 ].name , "SELECT :memory:" )
247+ self .assertEqual (spans [1 ].kind , trace .SpanKind .CLIENT )
248+
249+ SQLAlchemyInstrumentor ().uninstrument ()
250+ engine2 = create_engine ("sqlite:///:memory:" )
251+ cnx2 = engine2 .connect ()
252+ cnx2 .execute ("SELECT 2 + 2;" ).fetchall ()
253+ spans = self .memory_exporter .get_finished_spans ()
254+ self .assertEqual (len (spans ), 2 )
255+
256+
You can’t perform that action at this time.
0 commit comments