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.23b2.tar.gz.

File metadata

File hashes

Hashes for opentelemetry-instrumentation-aiohttp-client-0.23b2.tar.gz
Algorithm Hash digest
SHA256 426ab895966c9cdc9ebf3760e60bbcf6ee8d0edd4f8539d718a02d2e705cad1f
MD5 526a586f47a55713d42c5bb988ff6928
BLAKE2b-256 0d2d9ed8eb6879f2993afaa0a3eee57ebb725a7c85cbff5438ec75705bd324f3

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation_aiohttp_client-0.23b2-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_aiohttp_client-0.23b2-py3-none-any.whl
Algorithm Hash digest
SHA256 4dc704730edd81279896a0bc5f4d05c0a877f589b961e0b85c2ba48d0b0f8fc8
MD5 902eb72ee9e4ed1a3ae4c99bf2d462ab
BLAKE2b-256 f0b3368ff13c2536d78662ef94ae57e34c987bbcc0d4bc47e19b56b5816bdafc

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