You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling FastAPIInstrumentor.uninstrument_app() doesn't remove the app parameter from the _InstrumentedFastAPI._instrumented_fastapi_apps set. If instrumenting and uninstrumenting is done repeatedly, for example in a test suite, this can lead to leaking significant amount of memory.
Steps to Reproduce
import sys
from fastapi import FastAPI
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
app = FastAPI()
print(sys.getrefcount(app))
FastAPIInstrumentor.instrument_app(app)
print(sys.getrefcount(app))
FastAPIInstrumentor.uninstrument_app(app)
print(sys.getrefcount(app))
Expected Result
After the call to uninstrument_app() the refcount should be the same as it was before calling instrument_app()
Actual Result
The refcount is one greater.
Additional context
The mechanism of storing references to the apps was implemented in #1258.
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered:
Describe your environment
OS: Ubuntu 22.04
Python version: Python 3.11.11
Package version: 0.45b0
What happened?
Calling
FastAPIInstrumentor.uninstrument_app()
doesn't remove theapp
parameter from the_InstrumentedFastAPI._instrumented_fastapi_apps
set. If instrumenting and uninstrumenting is done repeatedly, for example in a test suite, this can lead to leaking significant amount of memory.Steps to Reproduce
Expected Result
After the call to
uninstrument_app()
the refcount should be the same as it was before callinginstrument_app()
Actual Result
The refcount is one greater.
Additional context
The mechanism of storing references to the apps was implemented in #1258.
Would you like to implement a fix?
Yes
The text was updated successfully, but these errors were encountered: