26 lines
869 B
Python
26 lines
869 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Column, DateTime, Float, Integer, String
|
|
from sqlalchemy.ext.declarative import declarative_base
|
|
|
|
Base = declarative_base()
|
|
|
|
|
|
class PerformanceMetric(Base):
|
|
__tablename__ = "performance_metrics"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
timestamp = Column(DateTime, default=datetime.utcnow, index=True)
|
|
metric_name = Column(String, index=True)
|
|
value = Column(Float)
|
|
labels = Column(String) # JSON string of labels
|
|
endpoint = Column(String, index=True, nullable=True)
|
|
method = Column(String, nullable=True)
|
|
status_code = Column(Integer, nullable=True)
|
|
duration_seconds = Column(Float, nullable=True)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<PerformanceMetric(id={self.id}, name={self.metric_name}, value={self.value})>"
|