chore: initialize EverOS 1.0.0
md-first memory extraction framework for AI agents. Markdown is the single source of truth; SQLite holds state and LanceDB provides the rebuildable vector + BM25 + scalar index. The codebase follows a single-direction DDD layering (entrypoints -> service -> memory -> infra, with component / core / config cross-cutting) enforced by import-linter. Engineering surface: - Coding conventions in .claude/rules/ (path-scoped) and workflows in .claude/skills/ (/commit, /new-branch, /pr). - GitHub Actions CI runs make lint + test + integration; pre-commit mirrors the gates locally (ruff, hygiene hooks, gitlint commit-msg). - Commit messages follow Conventional Commits, enforced by gitlint. - make lint also enforces datetime two-zone discipline and OpenAPI drift.
This commit is contained in:
102
src/everos/core/observability/metrics/histogram.py
Normal file
102
src/everos/core/observability/metrics/histogram.py
Normal file
@ -0,0 +1,102 @@
|
||||
"""Histogram wrapper around ``prometheus_client.Histogram``."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
from typing import Any
|
||||
|
||||
from prometheus_client import Histogram as PromHistogram
|
||||
|
||||
from .registry import get_metrics_registry
|
||||
|
||||
|
||||
class HistogramBuckets:
|
||||
"""Predefined bucket configurations for common workloads."""
|
||||
|
||||
DEFAULT: tuple[float, ...] = (
|
||||
0.005,
|
||||
0.01,
|
||||
0.025,
|
||||
0.05,
|
||||
0.1,
|
||||
0.25,
|
||||
0.5,
|
||||
1.0,
|
||||
2.5,
|
||||
5.0,
|
||||
10.0,
|
||||
)
|
||||
FAST: tuple[float, ...] = (0.001, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5)
|
||||
API_CALL: tuple[float, ...] = (
|
||||
0.01,
|
||||
0.05,
|
||||
0.1,
|
||||
0.25,
|
||||
0.5,
|
||||
1.0,
|
||||
2.0,
|
||||
5.0,
|
||||
10.0,
|
||||
30.0,
|
||||
)
|
||||
BATCH: tuple[float, ...] = (0.1, 0.5, 1.0, 5.0, 10.0, 30.0, 60.0)
|
||||
DATABASE: tuple[float, ...] = (
|
||||
0.001,
|
||||
0.005,
|
||||
0.01,
|
||||
0.025,
|
||||
0.05,
|
||||
0.1,
|
||||
0.25,
|
||||
0.5,
|
||||
1.0,
|
||||
2.5,
|
||||
5.0,
|
||||
)
|
||||
|
||||
|
||||
class Histogram:
|
||||
"""Distribution of observed values (latency, sizes)."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
description: str,
|
||||
labelnames: Sequence[str] = (),
|
||||
namespace: str = "",
|
||||
subsystem: str = "",
|
||||
unit: str = "",
|
||||
buckets: Sequence[float] = HistogramBuckets.DEFAULT,
|
||||
) -> None:
|
||||
self._histogram = PromHistogram(
|
||||
name=name,
|
||||
documentation=description,
|
||||
labelnames=labelnames,
|
||||
namespace=namespace,
|
||||
subsystem=subsystem,
|
||||
unit=unit,
|
||||
buckets=tuple(buckets),
|
||||
registry=get_metrics_registry(),
|
||||
)
|
||||
|
||||
def labels(self, **labels: str) -> LabeledHistogram:
|
||||
return LabeledHistogram(self._histogram.labels(**labels))
|
||||
|
||||
def observe(self, amount: float) -> None:
|
||||
self._histogram.observe(amount)
|
||||
|
||||
def time(self) -> Any:
|
||||
return self._histogram.time()
|
||||
|
||||
|
||||
class LabeledHistogram:
|
||||
"""Histogram slice with labels applied."""
|
||||
|
||||
def __init__(self, labeled: Any) -> None:
|
||||
self._labeled = labeled
|
||||
|
||||
def observe(self, amount: float) -> None:
|
||||
self._labeled.observe(amount)
|
||||
|
||||
def time(self) -> Any:
|
||||
return self._labeled.time()
|
||||
Reference in New Issue
Block a user