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
from opentelemetry import trace
from opentelemetry.exporter import zipkin
from opentelemetry.instrumentation.flask import FlaskInstrumentor
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor
from opentelemetry.instrumentation.aiohttp_client import create_trace_config
from opentelemetry.instrumentation.aiopg import AiopgInstrumentor
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
loop = asyncio.get_event_loop()
app = flask.Flask("python-web-perf")
# opentelemetry
trace.set_tracer_provider(TracerProvider())
zipkin_exporter = zipkin.ZipkinSpanExporter(
service_name="app_asyncio_flask",
url=f'http://{zipkin_host}:9411/api/v2/spans',
)
trace.get_tracer_provider().add_span_processor(
BatchExportSpanProcessor(zipkin_exporter)
)
app = flask.Flask(__name__)
FlaskInstrumentor().instrument_app(app)
AiopgInstrumentor().instrument()
What is the expected behavior?
I expect the postgresql span to be available in zipkin.
What is the actual behavior?
The aiopg.connect call fail with the following exception.
Traceback (most recent call last):
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/tpocreau/.venv/web-perf/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/tpocreau/wk/python-web-perf/src/app_asyncio_flask.py", line 76, in test
fetch(feature_store_url),
File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
File "/home/tpocreau/wk/python-web-perf/src/async_db.py", line 11, in get_row
async with aiopg.connect(database='test', user='test', password='test', host=pg_host) as conn:
AttributeError: __aexit__
Without the AiopgInstrumentor().instrument() line, the application is running as expected.
Additional context
I replaced aiopg by asyncpg, and everything is working as expected (span is available in zipkin).
async def get_row_asyncpg():
conn = await asyncpg.connect(user='test', password='test',
database='test', host=pg_host)
index = random.randint(1, max_n)
values = await conn.execute(
f'select pg_sleep({delay}); select a, b from test where a = {index}'
)
await conn.close()
return values
The text was updated successfully, but these errors were encountered:
Describe your environment
Ubuntu, python 3.6, aiopg 1.0.0, opentelemetry 0.16b1
Steps to reproduce
On a working flask application using aiopg like here to https://github.com/miguelgrinberg/python-web-perf/blob/master/src/async_db.py
What is the expected behavior?
I expect the postgresql span to be available in zipkin.
What is the actual behavior?
The
aiopg.connect
call fail with the following exception.Without the
AiopgInstrumentor().instrument()
line, the application is running as expected.Additional context
I replaced aiopg by asyncpg, and everything is working as expected (span is available in zipkin).
The text was updated successfully, but these errors were encountered: