mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-05 04:17:32 +00:00
move span events one level down into structured log events
This commit is contained in:
parent
99af14b18c
commit
e8c2f068a3
3 changed files with 65 additions and 52 deletions
|
@ -41,15 +41,9 @@ class Trace(BaseModel):
|
|||
@json_schema_type
|
||||
class EventType(Enum):
|
||||
UNSTRUCTURED_LOG = "unstructured_log"
|
||||
|
||||
# all structured log events below
|
||||
SPAN_START = "span_start"
|
||||
SPAN_END = "span_end"
|
||||
STRUCTURED_LOG = "structured_log"
|
||||
METRIC = "metric"
|
||||
|
||||
def is_structured(self) -> bool:
|
||||
return self != EventType.UNSTRUCTURED_LOG
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class LogSeverity(Enum):
|
||||
|
@ -69,25 +63,12 @@ class EventCommon(BaseModel):
|
|||
|
||||
|
||||
@json_schema_type
|
||||
class LoggingEvent(EventCommon):
|
||||
class UnstructuredLogEvent(EventCommon):
|
||||
type: Literal[EventType.UNSTRUCTURED_LOG.value] = EventType.UNSTRUCTURED_LOG.value
|
||||
message: str
|
||||
severity: LogSeverity
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class SpanStartEvent(EventCommon):
|
||||
type: Literal[EventType.SPAN_START.value] = EventType.SPAN_START.value
|
||||
name: str
|
||||
parent_span_id: Optional[str] = None
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class SpanEndEvent(EventCommon):
|
||||
type: Literal[EventType.SPAN_END.value] = EventType.SPAN_END.value
|
||||
status: SpanStatus
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class MetricEvent(EventCommon):
|
||||
type: Literal[EventType.METRIC.value] = EventType.METRIC.value
|
||||
|
@ -96,8 +77,48 @@ class MetricEvent(EventCommon):
|
|||
unit: str
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class StructuredLogType(Enum):
|
||||
SPAN_START = "span_start"
|
||||
SPAN_END = "span_end"
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class SpanStartPayload(BaseModel):
|
||||
type: Literal[StructuredLogType.SPAN_START.value] = (
|
||||
StructuredLogType.SPAN_START.value
|
||||
)
|
||||
name: str
|
||||
parent_span_id: Optional[str] = None
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class SpanEndPayload(BaseModel):
|
||||
type: Literal[StructuredLogType.SPAN_END.value] = StructuredLogType.SPAN_END.value
|
||||
status: SpanStatus
|
||||
|
||||
|
||||
StructuredLogPayload = Annotated[
|
||||
Union[
|
||||
SpanStartPayload,
|
||||
SpanEndPayload,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
||||
@json_schema_type
|
||||
class StructuredLogEvent(EventCommon):
|
||||
type: Literal[EventType.STRUCTURED_LOG.value] = EventType.STRUCTURED_LOG.value
|
||||
payload: StructuredLogPayload
|
||||
|
||||
|
||||
Event = Annotated[
|
||||
Union[LoggingEvent, SpanStartEvent, SpanEndEvent],
|
||||
Union[
|
||||
UnstructuredLogEvent,
|
||||
MetricEvent,
|
||||
StructuredLogEvent,
|
||||
],
|
||||
Field(discriminator="type"),
|
||||
]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue