Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions backend/src/core/api/routes/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# LeastAction Sustainable Use License (see LICENSE.md) or, for files
# marked EE, the LeastAction Enterprise Edition License (see LICENSE_EE.md).
# Use of this file outside those terms is not permitted.
import asyncio
import json
import traceback
from collections.abc import AsyncGenerator
Expand All @@ -17,7 +16,12 @@
from src.common.config import Config
from src.common.context_vars.user_context import get_user_laui
from src.common.logger.logger import log_error, log_info
from src.core.logs_details.service import LogsService, get_logs_service
from src.core.logs_details.service import (
LOG_QUERY_TIMEOUT,
LogsService,
get_logs_service,
run_log_op,
)

logs_router = APIRouter()

Expand Down Expand Up @@ -94,10 +98,16 @@ async def query_logs(request: LogQueryRequest) -> dict:
log_info(
"api", "logs_router", "query_logs", f"user={get_user_laui()} payload={request.model_dump()}"
)
loop = asyncio.get_event_loop()
return await loop.run_in_executor(
None, _run_duckdb_query, request.sql, request.category, request.date
)
try:
return await run_log_op(
_run_duckdb_query,
request.sql,
request.category,
request.date,
timeout=LOG_QUERY_TIMEOUT,
)
except TimeoutError as exc:
return {"error": str(exc)}


def _sse(event: str, data: Any) -> str:
Expand Down
Loading
Loading