mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-27 06:01:01 +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, "Histogram", histogram_factory)
|
||||||
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
||||||
|
|
||||||
first = metrics.ConsumerMetrics("proc", "flow", "name")
|
first = metrics.ConsumerMetrics("proc", "cons", workspace="ws", flow="fl")
|
||||||
second = metrics.ConsumerMetrics("proc-2", "flow-2", "name-2")
|
second = metrics.ConsumerMetrics("proc-2", "cons-2")
|
||||||
|
|
||||||
assert enum_factory.call_count == 1
|
assert enum_factory.call_count == 1
|
||||||
assert histogram_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
|
counter_factory.return_value.labels.return_value = labels
|
||||||
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
monkeypatch.setattr(metrics, "Counter", counter_factory)
|
||||||
|
|
||||||
producer_metrics = metrics.ProducerMetrics("proc", "flow", "output")
|
producer_metrics = metrics.ProducerMetrics("proc", "output")
|
||||||
producer_metrics.inc()
|
producer_metrics.inc()
|
||||||
|
|
||||||
counter_factory.assert_called_once()
|
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, "Enum", enum_factory)
|
||||||
monkeypatch.setattr(metrics, "Counter", counter_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.received()
|
||||||
subscriber_metrics.state("running")
|
subscriber_metrics.state("running")
|
||||||
subscriber_metrics.dropped("ignored")
|
subscriber_metrics.dropped("ignored")
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from argparse import ArgumentParser
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
from prometheus_client import Histogram
|
|
||||||
|
|
||||||
from .. schema import AgentRequest, AgentResponse, Error
|
from .. schema import AgentRequest, AgentResponse, Error
|
||||||
from .. exceptions import TooManyRequests
|
from .. exceptions import TooManyRequests
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ class AsyncProcessor:
|
||||||
config_subscriber_id = str(uuid.uuid4())
|
config_subscriber_id = str(uuid.uuid4())
|
||||||
|
|
||||||
config_consumer_metrics = ConsumerMetrics(
|
config_consumer_metrics = ConsumerMetrics(
|
||||||
processor = self.id, flow = None, name = "config",
|
processor=self.id, consumer="config",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Subscribe to config notify queue
|
# Subscribe to config notify queue
|
||||||
|
|
@ -112,10 +112,10 @@ class AsyncProcessor:
|
||||||
config_rr_id = str(uuid.uuid4())
|
config_rr_id = str(uuid.uuid4())
|
||||||
|
|
||||||
config_req_metrics = ProducerMetrics(
|
config_req_metrics = ProducerMetrics(
|
||||||
processor = self.id, flow = None, name = "config-request",
|
processor=self.id, producer="config-request",
|
||||||
)
|
)
|
||||||
config_resp_metrics = SubscriberMetrics(
|
config_resp_metrics = SubscriberMetrics(
|
||||||
processor = self.id, flow = None, name = "config-response",
|
processor=self.id, subscriber="config-response",
|
||||||
)
|
)
|
||||||
|
|
||||||
return RequestResponse(
|
return RequestResponse(
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,7 @@ class AuditPublisher:
|
||||||
schema=AuditEvent,
|
schema=AuditEvent,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=processor_id or component_name,
|
processor=processor_id or component_name,
|
||||||
flow=None,
|
producer="audit-events",
|
||||||
name="audit-events",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ class ConsumerSpec(Spec):
|
||||||
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
||||||
|
|
||||||
consumer_metrics = ConsumerMetrics(
|
consumer_metrics = ConsumerMetrics(
|
||||||
processor = flow.id, flow = flow.name, name = self.name,
|
processor=flow.id, consumer=self.name,
|
||||||
|
workspace=flow.workspace, flow=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
consumer = Consumer(
|
consumer = Consumer(
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class DynamicToolService(AsyncProcessor):
|
||||||
|
|
||||||
# Create consumer for requests
|
# Create consumer for requests
|
||||||
consumer_metrics = ConsumerMetrics(
|
consumer_metrics = ConsumerMetrics(
|
||||||
processor=self.id, flow=None, name="request"
|
processor=self.id, consumer="request",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.consumer = Consumer(
|
self.consumer = Consumer(
|
||||||
|
|
@ -79,7 +79,7 @@ class DynamicToolService(AsyncProcessor):
|
||||||
|
|
||||||
# Create producer for responses
|
# Create producer for responses
|
||||||
producer_metrics = ProducerMetrics(
|
producer_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="response"
|
processor=self.id, producer="response",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.producer = Producer(
|
self.producer = Producer(
|
||||||
|
|
@ -93,7 +93,7 @@ class DynamicToolService(AsyncProcessor):
|
||||||
__class__.tool_service_metric = Counter(
|
__class__.tool_service_metric = Counter(
|
||||||
'dynamic_tool_service_invocation_count',
|
'dynamic_tool_service_invocation_count',
|
||||||
'Dynamic tool service invocation count',
|
'Dynamic tool service invocation count',
|
||||||
["id"],
|
["processor"],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def start(self):
|
async def start(self):
|
||||||
|
|
@ -133,7 +133,7 @@ class DynamicToolService(AsyncProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.tool_service_metric.labels(
|
__class__.tool_service_metric.labels(
|
||||||
id=self.id,
|
processor=self.id,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
except TooManyRequests as e:
|
except TooManyRequests as e:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ from argparse import ArgumentParser
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
from prometheus_client import Histogram
|
|
||||||
|
|
||||||
from .. schema import EmbeddingsRequest, EmbeddingsResponse, Error
|
from .. schema import EmbeddingsRequest, EmbeddingsResponse, Error
|
||||||
from .. exceptions import TooManyRequests
|
from .. exceptions import TooManyRequests
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ class ImageToTextService(FlowProcessor):
|
||||||
__class__.image_to_text_metric = Histogram(
|
__class__.image_to_text_metric = Histogram(
|
||||||
'image_to_text_duration',
|
'image_to_text_duration',
|
||||||
'Image-to-text duration (seconds)',
|
'Image-to-text duration (seconds)',
|
||||||
["id", "flow"],
|
["processor"],
|
||||||
buckets=[
|
buckets=[
|
||||||
0.25, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
|
0.25, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
|
||||||
8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
|
|
@ -89,7 +89,7 @@ class ImageToTextService(FlowProcessor):
|
||||||
__class__.image_to_text_model_metric = Info(
|
__class__.image_to_text_model_metric = Info(
|
||||||
'image_to_text_model',
|
'image_to_text_model',
|
||||||
'Image-to-text model',
|
'Image-to-text model',
|
||||||
["processor", "flow"]
|
["processor"]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_request(self, msg, consumer, flow):
|
async def on_request(self, msg, consumer, flow):
|
||||||
|
|
@ -105,8 +105,7 @@ class ImageToTextService(FlowProcessor):
|
||||||
model = flow("model")
|
model = flow("model")
|
||||||
|
|
||||||
with __class__.image_to_text_metric.labels(
|
with __class__.image_to_text_metric.labels(
|
||||||
id=self.id,
|
processor=self.id,
|
||||||
flow=f"{flow.name}-{consumer.name}",
|
|
||||||
).time():
|
).time():
|
||||||
|
|
||||||
response = await self.describe_image(
|
response = await self.describe_image(
|
||||||
|
|
@ -126,8 +125,7 @@ class ImageToTextService(FlowProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.image_to_text_model_metric.labels(
|
__class__.image_to_text_model_metric.labels(
|
||||||
processor = self.id,
|
processor=self.id,
|
||||||
flow = flow.name
|
|
||||||
).info({
|
).info({
|
||||||
"model": str(model) if model is not None else "",
|
"model": str(model) if model is not None else "",
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,12 @@ class LibrarianClient:
|
||||||
"librarian_subscriber", f"{id}-librarian",
|
"librarian_subscriber", f"{id}-librarian",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
workspace = params.get("workspace")
|
||||||
flow_name = params.get("flow_name")
|
flow_name = params.get("flow_name")
|
||||||
|
|
||||||
librarian_request_metrics = ProducerMetrics(
|
librarian_request_metrics = ProducerMetrics(
|
||||||
processor=id, flow=flow_name, name="librarian-request",
|
processor=id, producer="librarian-request",
|
||||||
|
workspace=workspace, flow=flow_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._producer = Producer(
|
self._producer = Producer(
|
||||||
|
|
@ -57,7 +59,8 @@ class LibrarianClient:
|
||||||
)
|
)
|
||||||
|
|
||||||
librarian_response_metrics = ConsumerMetrics(
|
librarian_response_metrics = ConsumerMetrics(
|
||||||
processor=id, flow=flow_name, name="librarian-response",
|
processor=id, consumer="librarian-response",
|
||||||
|
workspace=workspace, flow=flow_name,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._consumer = Consumer(
|
self._consumer = Consumer(
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ class LibrarianSpec(Spec):
|
||||||
processor.id + "--" + flow.workspace + "--" +
|
processor.id + "--" + flow.workspace + "--" +
|
||||||
flow.name + "--librarian--" + str(uuid.uuid4())
|
flow.name + "--librarian--" + str(uuid.uuid4())
|
||||||
),
|
),
|
||||||
|
workspace=flow.workspace,
|
||||||
flow_name=flow.name,
|
flow_name=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class LlmService(FlowProcessor):
|
||||||
__class__.text_completion_metric = Histogram(
|
__class__.text_completion_metric = Histogram(
|
||||||
'text_completion_duration',
|
'text_completion_duration',
|
||||||
'Text completion duration (seconds)',
|
'Text completion duration (seconds)',
|
||||||
["id", "flow"],
|
["processor"],
|
||||||
buckets=[
|
buckets=[
|
||||||
0.25, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
|
0.25, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0,
|
||||||
8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||||
|
|
@ -108,7 +108,7 @@ class LlmService(FlowProcessor):
|
||||||
__class__.text_completion_model_metric = Info(
|
__class__.text_completion_model_metric = Info(
|
||||||
'text_completion_model',
|
'text_completion_model',
|
||||||
'Text completion model',
|
'Text completion model',
|
||||||
["processor", "flow"]
|
["processor"]
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_request(self, msg, consumer, flow):
|
async def on_request(self, msg, consumer, flow):
|
||||||
|
|
@ -133,8 +133,7 @@ class LlmService(FlowProcessor):
|
||||||
|
|
||||||
# Streaming mode
|
# Streaming mode
|
||||||
with __class__.text_completion_metric.labels(
|
with __class__.text_completion_metric.labels(
|
||||||
id=self.id,
|
processor=self.id,
|
||||||
flow=f"{flow.name}-{consumer.name}",
|
|
||||||
).time():
|
).time():
|
||||||
|
|
||||||
async for chunk in self.generate_content_stream(
|
async for chunk in self.generate_content_stream(
|
||||||
|
|
@ -157,8 +156,7 @@ class LlmService(FlowProcessor):
|
||||||
|
|
||||||
# Non-streaming mode (original behavior)
|
# Non-streaming mode (original behavior)
|
||||||
with __class__.text_completion_metric.labels(
|
with __class__.text_completion_metric.labels(
|
||||||
id=self.id,
|
processor=self.id,
|
||||||
flow=f"{flow.name}-{consumer.name}",
|
|
||||||
).time():
|
).time():
|
||||||
|
|
||||||
response = await self.generate_content(
|
response = await self.generate_content(
|
||||||
|
|
@ -179,8 +177,7 @@ class LlmService(FlowProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.text_completion_model_metric.labels(
|
__class__.text_completion_model_metric.labels(
|
||||||
processor = self.id,
|
processor=self.id,
|
||||||
flow = flow.name
|
|
||||||
).info({
|
).info({
|
||||||
"model": str(model) if model is not None else "",
|
"model": str(model) if model is not None else "",
|
||||||
"temperature": str(temperature) if temperature is not None else "",
|
"temperature": str(temperature) if temperature is not None else "",
|
||||||
|
|
|
||||||
|
|
@ -6,82 +6,85 @@ from prometheus_client import start_http_server, Info, Enum, Histogram
|
||||||
from prometheus_client import Counter
|
from prometheus_client import Counter
|
||||||
|
|
||||||
class ConsumerMetrics:
|
class ConsumerMetrics:
|
||||||
"""
|
|
||||||
Metrics tracking and reporting for flow consumers.
|
|
||||||
|
|
||||||
This class manages prometheus metrics specifically related to consumers
|
|
||||||
within the flow, including state, requests, processing time, and queues.
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, processor: str, flow: str, name: str) -> None:
|
def __init__(self, processor: str, consumer: str,
|
||||||
|
workspace: str | None = None,
|
||||||
|
flow: str | None = None) -> None:
|
||||||
|
|
||||||
self.processor = processor
|
self.processor = processor
|
||||||
|
self.consumer = consumer
|
||||||
|
self.workspace = workspace
|
||||||
self.flow = flow
|
self.flow = flow
|
||||||
self.name = name
|
|
||||||
|
|
||||||
if not hasattr(__class__, "state_metric"):
|
if not hasattr(__class__, "state_metric"):
|
||||||
__class__.state_metric = Enum(
|
__class__.state_metric = Enum(
|
||||||
'consumer_state', 'Consumer state',
|
'consumer_state', 'Consumer state',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "consumer"],
|
||||||
states=['stopped', 'running']
|
states=['stopped', 'running']
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(__class__, "request_metric"):
|
if not hasattr(__class__, "request_metric"):
|
||||||
__class__.request_metric = Histogram(
|
__class__.request_metric = Histogram(
|
||||||
'request_latency', 'Request latency (seconds)',
|
'request_latency', 'Request latency (seconds)',
|
||||||
["processor", "flow", "name"],
|
["processor", "consumer"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(__class__, "processing_metric"):
|
if not hasattr(__class__, "processing_metric"):
|
||||||
__class__.processing_metric = Counter(
|
__class__.processing_metric = Counter(
|
||||||
'processing_count', 'Processing count',
|
'processing_count', 'Processing count',
|
||||||
["processor", "flow", "name", "status"],
|
["processor", "workspace", "flow", "consumer", "status"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(__class__, "rate_limit_metric"):
|
if not hasattr(__class__, "rate_limit_metric"):
|
||||||
__class__.rate_limit_metric = Counter(
|
__class__.rate_limit_metric = Counter(
|
||||||
'rate_limit_count', 'Rate limit event count',
|
'rate_limit_count', 'Rate limit event count',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "consumer"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def process(self, status: str) -> None:
|
def process(self, status: str) -> None:
|
||||||
__class__.processing_metric.labels(
|
__class__.processing_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
status=status
|
flow=self.flow, consumer=self.consumer, status=status,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
def rate_limit(self) -> None:
|
def rate_limit(self) -> None:
|
||||||
__class__.rate_limit_metric.labels(
|
__class__.rate_limit_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, consumer=self.consumer,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
def state(self, state: str) -> None:
|
def state(self, state: str) -> None:
|
||||||
__class__.state_metric.labels(
|
__class__.state_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, consumer=self.consumer,
|
||||||
).state(state)
|
).state(state)
|
||||||
|
|
||||||
def record_time(self) -> Any:
|
def record_time(self) -> Any:
|
||||||
return __class__.request_metric.labels(
|
return __class__.request_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, consumer=self.consumer,
|
||||||
).time()
|
).time()
|
||||||
|
|
||||||
class ProducerMetrics:
|
class ProducerMetrics:
|
||||||
|
|
||||||
def __init__(self, processor: str, flow: str, name: str) -> None:
|
def __init__(self, processor: str, producer: str,
|
||||||
|
workspace: str | None = None,
|
||||||
|
flow: str | None = None) -> None:
|
||||||
|
|
||||||
self.processor = processor
|
self.processor = processor
|
||||||
|
self.producer = producer
|
||||||
|
self.workspace = workspace
|
||||||
self.flow = flow
|
self.flow = flow
|
||||||
self.name = name
|
|
||||||
|
|
||||||
if not hasattr(__class__, "producer_metric"):
|
if not hasattr(__class__, "producer_metric"):
|
||||||
__class__.producer_metric = Counter(
|
__class__.producer_metric = Counter(
|
||||||
'producer_count', 'Output items produced',
|
'producer_count', 'Output items produced',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "producer"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def inc(self) -> None:
|
def inc(self) -> None:
|
||||||
__class__.producer_metric.labels(
|
__class__.producer_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, producer=self.producer,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
class ProcessorMetrics:
|
class ProcessorMetrics:
|
||||||
|
|
@ -102,43 +105,48 @@ class ProcessorMetrics:
|
||||||
|
|
||||||
class SubscriberMetrics:
|
class SubscriberMetrics:
|
||||||
|
|
||||||
def __init__(self, processor: str, flow: str, name: str) -> None:
|
def __init__(self, processor: str, subscriber: str,
|
||||||
|
workspace: str | None = None,
|
||||||
|
flow: str | None = None) -> None:
|
||||||
|
|
||||||
self.processor = processor
|
self.processor = processor
|
||||||
|
self.subscriber = subscriber
|
||||||
|
self.workspace = workspace
|
||||||
self.flow = flow
|
self.flow = flow
|
||||||
self.name = name
|
|
||||||
|
|
||||||
if not hasattr(__class__, "state_metric"):
|
if not hasattr(__class__, "state_metric"):
|
||||||
__class__.state_metric = Enum(
|
__class__.state_metric = Enum(
|
||||||
'subscriber_state', 'Subscriber state',
|
'subscriber_state', 'Subscriber state',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "subscriber"],
|
||||||
states=['stopped', 'running']
|
states=['stopped', 'running']
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(__class__, "received_metric"):
|
if not hasattr(__class__, "received_metric"):
|
||||||
__class__.received_metric = Counter(
|
__class__.received_metric = Counter(
|
||||||
'received_count', 'Received count',
|
'received_count', 'Received count',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "subscriber"],
|
||||||
)
|
)
|
||||||
|
|
||||||
if not hasattr(__class__, "dropped_metric"):
|
if not hasattr(__class__, "dropped_metric"):
|
||||||
__class__.dropped_metric = Counter(
|
__class__.dropped_metric = Counter(
|
||||||
'dropped_count', 'Dropped messages count',
|
'dropped_count', 'Dropped messages count',
|
||||||
["processor", "flow", "name"],
|
["processor", "workspace", "flow", "subscriber"],
|
||||||
)
|
)
|
||||||
|
|
||||||
def received(self) -> None:
|
def received(self) -> None:
|
||||||
__class__.received_metric.labels(
|
__class__.received_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, subscriber=self.subscriber,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
def state(self, state: str) -> None:
|
def state(self, state: str) -> None:
|
||||||
|
|
||||||
__class__.state_metric.labels(
|
__class__.state_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, subscriber=self.subscriber,
|
||||||
).state(state)
|
).state(state)
|
||||||
|
|
||||||
def dropped(self, state: str) -> None:
|
def dropped(self, state: str) -> None:
|
||||||
__class__.dropped_metric.labels(
|
__class__.dropped_metric.labels(
|
||||||
processor = self.processor, flow = self.flow, name = self.name,
|
processor=self.processor, workspace=self.workspace,
|
||||||
|
flow=self.flow, subscriber=self.subscriber,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,8 @@ class ProducerSpec(Spec):
|
||||||
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
||||||
|
|
||||||
producer_metrics = ProducerMetrics(
|
producer_metrics = ProducerMetrics(
|
||||||
processor = flow.id, flow = flow.name, name = self.name
|
processor=flow.id, producer=self.name,
|
||||||
|
workspace=flow.workspace, flow=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
producer = Producer(
|
producer = Producer(
|
||||||
|
|
|
||||||
|
|
@ -132,11 +132,13 @@ class RequestResponseSpec(Spec):
|
||||||
return
|
return
|
||||||
|
|
||||||
request_metrics = ProducerMetrics(
|
request_metrics = ProducerMetrics(
|
||||||
processor = flow.id, flow = flow.name, name = self.request_name
|
processor=flow.id, producer=self.request_name,
|
||||||
|
workspace=flow.workspace, flow=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
response_metrics = SubscriberMetrics(
|
response_metrics = SubscriberMetrics(
|
||||||
processor = flow.id, flow = flow.name, name = self.request_name
|
processor=flow.id, subscriber=self.response_name,
|
||||||
|
workspace=flow.workspace, flow=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
rr = self.impl(
|
rr = self.impl(
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ class SubscriberSpec(Spec):
|
||||||
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
def add(self, flow: Any, processor: Any, definition: dict[str, Any]) -> None:
|
||||||
|
|
||||||
subscriber_metrics = SubscriberMetrics(
|
subscriber_metrics = SubscriberMetrics(
|
||||||
processor = flow.id, flow = flow.name, name = self.name
|
processor=flow.id, subscriber=self.name,
|
||||||
|
workspace=flow.workspace, flow=flow.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
subscriber = Subscriber(
|
subscriber = Subscriber(
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class ToolService(FlowProcessor):
|
||||||
if not hasattr(__class__, "tool_invocation_metric"):
|
if not hasattr(__class__, "tool_invocation_metric"):
|
||||||
__class__.tool_invocation_metric = Counter(
|
__class__.tool_invocation_metric = Counter(
|
||||||
'tool_invocation_count', 'Tool invocation count',
|
'tool_invocation_count', 'Tool invocation count',
|
||||||
["id", "flow", "name"],
|
["processor", "workspace", "flow", "tool"],
|
||||||
)
|
)
|
||||||
|
|
||||||
async def on_request(self, msg, consumer, flow):
|
async def on_request(self, msg, consumer, flow):
|
||||||
|
|
@ -89,7 +89,8 @@ class ToolService(FlowProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.tool_invocation_metric.labels(
|
__class__.tool_invocation_metric.labels(
|
||||||
id = self.id, flow = flow.name, name = request.name,
|
processor=self.id, workspace=flow.workspace,
|
||||||
|
flow=flow.name, tool=request.name,
|
||||||
).inc()
|
).inc()
|
||||||
|
|
||||||
except TooManyRequests as e:
|
except TooManyRequests as e:
|
||||||
|
|
|
||||||
|
|
@ -277,13 +277,11 @@ class ToolServiceImpl:
|
||||||
|
|
||||||
request_metrics = ProducerMetrics(
|
request_metrics = ProducerMetrics(
|
||||||
processor=self.processor.id,
|
processor=self.processor.id,
|
||||||
flow="tool-service",
|
producer=self.request_queue,
|
||||||
name=self.request_queue
|
|
||||||
)
|
)
|
||||||
response_metrics = SubscriberMetrics(
|
response_metrics = SubscriberMetrics(
|
||||||
processor=self.processor.id,
|
processor=self.processor.id,
|
||||||
flow="tool-service",
|
subscriber=self.response_queue,
|
||||||
name=self.response_queue
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create unique subscription for responses
|
# Create unique subscription for responses
|
||||||
|
|
|
||||||
|
|
@ -173,12 +173,12 @@ class Processor(AsyncProcessor):
|
||||||
request_topic=config_request_queue,
|
request_topic=config_request_queue,
|
||||||
request_schema=ConfigRequest,
|
request_schema=ConfigRequest,
|
||||||
request_metrics=ProducerMetrics(
|
request_metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="config-request",
|
processor=self.id, producer="config-request",
|
||||||
),
|
),
|
||||||
response_topic=config_response_queue,
|
response_topic=config_response_queue,
|
||||||
response_schema=ConfigResponse,
|
response_schema=ConfigResponse,
|
||||||
response_metrics=SubscriberMetrics(
|
response_metrics=SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="config-response",
|
processor=self.id, subscriber="config-response",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -191,12 +191,12 @@ class Processor(AsyncProcessor):
|
||||||
request_topic=f"{flow_request_queue}:{workspace}",
|
request_topic=f"{flow_request_queue}:{workspace}",
|
||||||
request_schema=FlowRequest,
|
request_schema=FlowRequest,
|
||||||
request_metrics=ProducerMetrics(
|
request_metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="flow-request",
|
processor=self.id, producer="flow-request",
|
||||||
),
|
),
|
||||||
response_topic=f"{flow_response_queue}:{workspace}",
|
response_topic=f"{flow_response_queue}:{workspace}",
|
||||||
response_schema=FlowResponse,
|
response_schema=FlowResponse,
|
||||||
response_metrics=SubscriberMetrics(
|
response_metrics=SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="flow-response",
|
processor=self.id, subscriber="flow-response",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -209,12 +209,12 @@ class Processor(AsyncProcessor):
|
||||||
request_topic=iam_request_queue,
|
request_topic=iam_request_queue,
|
||||||
request_schema=IamRequest,
|
request_schema=IamRequest,
|
||||||
request_metrics=ProducerMetrics(
|
request_metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-request",
|
processor=self.id, producer="iam-request",
|
||||||
),
|
),
|
||||||
response_topic=iam_response_queue,
|
response_topic=iam_response_queue,
|
||||||
response_schema=IamResponse,
|
response_schema=IamResponse,
|
||||||
response_metrics=SubscriberMetrics(
|
response_metrics=SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="iam-response",
|
processor=self.id, subscriber="iam-response",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ class Processor(ChunkingService):
|
||||||
if not hasattr(__class__, "chunk_metric"):
|
if not hasattr(__class__, "chunk_metric"):
|
||||||
__class__.chunk_metric = Histogram(
|
__class__.chunk_metric = Histogram(
|
||||||
'chunk_size', 'Chunk size',
|
'chunk_size', 'Chunk size',
|
||||||
["id", "flow"],
|
["processor"],
|
||||||
buckets=[100, 160, 250, 400, 650, 1000, 1600,
|
buckets=[100, 160, 250, 400, 650, 1000, 1600,
|
||||||
2500, 4000, 6400, 10000, 16000]
|
2500, 4000, 6400, 10000, 16000]
|
||||||
)
|
)
|
||||||
|
|
@ -184,7 +184,7 @@ class Processor(ChunkingService):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.chunk_metric.labels(
|
__class__.chunk_metric.labels(
|
||||||
id=consumer.id, flow=consumer.flow
|
processor=self.id,
|
||||||
).observe(chunk_length)
|
).observe(chunk_length)
|
||||||
|
|
||||||
await flow("output").send(r)
|
await flow("output").send(r)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ class Processor(ChunkingService):
|
||||||
if not hasattr(__class__, "chunk_metric"):
|
if not hasattr(__class__, "chunk_metric"):
|
||||||
__class__.chunk_metric = Histogram(
|
__class__.chunk_metric = Histogram(
|
||||||
'chunk_size', 'Chunk size',
|
'chunk_size', 'Chunk size',
|
||||||
["id", "flow"],
|
["processor"],
|
||||||
buckets=[100, 160, 250, 400, 650, 1000, 1600,
|
buckets=[100, 160, 250, 400, 650, 1000, 1600,
|
||||||
2500, 4000, 6400, 10000, 16000]
|
2500, 4000, 6400, 10000, 16000]
|
||||||
)
|
)
|
||||||
|
|
@ -180,7 +180,7 @@ class Processor(ChunkingService):
|
||||||
)
|
)
|
||||||
|
|
||||||
__class__.chunk_metric.labels(
|
__class__.chunk_metric.labels(
|
||||||
id=consumer.id, flow=consumer.flow
|
processor=self.id,
|
||||||
).observe(chunk_length)
|
).observe(chunk_length)
|
||||||
|
|
||||||
await flow("output").send(r)
|
await flow("output").send(r)
|
||||||
|
|
|
||||||
|
|
@ -106,13 +106,13 @@ class Processor(AsyncProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
config_request_metrics = ConsumerMetrics(
|
config_request_metrics = ConsumerMetrics(
|
||||||
processor = self.id, flow = None, name = "config-request"
|
processor=self.id, consumer="config-request",
|
||||||
)
|
)
|
||||||
config_response_metrics = ProducerMetrics(
|
config_response_metrics = ProducerMetrics(
|
||||||
processor = self.id, flow = None, name = "config-response"
|
processor=self.id, producer="config-response",
|
||||||
)
|
)
|
||||||
config_push_metrics = ProducerMetrics(
|
config_push_metrics = ProducerMetrics(
|
||||||
processor = self.id, flow = None, name = "config-push"
|
processor=self.id, producer="config-push",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.config_request_queue_base = config_request_queue
|
self.config_request_queue_base = config_request_queue
|
||||||
|
|
@ -225,8 +225,8 @@ class Processor(AsyncProcessor):
|
||||||
topic=resp_queue,
|
topic=resp_queue,
|
||||||
schema=ConfigResponse,
|
schema=ConfigResponse,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, producer="config-response",
|
||||||
name=f"config-response-{workspace_id}",
|
workspace=workspace_id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -242,8 +242,8 @@ class Processor(AsyncProcessor):
|
||||||
workspace=workspace_id,
|
workspace=workspace_id,
|
||||||
),
|
),
|
||||||
metrics=ConsumerMetrics(
|
metrics=ConsumerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, consumer="config-request",
|
||||||
name=f"config-request-{workspace_id}",
|
workspace=workspace_id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,8 +120,8 @@ class Processor(WorkspaceProcessor):
|
||||||
topic=resp_queue,
|
topic=resp_queue,
|
||||||
schema=KnowledgeResponse,
|
schema=KnowledgeResponse,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, producer="knowledge-response",
|
||||||
name=f"knowledge-response-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -136,8 +136,8 @@ class Processor(WorkspaceProcessor):
|
||||||
self.on_knowledge_request, workspace=workspace,
|
self.on_knowledge_request, workspace=workspace,
|
||||||
),
|
),
|
||||||
metrics=ConsumerMetrics(
|
metrics=ConsumerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, consumer="knowledge-request",
|
||||||
name=f"knowledge-request-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,10 +55,10 @@ class Processor(WorkspaceProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
config_req_metrics = ProducerMetrics(
|
config_req_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="config-request",
|
processor=self.id, producer="config-request",
|
||||||
)
|
)
|
||||||
config_resp_metrics = SubscriberMetrics(
|
config_resp_metrics = SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="config-response",
|
processor=self.id, subscriber="config-response",
|
||||||
)
|
)
|
||||||
|
|
||||||
config_rr_id = str(uuid.uuid4())
|
config_rr_id = str(uuid.uuid4())
|
||||||
|
|
@ -100,8 +100,8 @@ class Processor(WorkspaceProcessor):
|
||||||
topic=resp_queue,
|
topic=resp_queue,
|
||||||
schema=FlowResponse,
|
schema=FlowResponse,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, producer="flow-response",
|
||||||
name=f"flow-response-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -116,8 +116,8 @@ class Processor(WorkspaceProcessor):
|
||||||
self.on_flow_request, workspace=workspace,
|
self.on_flow_request, workspace=workspace,
|
||||||
),
|
),
|
||||||
metrics=ConsumerMetrics(
|
metrics=ConsumerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, consumer="flow-request",
|
||||||
name=f"flow-request-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,12 +164,12 @@ class IamAuth:
|
||||||
request_topic=iam_request_queue,
|
request_topic=iam_request_queue,
|
||||||
request_schema=IamRequest,
|
request_schema=IamRequest,
|
||||||
request_metrics=ProducerMetrics(
|
request_metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-request",
|
processor=self.id, producer="iam-request",
|
||||||
),
|
),
|
||||||
response_topic=iam_response_queue,
|
response_topic=iam_response_queue,
|
||||||
response_schema=IamResponse,
|
response_schema=IamResponse,
|
||||||
response_metrics=SubscriberMetrics(
|
response_metrics=SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="iam-response",
|
processor=self.id, subscriber="iam-response",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,12 +96,10 @@ class ConfigReceiver:
|
||||||
id = str(uuid.uuid4())
|
id = str(uuid.uuid4())
|
||||||
|
|
||||||
config_req_metrics = ProducerMetrics(
|
config_req_metrics = ProducerMetrics(
|
||||||
processor="api-gateway", flow=None,
|
processor="api-gateway", producer="config-request",
|
||||||
name="config-request",
|
|
||||||
)
|
)
|
||||||
config_resp_metrics = SubscriberMetrics(
|
config_resp_metrics = SubscriberMetrics(
|
||||||
processor="api-gateway", flow=None,
|
processor="api-gateway", subscriber="config-response",
|
||||||
name="config-response",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
return RequestResponse(
|
return RequestResponse(
|
||||||
|
|
|
||||||
|
|
@ -44,10 +44,10 @@ class Processor(AsyncProcessor):
|
||||||
super().__init__(**params)
|
super().__init__(**params)
|
||||||
|
|
||||||
iam_request_metrics = ConsumerMetrics(
|
iam_request_metrics = ConsumerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-request",
|
processor=self.id, consumer="iam-request",
|
||||||
)
|
)
|
||||||
iam_response_metrics = ProducerMetrics(
|
iam_response_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-response",
|
processor=self.id, producer="iam-response",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.iam_request_topic = iam_req_q
|
self.iam_request_topic = iam_req_q
|
||||||
|
|
@ -88,10 +88,10 @@ class Processor(AsyncProcessor):
|
||||||
def _create_config_client(self):
|
def _create_config_client(self):
|
||||||
config_rr_id = str(uuid.uuid4())
|
config_rr_id = str(uuid.uuid4())
|
||||||
config_req_metrics = ProducerMetrics(
|
config_req_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="config-request",
|
processor=self.id, producer="config-request",
|
||||||
)
|
)
|
||||||
config_resp_metrics = SubscriberMetrics(
|
config_resp_metrics = SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="config-response",
|
processor=self.id, subscriber="config-response",
|
||||||
)
|
)
|
||||||
return RequestResponse(
|
return RequestResponse(
|
||||||
backend=self.pubsub,
|
backend=self.pubsub,
|
||||||
|
|
|
||||||
|
|
@ -120,10 +120,10 @@ class Processor(AsyncProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
iam_request_metrics = ConsumerMetrics(
|
iam_request_metrics = ConsumerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-request",
|
processor=self.id, consumer="iam-request",
|
||||||
)
|
)
|
||||||
iam_response_metrics = ProducerMetrics(
|
iam_response_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="iam-response",
|
processor=self.id, producer="iam-response",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.iam_request_topic = iam_req_q
|
self.iam_request_topic = iam_req_q
|
||||||
|
|
@ -179,10 +179,10 @@ class Processor(AsyncProcessor):
|
||||||
import uuid
|
import uuid
|
||||||
config_rr_id = str(uuid.uuid4())
|
config_rr_id = str(uuid.uuid4())
|
||||||
config_req_metrics = ProducerMetrics(
|
config_req_metrics = ProducerMetrics(
|
||||||
processor=self.id, flow=None, name="config-request",
|
processor=self.id, producer="config-request",
|
||||||
)
|
)
|
||||||
config_resp_metrics = SubscriberMetrics(
|
config_resp_metrics = SubscriberMetrics(
|
||||||
processor=self.id, flow=None, name="config-response",
|
processor=self.id, subscriber="config-response",
|
||||||
)
|
)
|
||||||
return RequestResponse(
|
return RequestResponse(
|
||||||
backend=self.pubsub,
|
backend=self.pubsub,
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ class Processor(WorkspaceProcessor):
|
||||||
|
|
||||||
# Config service client for collection management
|
# Config service client for collection management
|
||||||
config_request_metrics = ProducerMetrics(
|
config_request_metrics = ProducerMetrics(
|
||||||
processor = id, flow = None, name = "config-request"
|
processor=id, producer="config-request",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.config_request_producer = Producer(
|
self.config_request_producer = Producer(
|
||||||
|
|
@ -182,7 +182,7 @@ class Processor(WorkspaceProcessor):
|
||||||
)
|
)
|
||||||
|
|
||||||
config_response_metrics = ConsumerMetrics(
|
config_response_metrics = ConsumerMetrics(
|
||||||
processor = id, flow = None, name = "config-response"
|
processor=id, consumer="config-response",
|
||||||
)
|
)
|
||||||
|
|
||||||
self.config_response_consumer = Consumer(
|
self.config_response_consumer = Consumer(
|
||||||
|
|
@ -258,8 +258,8 @@ class Processor(WorkspaceProcessor):
|
||||||
topic=lib_resp_queue,
|
topic=lib_resp_queue,
|
||||||
schema=LibrarianResponse,
|
schema=LibrarianResponse,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, producer="librarian-response",
|
||||||
name=f"librarian-response-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -268,8 +268,8 @@ class Processor(WorkspaceProcessor):
|
||||||
topic=col_resp_queue,
|
topic=col_resp_queue,
|
||||||
schema=CollectionManagementResponse,
|
schema=CollectionManagementResponse,
|
||||||
metrics=ProducerMetrics(
|
metrics=ProducerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, producer="collection-response",
|
||||||
name=f"collection-response-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -284,8 +284,8 @@ class Processor(WorkspaceProcessor):
|
||||||
self.on_librarian_request, workspace=workspace,
|
self.on_librarian_request, workspace=workspace,
|
||||||
),
|
),
|
||||||
metrics=ConsumerMetrics(
|
metrics=ConsumerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, consumer="librarian-request",
|
||||||
name=f"librarian-request-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -300,8 +300,8 @@ class Processor(WorkspaceProcessor):
|
||||||
self.on_collection_request, workspace=workspace,
|
self.on_collection_request, workspace=workspace,
|
||||||
),
|
),
|
||||||
metrics=ConsumerMetrics(
|
metrics=ConsumerMetrics(
|
||||||
processor=self.id, flow=None,
|
processor=self.id, consumer="collection-request",
|
||||||
name=f"collection-request-{workspace}",
|
workspace=workspace,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ serverless endpoint service. Input is prompt, output is response.
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
from prometheus_client import Histogram
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ OpenAI endpoit service. Input is prompt, output is response.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
from prometheus_client import Histogram
|
|
||||||
from openai import AzureOpenAI, RateLimitError
|
from openai import AzureOpenAI, RateLimitError
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ Input is prompt, output is response.
|
||||||
|
|
||||||
import cohere
|
import cohere
|
||||||
from cohere.errors import TooManyRequestsError, ServiceUnavailableError
|
from cohere.errors import TooManyRequestsError, ServiceUnavailableError
|
||||||
from prometheus_client import Histogram
|
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue