@@ -90,53 +90,38 @@ async def get_prometheus_metrics(request: Request) -> str:
9090 lines = []
9191
9292 # Application info
93- lines .append (
94- f'# HELP ragcache_info Application information'
95- )
96- lines .append (
97- f'# TYPE ragcache_info gauge'
98- )
99- lines .append (
100- f'ragcache_info{{version="0.1.0",environment="{ config .app_env } "}} 1'
101- )
93+ lines .append (f"# HELP ragcache_info Application information" )
94+ lines .append (f"# TYPE ragcache_info gauge" )
95+ lines .append (f'ragcache_info{{version="0.1.0",environment="{ config .app_env } "}} 1' )
10296
10397 # Pipeline metrics
10498 pipeline = metrics .get ("pipeline" , {})
10599 if pipeline :
106- lines .append (f'# HELP ragcache_requests_total Total requests processed' )
107- lines .append (f'# TYPE ragcache_requests_total counter' )
108- lines .append (
109- f'ragcache_requests_total { pipeline .get ("total_requests" , 0 )} '
110- )
111-
112- lines .append (f'# HELP ragcache_cache_hits_total Total cache hits' )
113- lines .append (f'# TYPE ragcache_cache_hits_total counter' )
100+ lines .append (f"# HELP ragcache_requests_total Total requests processed" )
101+ lines .append (f"# TYPE ragcache_requests_total counter" )
102+ lines .append (f'ragcache_requests_total { pipeline .get ("total_requests" , 0 )} ' )
103+
104+ lines .append (f"# HELP ragcache_cache_hits_total Total cache hits" )
105+ lines .append (f"# TYPE ragcache_cache_hits_total counter" )
114106 lines .append (f'ragcache_cache_hits_total { pipeline .get ("cache_hits" , 0 )} ' )
115107
116- lines .append (f'# HELP ragcache_cache_hit_rate Cache hit rate' )
117- lines .append (f'# TYPE ragcache_cache_hit_rate gauge' )
118- lines .append (
119- f'ragcache_cache_hit_rate { pipeline .get ("cache_hit_rate" , 0 )} '
120- )
108+ lines .append (f"# HELP ragcache_cache_hit_rate Cache hit rate" )
109+ lines .append (f"# TYPE ragcache_cache_hit_rate gauge" )
110+ lines .append (f'ragcache_cache_hit_rate { pipeline .get ("cache_hit_rate" , 0 )} ' )
121111
122- lines .append (f'# HELP ragcache_avg_latency_ms Average latency in ms' )
123- lines .append (f'# TYPE ragcache_avg_latency_ms gauge' )
124- lines .append (
125- f'ragcache_avg_latency_ms { pipeline .get ("avg_latency_ms" , 0 )} '
126- )
112+ lines .append (f"# HELP ragcache_avg_latency_ms Average latency in ms" )
113+ lines .append (f"# TYPE ragcache_avg_latency_ms gauge" )
114+ lines .append (f'ragcache_avg_latency_ms { pipeline .get ("avg_latency_ms" , 0 )} ' )
127115
128116 # Redis metrics
129117 cache = metrics .get ("cache" , {})
130118 if cache :
131- lines .append (f' # HELP ragcache_redis_keys Total Redis keys' )
132- lines .append (f' # TYPE ragcache_redis_keys gauge' )
119+ lines .append (f" # HELP ragcache_redis_keys Total Redis keys" )
120+ lines .append (f" # TYPE ragcache_redis_keys gauge" )
133121 lines .append (f'ragcache_redis_keys { cache .get ("total_keys" , 0 )} ' )
134122
135- lines .append (f'# HELP ragcache_redis_memory_bytes Redis memory usage' )
136- lines .append (f'# TYPE ragcache_redis_memory_bytes gauge' )
137- lines .append (
138- f'ragcache_redis_memory_bytes { cache .get ("memory_used_bytes" , 0 )} '
139- )
123+ lines .append (f"# HELP ragcache_redis_memory_bytes Redis memory usage" )
124+ lines .append (f"# TYPE ragcache_redis_memory_bytes gauge" )
125+ lines .append (f'ragcache_redis_memory_bytes { cache .get ("memory_used_bytes" , 0 )} ' )
140126
141127 return "\n " .join (lines )
142-
0 commit comments