Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

64 lines
2.7 KiB
Python

from prometheus_client import Counter, Histogram
def query_kind_label(query: dict | None) -> str:
if query and query.get("kind") == "InsightsQLQuery":
return "insightsql"
return "insight"
ENDPOINT_EXECUTION_TOTAL = Counter(
"insights_endpoint_execution_total",
"Endpoint executions that reached query execution (excludes concurrency rejections; see insights_endpoint_concurrency_rejected_total). "
"status is success; user_error (invalid query/variables in the user's endpoint, returned as 4xx); "
"query_performance (the query hit a Datastore cost guardrail — timeout/memory/size/estimated-too-slow — returned as 400); "
"capacity (shared Datastore pool momentarily saturated, returned as 503); "
'or error (unexpected system failure). Only error is a system fault — alert on status="error"',
labelnames=["execution_type", "query_kind", "status"],
)
ENDPOINT_EXECUTION_DURATION_SECONDS = Histogram(
"insights_endpoint_execution_duration_seconds",
"End-to-end endpoint execution duration (excludes concurrency rejections)",
labelnames=["execution_type", "query_kind"],
buckets=(0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 20, 45, 90, 180, 300, float("inf")),
)
ENDPOINT_MATERIALIZATION_EVENT_TOTAL = Counter(
"insights_endpoint_materialization_event_total",
"Materialization lifecycle events (enable/disable/deactivate_stale)",
labelnames=["action", "status"],
)
ENDPOINT_CONCURRENCY_REJECTED_TOTAL = Counter(
"insights_endpoint_concurrency_rejected_total",
"Endpoint executions rejected because the concurrency limit was exceeded",
# team_id is safe cardinality here: only teams actually hitting concurrency limits appear
labelnames=["team_id"],
)
ENDPOINT_CACHE_RESULT_TOTAL = Counter(
"insights_endpoint_cache_result_total",
"Endpoint responses by query-result cache outcome (hit or miss)",
labelnames=["execution_type", "query_kind", "outcome"],
)
ENDPOINT_INSIGHTSQL_RESULT_ROWS = Histogram(
"insights_endpoint_insightsql_result_rows",
"Number of rows returned by a InsightsQL endpoint response",
labelnames=["execution_type"],
buckets=(10, 100, 1_000, 10_000, 100_000, 1_000_000, float("inf")),
)
ENDPOINT_VALIDATION_ERROR_TOTAL = Counter(
"insights_endpoint_validation_error_total",
"Endpoint requests rejected at validation time, by reason",
labelnames=["reason"],
)
ENDPOINT_MATERIALIZED_FRESHNESS_RATIO = Histogram(
"insights_endpoint_materialized_freshness_ratio",
"Age of the served materialized data relative to its data_freshness_seconds target; >1.0 means behind SLA",
buckets=(0.05, 0.1, 0.25, 0.5, 0.75, 0.9, 1.0, 1.1, 1.25, 1.5, 2, 5, 10, float("inf")),
)