{"library":"opentelemetry-instrumentation-aiohttp-server","title":"OpenTelemetry Aiohttp Server Instrumentation","description":"This library provides instrumentation for aiohttp servers, enabling automatic tracing of incoming HTTP requests and responses using OpenTelemetry. It's part of the `opentelemetry-python-contrib` project, currently at version `0.62b0`, and generally follows the release cadence of the broader OpenTelemetry Python Contrib repository, with frequent beta updates.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install opentelemetry-instrumentation-aiohttp-server opentelemetry-sdk aiohttp"],"cli":null},"imports":["from opentelemetry.instrumentation.aiohttp_server import AiohttpServerInstrumentor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import sys\nimport asyncio\nfrom opentelemetry import trace\nfrom opentelemetry.sdk.resources import Resource\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor\nfrom opentelemetry.instrumentation.aiohttp_server import AiohttpServerInstrumentor\nfrom aiohttp import web\n\n# 1. Configure OpenTelemetry Tracer Provider\nresource = Resource.create({\"service.name\": \"aiohttp-server-app\"})\nprovider = TracerProvider(resource=resource)\nprocessor = SimpleSpanProcessor(ConsoleSpanExporter(sys.stdout))\nprovider.add_span_processor(processor)\ntrace.set_tracer_provider(provider)\n\n# 2. Instrument the aiohttp server\nAiohttpServerInstrumentor().instrument()\n\n# 3. Define a simple aiohttp application\nasync def hello_handler(request):\n    tracer = trace.get_tracer(__name__)\n    with tracer.start_as_current_span(\"hello-endpoint-logic\"): \n        await asyncio.sleep(0.05) # Simulate some async work\n        return web.Response(text=\"Hello, OpenTelemetry aiohttp!\")\n\nasync def health_check_handler(request):\n    return web.Response(text=\"OK\")\n\napp = web.Application()\napp.router.add_get(\"/\", hello_handler)\napp.router.add_get(\"/health\", health_check_handler)\n\n# 4. Run the aiohttp server\nif __name__ == '__main__':\n    print(\"Server starting on http://localhost:8080\")\n    print(\"Try: curl http://localhost:8080\")\n    web.run_app(app, host=\"localhost\", port=8080)\n","lang":"python","description":"This quickstart demonstrates how to instrument an `aiohttp` server with OpenTelemetry. It sets up a basic `TracerProvider` that exports spans to the console, instruments the `aiohttp` framework, defines two simple routes, and then runs the server. Requests to `/` and `/health` will generate traces showing the incoming request and any custom spans within the handler logic.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"0.62b1","pypi_latest":"0.62b1","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5.1,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"33.2M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"35M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"36.4M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.9,"import_time_s":null,"mem_mb":null,"disk_size":"39M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"28.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":3.7,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"27.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4,"import_time_s":null,"mem_mb":null,"disk_size":"30M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"33.4M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"opentelemetry-instrumentation-aiohttp-server","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":6.8,"import_time_s":null,"mem_mb":null,"disk_size":"36M"}]}}