Opentracing support for Starlette and FastApi

Overview

Starlette-OpenTracing

Build info PyPi info PyPI pyversions Maintenance yes Coverage status

OpenTracing support for Starlette and FastApi. Inspired by: Flask-OpenTracing OpenTracing implementations exist for major distributed tracing systems and can be bound or swapped with a one-line configuration change. This package uses the OpenTracing API for Python to implement it's functionality.

The package will implement: Starlette middleware that can be used to add Opentracing support to all incoming requests. It also supports the usage of a customer root span by looking at extra headers for incoming request:

Screenshot

This work was funded by SURFnet.

Installation

Run the following command:

$ pip install Starlette-Opentracing

Usage

See the examples for FastAPI and Starlette in examples/

Deploy

Increase version in VERSION

git commit -a -m "bumped version to 0.0.3"
git tag -a v0.0.3 -m "version 0.0.3"
git push --follow-tags

License info

Copyright 2020 R. Dohmen <[email protected]>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You might also like...
Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

Starlette middleware for Prerender

Prerender Python Starlette Starlette middleware for Prerender Documentation: https://BeeMyDesk.github.io/prerender-python-starlette/ Source Code: http

Prometheus integration for Starlette.

Starlette Prometheus Introduction Prometheus integration for Starlette. Requirements Python 3.6+ Starlette 0.9+ Installation $ pip install starlette-p

FastAPI-Amis-Admin is a high-performance, efficient and easily extensible FastAPI admin framework. Inspired by django-admin, and has as many powerful functions as django-admin.
FastAPI-Amis-Admin is a high-performance, efficient and easily extensible FastAPI admin framework. Inspired by django-admin, and has as many powerful functions as django-admin.

简体中文 | English 项目介绍 FastAPI-Amis-Admin fastapi-amis-admin是一个拥有高性能,高效率,易拓展的fastapi管理后台框架. 启发自Django-Admin,并且拥有不逊色于Django-Admin的强大功能. 源码 · 在线演示 · 文档 · 文

fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability
fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability

FastAPI2 Admin Introduction fastapi-admin2 is an upgraded fastapi-admin, that supports ORM dialects, true Dependency Injection and extendability. Now

Stac-fastapi built on Tile38 and Redis to support caching

stac-fastapi-caching Stac-fastapi built on Tile38 to support caching. This code is built on top of stac-fastapi-elasticsearch 0.1.0 with pyle38, a Pyt

:rocket: CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.
:rocket: CLI tool for FastAPI. Generating new FastAPI projects & boilerplates made easy.

Project generator and manager for FastAPI. Source Code: View it on Github Features 🚀 Creates customizable project boilerplate. Creates customizable a

Simple FastAPI Example : Blog API using FastAPI : Beginner Friendly

fastapi_blog FastAPI : Simple Blog API with CRUD operation Steps to run the project: git clone https://github.com/mrAvi07/fastapi_blog.git cd fastapi-

Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI

FastAPI Ariadne Example Пример использования GraphQL Ariadne с FastAPI и сравнение его с GraphQL Graphene FastAPI - GitHub ###Запуск на локальном окру

Comments
  • Adds option to use path templates for span operation name

    Adds option to use path templates for span operation name

    When tracing endpoint that have a path parameter, especially when the path parameter is a unique id for a resource, the number of operations when viewing traces becomes very large. Using the path templates sets a finite limit of possible operation names.

    opened by hkethi002 3
  • Update requirements.txt

    Update requirements.txt

    Inside your Fast API Example ( example/fastapi/requirements.txt ) , you have:

    fastapi
    jaeger-client
    opentracing_instrumentation
    requests
    -e git://github.com/acidjunk/starlette-opentracing.git#egg=Starlette-OpenTracing
    tornado==5.1.1  # pin to last release for 5, implicit install of 6 gives errors
    uvicorn
    

    This was made 9 months ago, and didn't was released Python 3.9, however, I think that Tornado version is not a problem now with python 3.9

    I tried this example, and my requirements.txt are:

    fastapi==0.63.0
    uvicorn==0.13.3
    requests==2.25.1
    
    jaeger-client==4.3.0
    opentracing-instrumentation==3.3.1
    Starlette-OpenTracing==0.1.0
    

    With Python 3.8 I got this error:

    Traceback (most recent call last):  File "app.py", line 11, in <module>    from opentracing_instrumentation.client_hooks import install_all_patches  File "/usr/local/lib/python3.8/site-packages/opentracing_instrumentation/__init__.py", line 21, in <module>    from .request_context import get_current_span  # noqa  File "/usr/local/lib/python3.8/site-packages/opentracing_instrumentation/request_context.py", line 26, in <module>    from opentracing.scope_managers.tornado import TornadoScopeManager  File "/usr/local/lib/python3.8/site-packages/opentracing/scope_managers/tornado.py", line 24, in <module>    import tornado.stack_contextModuleNotFoundError: No module named 'tornado.stack_context'
    

    However with Python 3.9.1 works perfectly :)

    I think you can update your requirements in your example.

    opened by ruimartinsptl 3
  • Not working when i am trying to send the traces to tempo.

    Not working when i am trying to send the traces to tempo.

    I am trying to send traces to tempo and it is not working. The traces do work on jaeger.

    my opentracing config looks like this Config( config={ "sampler": {"type": "const", "param": 1}, "logging": False, "local_agent": {"reporting_host": "localhost"}, }, scope_manager=ContextVarsScopeManager(), service_name="Test App", )

    opened by swapnil-raj 0
  • Test is subclassing BaseHTTPMiddleware

    Test is subclassing BaseHTTPMiddleware

    The current middleware subclasses BaseHTTPMiddleware which per encode/starlette#919 and tiangolo/fastapi#2086 will cause all background tasks to run before the response is sent.

    opened by acidjunk 0
Owner
Rene Dohmen
Freelance python developer
Rene Dohmen
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 225 Jan 5, 2023
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 562 Jan 1, 2023
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 154 Feb 16, 2021
Prometheus exporter for Starlette and FastAPI

starlette_exporter Prometheus exporter for Starlette and FastAPI. The middleware collects basic metrics: Counter: starlette_requests_total Histogram:

Steve Hillier 82 Feb 13, 2021
SQLAlchemy Admin for Starlette/FastAPI

SQLAlchemy Admin for Starlette/FastAPI SQLAdmin is a flexible Admin interface for SQLAlchemy models. Main features include: SQLAlchemy sync/async engi

Amin Alaee 683 Jan 3, 2023
FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management

FastAPI Server-sided Session FastAPI Server Session is a dependency-based extension for FastAPI that adds support for server-sided session management.

DevGuyAhnaf 5 Dec 23, 2022
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 300 Dec 26, 2022
Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automatically use request headers such as x-request-id or x-correlation-id.

starlette context Middleware for Starlette that allows you to store and access the context data of a request. Can be used with logging so logs automat

Tomasz Wójcik 110 Feb 16, 2021
Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡

csrf-starlette-fastapi Dead simple CSRF security middleware for Starlette ⭐ and Fast API ⚡ Will work with either a <input type="hidden"> field or ajax

Nathaniel Sabanski 9 Nov 20, 2022
Starlette middleware for Prerender

Prerender Python Starlette Starlette middleware for Prerender Documentation: https://BeeMyDesk.github.io/prerender-python-starlette/ Source Code: http

BeeMyDesk 14 May 2, 2021