small update which adds a METRIC type

This commit is contained in:
Ashwin Bharambe 2024-09-11 12:17:04 -07:00
parent 6ccb0a4c1f
commit f294875396

View file

@ -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"),