From f294875396691c5e39ea49acba95e244ccbb978b Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Wed, 11 Sep 2024 12:17:04 -0700 Subject: [PATCH] small update which adds a METRIC type --- llama_toolchain/telemetry/api/api.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/llama_toolchain/telemetry/api/api.py b/llama_toolchain/telemetry/api/api.py index afc1c2e7e..812806a8c 100644 --- a/llama_toolchain/telemetry/api/api.py +++ b/llama_toolchain/telemetry/api/api.py @@ -40,9 +40,15 @@ class Trace(BaseModel): @json_schema_type class EventType(Enum): - LOG = "log" + UNSTRUCTURED_LOG = "unstructured_log" + + # all structured log events below SPAN_START = "span_start" SPAN_END = "span_end" + METRIC = "metric" + + def is_structured(self) -> bool: + return self != EventType.UNSTRUCTURED_LOG @json_schema_type @@ -64,7 +70,7 @@ class EventCommon(BaseModel): @json_schema_type class LoggingEvent(EventCommon): - type: Literal[EventType.LOG.value] = EventType.LOG.value + type: Literal[EventType.UNSTRUCTURED_LOG.value] = EventType.UNSTRUCTURED_LOG.value message: str severity: LogSeverity @@ -82,6 +88,14 @@ class SpanEndEvent(EventCommon): status: SpanStatus +@json_schema_type +class MetricEvent(EventCommon): + type: Literal[EventType.METRIC.value] = EventType.METRIC.value + metric: str # this would be an enum + value: Union[int, float] + unit: str + + Event = Annotated[ Union[LoggingEvent, SpanStartEvent, SpanEndEvent], Field(discriminator="type"),