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.19b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry-instrumentation-aiohttp-client-0.19b0.tar.gz
Algorithm Hash digest
SHA256 8738b6ada030247893800516c43e815994ec3291488331e82ccbc7d00e0ca9fe
MD5 aeffcf97f50be721bf3b1d07de673390
BLAKE2b-256 10a745d7d93cdf054966eb72a1b9ade907e15d115e57c1202e07721e2579209b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_instrumentation_aiohttp_client-0.19b0-py3-none-any.whl
Algorithm Hash digest
SHA256 901a255c16e1ccdb92090956f0a929b239101851a2e16ea2c0fc7547b7969de6
MD5 639c9f746fa0a4dcca6e5e0fe4230aab
BLAKE2b-256 c31eac8f7d13ce8a4917a07d7f9f1d2ad3184208a8d16b206d0784272bca89e0

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