mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-12 13:00:39 +00:00
revert back changes to EventCommon
This commit is contained in:
parent
e9da8c558f
commit
6917f376e4
2 changed files with 10 additions and 10 deletions
|
@ -75,9 +75,9 @@ class LogSeverity(Enum):
|
||||||
|
|
||||||
|
|
||||||
class EventCommon(BaseModel):
|
class EventCommon(BaseModel):
|
||||||
trace_id: Optional[str] = None
|
trace_id: str
|
||||||
span_id: Optional[str] = None
|
span_id: str
|
||||||
timestamp: Optional[datetime] = None
|
timestamp: datetime
|
||||||
attributes: Optional[Dict[str, Primitive]] = Field(default_factory=dict)
|
attributes: Optional[Dict[str, Primitive]] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class MetricEvent(EventCommon):
|
||||||
type: Literal[EventType.METRIC.value] = EventType.METRIC.value
|
type: Literal[EventType.METRIC.value] = EventType.METRIC.value
|
||||||
metric: str # this would be an enum
|
metric: str # this would be an enum
|
||||||
value: Union[int, float]
|
value: Union[int, float]
|
||||||
unit: Optional[str] = None
|
unit: str
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
|
|
|
@ -153,20 +153,20 @@ class TelemetryAdapter(TelemetryDatasetMixin, Telemetry):
|
||||||
else:
|
else:
|
||||||
print(f"Warning: No active span found for span_id {span_id}. Dropping event: {event}")
|
print(f"Warning: No active span found for span_id {span_id}. Dropping event: {event}")
|
||||||
|
|
||||||
def _get_or_create_counter(self, name: str, unit: Optional[str] = None) -> metrics.Counter:
|
def _get_or_create_counter(self, name: str, unit: str) -> metrics.Counter:
|
||||||
if name not in _GLOBAL_STORAGE["counters"]:
|
if name not in _GLOBAL_STORAGE["counters"]:
|
||||||
_GLOBAL_STORAGE["counters"][name] = self.meter.create_counter(
|
_GLOBAL_STORAGE["counters"][name] = self.meter.create_counter(
|
||||||
name=name,
|
name=name,
|
||||||
unit=unit or "",
|
unit=unit,
|
||||||
description=f"Counter for {name}",
|
description=f"Counter for {name}",
|
||||||
)
|
)
|
||||||
return _GLOBAL_STORAGE["counters"][name]
|
return _GLOBAL_STORAGE["counters"][name]
|
||||||
|
|
||||||
def _get_or_create_gauge(self, name: str, unit: Optional[str] = None) -> metrics.ObservableGauge:
|
def _get_or_create_gauge(self, name: str, unit: str) -> metrics.ObservableGauge:
|
||||||
if name not in _GLOBAL_STORAGE["gauges"]:
|
if name not in _GLOBAL_STORAGE["gauges"]:
|
||||||
_GLOBAL_STORAGE["gauges"][name] = self.meter.create_gauge(
|
_GLOBAL_STORAGE["gauges"][name] = self.meter.create_gauge(
|
||||||
name=name,
|
name=name,
|
||||||
unit=unit or "",
|
unit=unit,
|
||||||
description=f"Gauge for {name}",
|
description=f"Gauge for {name}",
|
||||||
)
|
)
|
||||||
return _GLOBAL_STORAGE["gauges"][name]
|
return _GLOBAL_STORAGE["gauges"][name]
|
||||||
|
@ -181,11 +181,11 @@ class TelemetryAdapter(TelemetryDatasetMixin, Telemetry):
|
||||||
up_down_counter = self._get_or_create_up_down_counter(event.metric, event.unit)
|
up_down_counter = self._get_or_create_up_down_counter(event.metric, event.unit)
|
||||||
up_down_counter.add(event.value, attributes=event.attributes)
|
up_down_counter.add(event.value, attributes=event.attributes)
|
||||||
|
|
||||||
def _get_or_create_up_down_counter(self, name: str, unit: Optional[str] = None) -> metrics.UpDownCounter:
|
def _get_or_create_up_down_counter(self, name: str, unit: str) -> metrics.UpDownCounter:
|
||||||
if name not in _GLOBAL_STORAGE["up_down_counters"]:
|
if name not in _GLOBAL_STORAGE["up_down_counters"]:
|
||||||
_GLOBAL_STORAGE["up_down_counters"][name] = self.meter.create_up_down_counter(
|
_GLOBAL_STORAGE["up_down_counters"][name] = self.meter.create_up_down_counter(
|
||||||
name=name,
|
name=name,
|
||||||
unit=unit or "",
|
unit=unit,
|
||||||
description=f"UpDownCounter for {name}",
|
description=f"UpDownCounter for {name}",
|
||||||
)
|
)
|
||||||
return _GLOBAL_STORAGE["up_down_counters"][name]
|
return _GLOBAL_STORAGE["up_down_counters"][name]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue