You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@
22
22
-[Prometheus](https://prometheus.io) metrics
23
23
-[OpenTelemetry](https://opentelemetry.io) traces
24
24
-[Structlog](https://www.structlog.org/) logging with native **logging** module support
25
-
- Integrations with [Litestar](https://litestar.dev), [FastAPI](https://fastapi.tiangolo.com) and [Starlette](https://www.starlette.io)
25
+
- Integrations with [Litestar](https://litestar.dev), [FastAPI](https://fastapi.tiangolo.com), [Starlette](https://www.starlette.io) and [Aiohttp](https://docs.aiohttp.org/en/stable/web.html)
26
26
- Logging support for [Uvicorn](https://www.uvicorn.org) and [Gunicorn](https://gunicorn.org) with custom **UvicornWorker**
@@ -141,3 +142,64 @@ If you want to use **StructlogPlugin** from ``litestar.plugins.structlog`` toget
141
142
:caption: Import processor for extract trace meta
142
143
143
144
from asgi_monitor.logging.trace_processor import extract_opentelemetry_trace_meta
145
+
146
+
147
+
Aiohttp
148
+
====================
149
+
150
+
Despite the fact that **Aiohttp** does **not support** the **ASGI**-interface, but it is still a popular asynchronous framework and we are happy to support it.
151
+
152
+
.. code-block:: python
153
+
:caption: Configuring monitoring for the Aiohttp
154
+
155
+
import logging
156
+
157
+
from aiohttp.web import Application, run_app
158
+
from asgi_monitor.integrations.aiohttp import MetricsConfig, TracingConfig, setup_metrics, setup_tracing
159
+
from asgi_monitor.logging import configure_logging
160
+
from asgi_monitor.logging.aiohttp import TraceAccessLogger
161
+
from opentelemetry import trace
162
+
from opentelemetry.sdk.resources import Resource
163
+
from opentelemetry.sdk.trace import TracerProvider
``TraceAccessLogger`` add trace meta info in aiohttp request log.
197
+
198
+
199
+
**Aiohttp** tracing isnot**based** on an ``opentelemetry-asgi``, so the ``TracingConfig`` looks like this:
200
+
201
+
1. ``scope_span_details_extractor`` (**Callable[[Request], tuple[str, dict[str, Any]]]**) - Callback which should return a string and a tuple, representing the desired default span name and a dictionary withany additional span attributes to set.
202
+
203
+
2. ``meter_provider`` (**MeterProvider |None**) - Optional meter provider to use.
204
+
205
+
3. ``tracer_provider`` (**TracerProvider |None**) - Optional tracer provider to use.
Copy file name to clipboardExpand all lines: docs/monitoring/tracing.rst
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,9 +29,9 @@ Configuration
29
29
30
30
``BaseTracingConfig`` is a configuration class for the OpenTelemetry middleware, and it accepts the following arguments as input:
31
31
32
-
1. ``exclude_urls_env_key`` (**str**) - Key to use when checking whether a list of excluded urls is passed via ENV. Each integration module uses its own ``TracingConfig``, where the default value of the **metrics_prefix** corresponds to the name of the integration.
32
+
1. ``exclude_urls_env_key`` (**str**) - Key to use when checking whether a list of excluded urls is passed via ENV. Each integration module uses its own ``TracingConfig``.
33
33
34
-
2. ``scope_span_details_extractor`` (**Callable[[Any], tuple[str, dict[str, Any]]]**) - Callback which should return a string and a tuple, representing the desired default span name and a dictionary with any additional span attributes to set. Each integration module uses its own ``TracingConfig``, where the default value of the **metrics_prefix** corresponds to the name of the integration.
34
+
2. ``scope_span_details_extractor`` (**Callable[[Any], tuple[str, dict[str, Any]]]**) - Callback which should return a string and a tuple, representing the desired default span name and a dictionary with any additional span attributes to set. Each integration module uses its own ``TracingConfig``.
35
35
36
36
3. ``server_request_hook_handler`` (**Callable[[Span, dict], None] | None**) - Optional callback which is called with the server span and ASGI scope object for every incoming request.
0 commit comments