Skip to main content

OpenTelemetry aiohttp client instrumentation

Project description

pypi

This library allows tracing HTTP requests made by the aiohttp client library.

Installation

pip install opentelemetry-instrumentation-aiohttp-client

Example

import asyncio

import aiohttp

from opentelemetry.instrumentation.aiohttp_client import AioHttpClientInstrumentor
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor


_JAEGER_EXPORTER = JaegerExporter(
   service_name="example-xxx",
   agent_host_name="localhost",
   agent_port=6831,
)

_TRACE_PROVIDER = TracerProvider()
_TRACE_PROVIDER.add_span_processor(BatchSpanProcessor(_JAEGER_EXPORTER))
trace.set_tracer_provider(_TRACE_PROVIDER)

AioHttpClientInstrumentor().instrument()


async def span_emitter():
   async with aiohttp.ClientSession() as session:
      async with session.get("https://example.com") as resp:
            print(resp.status)


asyncio.run(span_emitter())

References

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file opentelemetry-instrumentation-aiohttp-client-0.20b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry-instrumentation-aiohttp-client-0.20b0.tar.gz
Algorithm Hash digest
SHA256 0c0cd0ea752777326241b69d84b90b319014b58c6b0cf1403fcf0369d0353a13
MD5 90775d6ba55f217c6055b872cff7053f
BLAKE2b-256 e5d9124755969a87942bcdc80626033e2889590b841cbbe330e901ddc838b9d7

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation_aiohttp_client-0.20b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_aiohttp_client-0.20b0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff10cc91c2259df96d2c54bba71149887e44fc64322025bbd9791fb5fec6b8bc
MD5 b678e4b98c4eef8c1795ea6512cef20b
BLAKE2b-256 36fd1f12ec19ec4cf485df75839c1b67b9eaeaf560a0f36afcc47caa2a71a6b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page