mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-27 06:28:50 +00:00
fix: make telemetry more resilient to missing data
it seems sometimes `row` is missing some data like `root_span_id`, omit these entries and log a warning Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
fe6af7dc8b
commit
0360e0d941
1 changed files with 18 additions and 9 deletions
|
@ -11,6 +11,9 @@ from typing import Protocol
|
||||||
import aiosqlite
|
import aiosqlite
|
||||||
|
|
||||||
from llama_stack.apis.telemetry import QueryCondition, Span, SpanWithStatus, Trace
|
from llama_stack.apis.telemetry import QueryCondition, Span, SpanWithStatus, Trace
|
||||||
|
from llama_stack.log import get_logger
|
||||||
|
|
||||||
|
logger = get_logger(__name__, category="core")
|
||||||
|
|
||||||
|
|
||||||
class TraceStore(Protocol):
|
class TraceStore(Protocol):
|
||||||
|
@ -99,15 +102,21 @@ class SQLiteTraceStore(TraceStore):
|
||||||
conn.row_factory = aiosqlite.Row
|
conn.row_factory = aiosqlite.Row
|
||||||
async with conn.execute(query, params) as cursor:
|
async with conn.execute(query, params) as cursor:
|
||||||
rows = await cursor.fetchall()
|
rows = await cursor.fetchall()
|
||||||
return [
|
results = []
|
||||||
|
for row in rows:
|
||||||
|
try:
|
||||||
|
results.append(
|
||||||
Trace(
|
Trace(
|
||||||
trace_id=row["trace_id"],
|
trace_id=row["trace_id"],
|
||||||
root_span_id=row["root_span_id"],
|
root_span_id=row["root_span_id"],
|
||||||
start_time=datetime.fromisoformat(row["start_time"]),
|
start_time=datetime.fromisoformat(row["start_time"]),
|
||||||
end_time=datetime.fromisoformat(row["end_time"]),
|
end_time=datetime.fromisoformat(row["end_time"]),
|
||||||
)
|
)
|
||||||
for row in rows
|
)
|
||||||
]
|
except (KeyError, TypeError, ValueError) as e:
|
||||||
|
logger.warning(f"Could not construct Trace due to missing information in row: {e}")
|
||||||
|
continue
|
||||||
|
return results
|
||||||
|
|
||||||
async def get_span_tree(
|
async def get_span_tree(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue