diff --git a/aidial_assistant/app.py b/aidial_assistant/app.py index f91e628..d32e99a 100644 --- a/aidial_assistant/app.py +++ b/aidial_assistant/app.py @@ -15,11 +15,15 @@ tools_supporting_deployments: set[str] = set( os.getenv("TOOLS_SUPPORTING_DEPLOYMENTS", "").split(",") ) +otel_logging_enabled: bool = True -logging.config.dictConfig(get_log_config(log_level)) + +logging.config.dictConfig(get_log_config(log_level, otel_logging_enabled)) telemetry_config = TelemetryConfig( - tracing=TracingConfig(otlp_export=otlp_export_enabled, logging=True), + tracing=TracingConfig( + otlp_export=otlp_export_enabled, logging=otel_logging_enabled + ), ) app = DIALApp(telemetry_config=telemetry_config) diff --git a/aidial_assistant/utils/log_config.py b/aidial_assistant/utils/log_config.py index fbe23bc..f6660b7 100644 --- a/aidial_assistant/utils/log_config.py +++ b/aidial_assistant/utils/log_config.py @@ -1,11 +1,16 @@ -def get_log_config(log_level: str) -> dict: +def get_log_config(log_level: str, otel_logging: bool) -> dict: + otel_prefix_fmt = ( + "[trace_id=%(otelTraceID)s span_id=%(otelSpanID)s] - " + if otel_logging + else "" + ) return { "version": 1, "disable_existing_loggers": False, "formatters": { "default": { "()": "uvicorn.logging.DefaultFormatter", - "fmt": "%(levelprefix)s | %(asctime)s | %(name)s | %(process)d | %(message)s", + "fmt": f"%(levelprefix)s | %(asctime)s | %(name)s | %(process)d | {otel_prefix_fmt}%(message)s", "datefmt": "%Y-%m-%d %H:%M:%S", "use_colors": True, },