mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-07-30 21:56:07 +08:00
Remove references to disposed SQLAlchemy engines from instrumentation singleton (#3053)
* Remove references to SQLAlchemy engines which are disposed of EngineTracer in SQLAlchemy keeps weak references to a traced engine forever which can cause a noticeable memory leak if engines are constantly getting creating. * Updated changelog --------- Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com> Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
This commit is contained in:
@ -417,6 +417,10 @@ class TestSqlalchemyInstrumentation(TestBase):
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
|
||||
from opentelemetry.instrumentation.sqlalchemy.engine import (
|
||||
EngineTracer,
|
||||
)
|
||||
|
||||
callback = mock.Mock()
|
||||
|
||||
def make_shortlived_engine():
|
||||
@ -432,3 +436,4 @@ class TestSqlalchemyInstrumentation(TestBase):
|
||||
|
||||
gc.collect()
|
||||
assert callback.call_count == 5
|
||||
assert len(EngineTracer._remove_event_listener_params) == 0
|
||||
|
Reference in New Issue
Block a user