Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wesdu/fastapi-opentracing
fastapi opentracing middleware works on k8s
https://github.com/wesdu/fastapi-opentracing
Last synced: 28 days ago
JSON representation
fastapi opentracing middleware works on k8s
- Host: GitHub
- URL: https://github.com/wesdu/fastapi-opentracing
- Owner: wesdu
- License: mit
- Created: 2020-09-28T06:56:37.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-02-06T03:09:19.000Z (almost 2 years ago)
- Last Synced: 2024-09-29T02:22:00.573Z (about 1 month ago)
- Language: Python
- Size: 101 KB
- Stars: 23
- Watchers: 3
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-fastapi - FastAPI Opentracing - Opentracing middleware and database tracing support for FastAPI. (Third-Party Extensions / Utils)
- awesome-fastapi - FastAPI Opentracing - Opentracing middleware and database tracing support for FastAPI. (Third-Party Extensions / Utils)
README
# fastapi-opentracing
fastapi opentracing middleware works with istioinstall:
```
pip install fastapi-opentracing
```
example:```python
from fastapi import FastAPI
import uvicorn
from fastapi_opentracing import get_opentracing_span_headers
from fastapi_opentracing.middleware import OpenTracingMiddlewareapp = FastAPI()
app.add_middleware(OpenTracingMiddleware)
@app.get("/")
async def root():
carrier = await get_opentracing_span_headers()
return {'span': carrier}if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
```if your application uses tortoise-orm, you can execute the `install_all_patch`
or specify the client `mysql_client.install_patch` to patch you SQLClientexample:
```python
from fastapi import FastAPI
import uvicorn
from fastapi_opentracing import get_opentracing_span_headers
from fastapi_opentracing.middleware import OpenTracingMiddleware
from fastapi_opentracing.client_hooks.mysql_client import install_patch
from fastapi_opentracing.client_hooks import install_all_patchapp = FastAPI()
app.add_middleware(OpenTracingMiddleware)
TORTOISE_ORM = {
"connections": {"default": "mysql://root:[email protected]:3306/test"},
"apps": {
"models": {
"models": ["tests.models", "aerich.models"],
"default_connection": "default",
},
},
}
register_tortoise(
app,
config=TORTOISE_ORM,
generate_schemas=True
)install_all_patch()
@app.get("/")
async def root():
carrier = await get_opentracing_span_headers()
return {'span': carrier}if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
```Contributing and Developing
To install all dependencies, run:
```shell
python3 -m venv venv
source venv/bin/activate
make bootstrap
```Running Tests
```shell
make test
```Check the style and quality of python code
```shell
make lint
```