mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-28 06:31:03 +02:00
refactor: reduce Prometheus metrics cardinality and clarify label names (#1059)
With many workspaces and flows, the prometheus metrics expand greatly. Many significant metrics (e.g. latency) make more sense measured globally. This change introduces a consolidation. Histograms (request_latency, text_completion_duration, chunk_size, etc.) are now global with only processor-level labels, eliminating per-workspace time series multiplication. Counters and enums retain workspace and flow labels for per-workspace debugging visibility. Renamed metric labels for clarity: name -> consumer/producer/subscriber, and added explicit workspace label alongside flow. Fixed bug where request_response_spec labelled response subscriber with request_name instead of response_name. Removed unused Histogram imports from model and service files.
This commit is contained in:
parent
eb059707f0
commit
f7026efeda
31 changed files with 129 additions and 126 deletions
|
|
@ -73,8 +73,8 @@ def test_consumer_metrics_reuses_singletons_and_records_events(monkeypatch):
|
|||
monkeypatch.setattr(metrics, "Histogram", histogram_factory)
|
||||
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
||||
|
||||
first = metrics.ConsumerMetrics("proc", "flow", "name")
|
||||
second = metrics.ConsumerMetrics("proc-2", "flow-2", "name-2")
|
||||
first = metrics.ConsumerMetrics("proc", "cons", workspace="ws", flow="fl")
|
||||
second = metrics.ConsumerMetrics("proc-2", "cons-2")
|
||||
|
||||
assert enum_factory.call_count == 1
|
||||
assert histogram_factory.call_count == 1
|
||||
|
|
@ -96,7 +96,7 @@ def test_producer_metrics_increments_counter_once(monkeypatch):
|
|||
counter_factory.return_value.labels.return_value = labels
|
||||
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
||||
|
||||
producer_metrics = metrics.ProducerMetrics("proc", "flow", "output")
|
||||
producer_metrics = metrics.ProducerMetrics("proc", "output")
|
||||
producer_metrics.inc()
|
||||
|
||||
counter_factory.assert_called_once()
|
||||
|
|
@ -133,7 +133,7 @@ def test_subscriber_metrics_tracks_received_state_and_dropped(monkeypatch):
|
|||
monkeypatch.setattr(metrics, "Enum", enum_factory)
|
||||
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
||||
|
||||
subscriber_metrics = metrics.SubscriberMetrics("proc", "flow", "input")
|
||||
subscriber_metrics = metrics.SubscriberMetrics("proc", "input")
|
||||
subscriber_metrics.received()
|
||||
subscriber_metrics.state("running")
|
||||
subscriber_metrics.dropped("ignored")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue