Closed ddorian closed 2 days ago
I can't reproduce it.
I've also added the FlaskInstrumentor.instrument(app)
to actually test that the traces are being sent:
import gevent.monkey
gevent.monkey.patch_all()
import logfire
logfire.configure()
# todo doing this import shows the error
import magic
from flask import Flask
from opentelemetry.instrumentation.flask import FlaskInstrumentor
app = Flask(__name__)
FlaskInstrumentor().instrument_app(app)
@app.route('/')
def hello_world():
return '<p>Hello, World!</p>'
if __name__ == '__main__':
app.run()
This is the actual packages installed retrieved from pip freeze
(I've installed the packages mentioned in the description):
Am I doing something wrong?
I created a new project with fresh installs just to be sure. What if you try this exact poetry project ? poetry_project.zip
And then do python main.py
:
❯ python main.py
Logfire project URL: https://logfire.pydantic.dev/------------
Traceback (most recent call last):
File "src/gevent/_abstract_linkable.py", line 287, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
File "src/gevent/_abstract_linkable.py", line 333, in gevent._gevent_c_abstract_linkable.AbstractLinkable._notify_links
AssertionError: (None, <callback at 0x7f622d828840 args=([],)>)
2024-05-01T09:49:40Z <callback at 0x7f622d828840 args=([],)> failed with AssertionError
* Serving Flask app 'main'
* Debug mode: off
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
I still can't reproduce it.
Are you sure you are running the virtual environment created by poetry? I had to create the logfire_test/
directory, and the __init__.py
file on your example, and I actually run the app with poetry run python main.py
.
Are you sure you are running the virtual environment created by poetry?
Yes, the IDE uses it for me.
I had to create the logfire_test/ directory,
Agree
and the init.py file on your example,
Not needed.
and I actually run the app with poetry run python main.py.
Yes. This is the full project without .idea & .logfire dirs logfire_test.zip
@Kludex maybe you need the os to be the same? (ubuntu 22.04)
I replicated in a github codespace https://github.com/ddorian/jubilant-space-potato
I could reproduce in your codespace. It seems to be a combination of gevent
+ opentelemetry
+ magic
that's the root cause. I get the same error from the following minimal repro:
import gevent.monkey
gevent.monkey.patch_all()
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExporter
processor = BatchSpanProcessor(SpanExporter(), schedule_delay_millis=500)
# todo doing this import shows the error
import magic
requirements.txt:
Deprecated==1.2.14
gevent==24.2.1
greenlet==3.0.3
importlib-metadata==7.0.0
opentelemetry-api==1.24.0
opentelemetry-sdk==1.24.0
opentelemetry-semantic-conventions==0.45b0
python-magic==0.4.27
typing_extensions==4.11.0
wrapt==1.16.0
zipp==3.18.1
zope.event==5.0
zope.interface==6.3
I can also reproduce locally with the same example (Ubuntu 24.04, Python 3.12.3)
Reported upstream at https://github.com/open-telemetry/opentelemetry-python/issues/3897
I'm also facing the same issue with Fastapi. Any quick fix?
I'm also facing the same issue with Fastapi. Any quick fix?
It shouldn't affect FastAPI... 🤔
Since this issue is on OTel side, I'll be closing it here.
If interested, you can watch this: https://github.com/open-telemetry/opentelemetry-python/issues/3897.
Description
The error below happens only when using the combination of gevent, logfire, and importing magic.
Full code:
Python, Logfire & OS Versions, related packages