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: articles/azure-monitor/app/opencensus-python-request.md
+13-45Lines changed: 13 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,64 +121,32 @@ You can find a Flask sample application that tracks requests in the [Azure Monit
121
121
122
122
## Track FastAPI applications
123
123
124
-
OpenCensus doesn't have an extension for FastAPI. To write your own FastAPI middleware:
125
-
126
124
1. The following dependencies are required:
127
125
- [fastapi](https://pypi.org/project/fastapi/)
128
126
- [uvicorn](https://pypi.org/project/uvicorn/)
129
127
130
128
In a production setting, we recommend that you deploy [uvicorn with gunicorn](https://www.uvicorn.org/deployment/#gunicorn).
131
129
132
-
1. Add [FastAPI middleware](https://fastapi.tiangolo.com/tutorial/middleware/). Make sure that you set the span kind server: `span.span_kind = SpanKind.SERVER`.
133
-
134
-
1. Run your application. Calls made to your FastAPI application should be automatically tracked. Telemetry should be logged directly to Azure Monitor.
135
-
136
-
```python
137
-
# Opencensus imports
138
-
from opencensus.ext.azure.trace_exporter import AzureExporter
139
-
from opencensus.trace.samplers import ProbabilitySampler
140
-
from opencensus.trace.tracer import Tracer
141
-
from opencensus.trace.span import SpanKind
142
-
from opencensus.trace.attributes_helper importCOMMON_ATTRIBUTES
0 commit comments