refactor: remove second trace setup

This commit is contained in:
Jonathan Kössler 2024-06-26 18:15:51 +02:00
parent 65cc1c9aad
commit 3532f949a9

View File

@ -8,15 +8,10 @@ from fastapi import FastAPI
from pyinfra.config.loader import validate_settings
from pyinfra.config.validators import webserver_validators
from pyinfra.utils.opentelemetry import instrument_app, setup_trace
def create_webserver_thread_from_settings(app: FastAPI, settings: Dynaconf) -> threading.Thread:
validate_settings(settings, validators=webserver_validators)
if settings.tracing.enabled:
return create_webserver_thread_with_tracing(app, settings)
return create_webserver_thread(app=app, port=settings.webserver.port, host=settings.webserver.host)
@ -29,18 +24,6 @@ def create_webserver_thread(app: FastAPI, port: int, host: str) -> threading.Thr
return thread
def create_webserver_thread_with_tracing(app: FastAPI, settings: Dynaconf) -> threading.Thread:
def inner():
setup_trace(settings)
instrument_app(app)
uvicorn.run(app, port=settings.webserver.port, host=settings.webserver.host, log_level=logging.WARNING)
thread = threading.Thread(target=inner)
thread.daemon = True
return thread
HealthFunction = Callable[[], bool]