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 import jaeger
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor


_JAEGER_EXPORTER = jaeger.JaegerSpanExporter(
   service_name="example-xxx",
   agent_host_name="localhost",
   agent_port=6831,
)

_TRACE_PROVIDER = TracerProvider()
_TRACE_PROVIDER.add_span_processor(BatchExportSpanProcessor(_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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file opentelemetry_instrumentation_aiohttp_client-0.18b1-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_aiohttp_client-0.18b1-py3-none-any.whl
Algorithm Hash digest
SHA256 074209f50d8561fd51836e7c8160cdc3f908dabe444d261629f77dca27629ded
MD5 67752d9f152c89aa52bdda16d5fdfd85
BLAKE2b-256 073fceb650562dfa301366823c2ea5a37521a665d45019c6ca2d0e4b73b68329

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