Buckets:

download
raw
1.12 kB
import importlib
from unittest import mock
import asyncpg
import pytest
from inline_snapshot import snapshot
from opentelemetry.instrumentation.asyncpg import AsyncPGInstrumentor
import logfire
import logfire._internal.integrations.asyncpg
def test_asyncpg() -> None:
original_execute = asyncpg.Connection.execute # type: ignore[reportUnknownMemberType]
logfire.instrument_asyncpg()
assert original_execute is not asyncpg.Connection.execute # type: ignore[reportUnknownMemberType]
AsyncPGInstrumentor().uninstrument()
assert original_execute is asyncpg.Connection.execute # type: ignore[reportUnknownMemberType]
def test_missing_opentelemetry_dependency() -> None:
with mock.patch.dict('sys.modules', {'opentelemetry.instrumentation.asyncpg': None}):
with pytest.raises(RuntimeError) as exc_info:
importlib.reload(logfire._internal.integrations.asyncpg)
assert str(exc_info.value) == snapshot("""\
`logfire.instrument_asyncpg()` requires the `opentelemetry-instrumentation-asyncpg` package.
You can install this with:
pip install 'logfire[asyncpg]'\
""")

Xet Storage Details

Size:
1.12 kB
·
Xet hash:
9a5b76afcc17630040d7bb32d7b78f5ecb1029dbb1f2865e14d0de48ba6df2c5

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.