mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-07-29 15:23:51 +00:00
small update which adds a METRIC type
This commit is contained in:
parent
6ccb0a4c1f
commit
f294875396
1 changed files with 16 additions and 2 deletions
|
@ -40,9 +40,15 @@ class Trace(BaseModel):
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class EventType(Enum):
|
class EventType(Enum):
|
||||||
LOG = "log"
|
UNSTRUCTURED_LOG = "unstructured_log"
|
||||||
|
|
||||||
|
# all structured log events below
|
||||||
SPAN_START = "span_start"
|
SPAN_START = "span_start"
|
||||||
SPAN_END = "span_end"
|
SPAN_END = "span_end"
|
||||||
|
METRIC = "metric"
|
||||||
|
|
||||||
|
def is_structured(self) -> bool:
|
||||||
|
return self != EventType.UNSTRUCTURED_LOG
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
|
@ -64,7 +70,7 @@ class EventCommon(BaseModel):
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class LoggingEvent(EventCommon):
|
class LoggingEvent(EventCommon):
|
||||||
type: Literal[EventType.LOG.value] = EventType.LOG.value
|
type: Literal[EventType.UNSTRUCTURED_LOG.value] = EventType.UNSTRUCTURED_LOG.value
|
||||||
message: str
|
message: str
|
||||||
severity: LogSeverity
|
severity: LogSeverity
|
||||||
|
|
||||||
|
@ -82,6 +88,14 @@ class SpanEndEvent(EventCommon):
|
||||||
status: SpanStatus
|
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[
|
Event = Annotated[
|
||||||
Union[LoggingEvent, SpanStartEvent, SpanEndEvent],
|
Union[LoggingEvent, SpanStartEvent, SpanEndEvent],
|
||||||
Field(discriminator="type"),
|
Field(discriminator="type"),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue