Skip to content

Instantly share code, notes, and snippets.

@jsmolina
Created November 12, 2021 12:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmolina/b116e3858469e7bfaa89e4e05c8c23cc to your computer and use it in GitHub Desktop.
Save jsmolina/b116e3858469e7bfaa89e4e05c8c23cc to your computer and use it in GitHub Desktop.
simple w3c tracecontext plugin for traceapi
from plugin import TraceParentLogger
def create_app():
config = get_api_settings()
app = FastAPI...
....
app.add_middleware(RawContextMiddleware, plugins=(TraceParentLogger(),)
from starlette_context.plugins.base import Plugin
class TraceParentLogger(Plugin):
key = "traceparent"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment