@@ -27,6 +27,12 @@ Features:
2727 - Integrations with [ FastAPI] ( https://fastapi.tiangolo.com ) and [ Starlette] ( https://www.starlette.io )
2828 - Logging support for [ Uvicorn] ( https://www.uvicorn.org ) and [ Gunicorn] ( https://gunicorn.org ) with custom ** UvicornWorker**
2929
30+ > ** Info**
31+ >
32+ > At this stage, the library is being tested and be careful in using it,
33+ > your participation in the development will be appreciated!
34+
35+
3036### Installation
3137
3238``` shell
@@ -89,7 +95,37 @@ See the `prometheus_client` [documentation](https://prometheus.github.io/client_
8995
9096You can also add query tracing and your logic using ` opentelemetry ` .
9197
92- Create your ** TracerProvider** with the necessary settings and add it to the ** TracingConfig** .
98+ ``` python
99+ from asgi_monitor.integrations.fastapi import TracingConfig, setup_tracing
100+ from opentelemetry import trace
101+ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
102+ from opentelemetry.sdk.resources import Resource
103+ from opentelemetry.sdk.trace import TracerProvider
104+ from opentelemetry.sdk.trace.export import BatchSpanProcessor
105+
106+ resource = Resource.create(
107+ attributes = {
108+ " service.name" : " asgi-monitor" ,
109+ " compose_service" : " asgi-monitor" ,
110+ },
111+ )
112+ tracer = TracerProvider(resource = resource)
113+ trace.set_tracer_provider(tracer)
114+ tracer.add_span_processor(BatchSpanProcessor(OTLPSpanExporter(endpoint = " http://asgi-monitor.tempo:4317" )))
115+ config = TracingConfig(tracer_provider = tracer)
116+
117+ setup_tracing(app = app, config = config)
118+ ```
119+
120+ Create your ** TracerProvider** with the necessary settings and add it to the ** TracingConfig** ,
121+ also include tracing in others setup functions.
122+
123+ After that, you can profile the payload of the application.
124+
125+ ``` python
126+ with trace.get_tracer(" asgi-monitor" ).start_as_current_span(" sleep 0.1" ):
127+ await asyncio.sleep(0.1 )
128+ ```
93129
94130See [ example] ( https://github.com/draincoder/asgi-monitor/blob/develop/examples/real_world/app/main.py )
95131to understand the tracing setup.\
@@ -106,3 +142,5 @@ carefully study them and customize them to your needs.
106142>
107143> Do not use these configs in production, as authorization and long-term data storage are not configured there!
108144>
145+
146+ The library originates from [ structlog-asgi] ( https://github.com/nkhitrov/structlog-asgi ) , tnx @nkhitrov
0 commit comments