OpenTelemetry aiohttp server Integration
This library allows tracing HTTP requests made by the aiohttp server library.
Installation
pip install opentelemetry-instrumentation-aiohttp-server
- opentelemetry.instrumentation.aiohttp_server.get_default_span_details(request)[source]
Default implementation for get_default_span_details :type request:
Request
:param request: the request object itself.
- opentelemetry.instrumentation.aiohttp_server.collect_request_attributes(request)[source]
Collects HTTP request attributes from the ASGI scope and returns a dictionary to be used as span creation attributes.
- Return type:
- opentelemetry.instrumentation.aiohttp_server.set_status_code(span, status_code)[source]
Adds HTTP response attributes to span using the status_code argument.
- Return type:
- class opentelemetry.instrumentation.aiohttp_server.AiohttpGetter[source]
Bases:
Getter
Extract current trace from headers
- async opentelemetry.instrumentation.aiohttp_server.middleware(request, handler)[source]
Middleware for aiohttp implementing tracing logic
- class opentelemetry.instrumentation.aiohttp_server.AioHttpServerInstrumentor(*args, **kwargs)[source]
Bases:
BaseInstrumentor
An instrumentor for aiohttp.web.Application
See BaseInstrumentor
- instrumentation_dependencies()[source]
Return a list of python packages with versions that the will be instrumented.
The format should be the same as used in requirements.txt or pyproject.toml.
For example, if an instrumentation instruments requests 1.x, this method should look like:
- def instrumentation_dependencies(self) -> Collection[str]:
return [‘requests ~= 1.0’]
This will ensure that the instrumentation will only be used when the specified library is present in the environment.