Improve metrics
This commit is contained in:
@@ -22,6 +22,7 @@ from app.services.whatsapp_service import WhatsAppService
|
||||
from app.consumers.po_event_consumer import POEventConsumer
|
||||
from shared.service_base import StandardFastAPIService
|
||||
from shared.clients.tenant_client import TenantServiceClient
|
||||
from shared.monitoring.system_metrics import SystemMetricsCollector
|
||||
import asyncio
|
||||
|
||||
|
||||
@@ -184,6 +185,10 @@ class NotificationService(StandardFastAPIService):
|
||||
self.email_service = EmailService()
|
||||
self.whatsapp_service = WhatsAppService(tenant_client=self.tenant_client)
|
||||
|
||||
# Initialize system metrics collection
|
||||
system_metrics = SystemMetricsCollector("notification")
|
||||
self.logger.info("System metrics collection started")
|
||||
|
||||
# Initialize SSE service
|
||||
self.sse_service = SSEService()
|
||||
await self.sse_service.initialize(settings.REDIS_URL)
|
||||
@@ -271,12 +276,14 @@ class NotificationService(StandardFastAPIService):
|
||||
return {"error": "SSE service not available"}
|
||||
|
||||
# Metrics endpoint
|
||||
@self.app.get("/metrics")
|
||||
async def metrics():
|
||||
"""Prometheus metrics endpoint"""
|
||||
if self.metrics_collector:
|
||||
return self.metrics_collector.get_metrics()
|
||||
return {"metrics": "not_available"}
|
||||
# Note: Metrics are exported via OpenTelemetry OTLP to SigNoz
|
||||
# The /metrics endpoint is not needed as metrics are pushed automatically
|
||||
# @self.app.get("/metrics")
|
||||
# async def metrics():
|
||||
# """Prometheus metrics endpoint"""
|
||||
# if self.metrics_collector:
|
||||
# return self.metrics_collector.get_metrics()
|
||||
# return {"metrics": "not_available"}
|
||||
|
||||
|
||||
# Create service instance
|
||||
|
||||
Reference in New Issue
Block a user