@@ -231,7 +231,7 @@ pub static TOTAL_EVENTS_INGESTED_BY_DATE: Lazy<IntCounterVec> = Lazy::new(|| {
231231 IntCounterVec :: new (
232232 Opts :: new (
233233 "total_events_ingested_by_date" ,
234- "Total events ingested by date (Counter for billing) " ,
234+ "Total events ingested by date" ,
235235 )
236236 . namespace ( METRICS_NAMESPACE ) ,
237237 & [ "date" ] ,
@@ -243,7 +243,7 @@ pub static TOTAL_EVENTS_INGESTED_SIZE_BY_DATE: Lazy<IntCounterVec> = Lazy::new(|
243243 IntCounterVec :: new (
244244 Opts :: new (
245245 "total_events_ingested_size_by_date" ,
246- "Total events ingested size in bytes by date (Counter for billing) " ,
246+ "Total events ingested size in bytes by date" ,
247247 )
248248 . namespace ( METRICS_NAMESPACE ) ,
249249 & [ "date" ] ,
@@ -255,7 +255,7 @@ pub static TOTAL_PARQUETS_STORED_BY_DATE: Lazy<IntCounterVec> = Lazy::new(|| {
255255 IntCounterVec :: new (
256256 Opts :: new (
257257 "total_parquets_stored_by_date" ,
258- "Total parquet files stored by date (Counter for billing) " ,
258+ "Total parquet files stored by date" ,
259259 )
260260 . namespace ( METRICS_NAMESPACE ) ,
261261 & [ "date" ] ,
@@ -267,7 +267,7 @@ pub static TOTAL_PARQUETS_STORED_SIZE_BY_DATE: Lazy<IntCounterVec> = Lazy::new(|
267267 IntCounterVec :: new (
268268 Opts :: new (
269269 "total_parquets_stored_size_by_date" ,
270- "Total parquet files stored size in bytes by date (Counter for billing) " ,
270+ "Total parquet files stored size in bytes by date" ,
271271 )
272272 . namespace ( METRICS_NAMESPACE ) ,
273273 & [ "date" ] ,
@@ -277,11 +277,8 @@ pub static TOTAL_PARQUETS_STORED_SIZE_BY_DATE: Lazy<IntCounterVec> = Lazy::new(|
277277
278278pub static TOTAL_QUERY_CALLS_BY_DATE : Lazy < IntCounterVec > = Lazy :: new ( || {
279279 IntCounterVec :: new (
280- Opts :: new (
281- "total_query_calls_by_date" ,
282- "Total query calls by date (Counter for billing)" ,
283- )
284- . namespace ( METRICS_NAMESPACE ) ,
280+ Opts :: new ( "total_query_calls_by_date" , "Total query calls by date" )
281+ . namespace ( METRICS_NAMESPACE ) ,
285282 & [ "date" ] ,
286283 )
287284 . expect ( "metric can be created" )
@@ -291,7 +288,7 @@ pub static TOTAL_FILES_SCANNED_IN_QUERY_BY_DATE: Lazy<IntCounterVec> = Lazy::new
291288 IntCounterVec :: new (
292289 Opts :: new (
293290 "total_files_scanned_in_query_by_date" ,
294- "Total files scanned in queries by date (Counter for billing) " ,
291+ "Total files scanned in queries by date" ,
295292 )
296293 . namespace ( METRICS_NAMESPACE ) ,
297294 & [ "date" ] ,
@@ -303,7 +300,7 @@ pub static TOTAL_BYTES_SCANNED_IN_QUERY_BY_DATE: Lazy<IntCounterVec> = Lazy::new
303300 IntCounterVec :: new (
304301 Opts :: new (
305302 "total_bytes_scanned_in_query_by_date" ,
306- "Total bytes scanned in queries by date (Counter for billing) " ,
303+ "Total bytes scanned in queries by date" ,
307304 )
308305 . namespace ( METRICS_NAMESPACE ) ,
309306 & [ "date" ] ,
@@ -315,7 +312,7 @@ pub static TOTAL_OBJECT_STORE_CALLS_BY_DATE: Lazy<IntCounterVec> = Lazy::new(||
315312 IntCounterVec :: new (
316313 Opts :: new (
317314 "total_object_store_calls_by_date" ,
318- "Total object store calls by date (Counter for billing) " ,
315+ "Total object store calls by date" ,
319316 )
320317 . namespace ( METRICS_NAMESPACE ) ,
321318 & [ "provider" , "method" , "date" ] ,
@@ -328,14 +325,38 @@ pub static TOTAL_FILES_SCANNED_IN_OBJECT_STORE_CALLS_BY_DATE: Lazy<IntCounterVec
328325 IntCounterVec :: new (
329326 Opts :: new (
330327 "total_files_scanned_in_object_store_calls_by_date" ,
331- "Total files scanned in object store calls by date (Counter for billing) " ,
328+ "Total files scanned in object store calls by date" ,
332329 )
333330 . namespace ( METRICS_NAMESPACE ) ,
334331 & [ "provider" , "method" , "date" ] ,
335332 )
336333 . expect ( "metric can be created" )
337334 } ) ;
338335
336+ pub static TOTAL_INPUT_LLM_TOKENS_BY_DATE : Lazy < IntCounterVec > = Lazy :: new ( || {
337+ IntCounterVec :: new (
338+ Opts :: new (
339+ "total_input_llm_tokens_by_date" ,
340+ "Total input LLM tokens used by date" ,
341+ )
342+ . namespace ( METRICS_NAMESPACE ) ,
343+ & [ "provider" , "model" , "date" ] ,
344+ )
345+ . expect ( "metric can be created" )
346+ } ) ;
347+
348+ pub static TOTAL_OUTPUT_LLM_TOKENS_BY_DATE : Lazy < IntCounterVec > = Lazy :: new ( || {
349+ IntCounterVec :: new (
350+ Opts :: new (
351+ "total_output_llm_tokens_by_date" ,
352+ "Total output LLM tokens used by date" ,
353+ )
354+ . namespace ( METRICS_NAMESPACE ) ,
355+ & [ "provider" , "model" , "date" ] ,
356+ )
357+ . expect ( "metric can be created" )
358+ } ) ;
359+
339360// Cluster Billing Metrics - Gauge type metrics for cluster-wide aggregated billing data
340361pub static TOTAL_CLUSTER_EVENTS_INGESTED_BY_DATE : Lazy < IntGaugeVec > = Lazy :: new ( || {
341362 IntGaugeVec :: new (
@@ -544,6 +565,12 @@ fn custom_metrics(registry: &Registry) {
544565 TOTAL_FILES_SCANNED_IN_OBJECT_STORE_CALLS_BY_DATE . clone ( ) ,
545566 ) )
546567 . expect ( "metric can be registered" ) ;
568+ registry
569+ . register ( Box :: new ( TOTAL_INPUT_LLM_TOKENS_BY_DATE . clone ( ) ) )
570+ . expect ( "metric can be registered" ) ;
571+ registry
572+ . register ( Box :: new ( TOTAL_OUTPUT_LLM_TOKENS_BY_DATE . clone ( ) ) )
573+ . expect ( "metric can be registered" ) ;
547574 // Register cluster billing metrics
548575 registry
549576 . register ( Box :: new ( TOTAL_CLUSTER_EVENTS_INGESTED_BY_DATE . clone ( ) ) )
@@ -698,6 +725,18 @@ pub fn increment_files_scanned_in_object_store_calls_by_date(
698725 . inc_by ( count) ;
699726}
700727
728+ pub fn increment_input_llm_tokens_by_date ( provider : & str , model : & str , tokens : u64 , date : & str ) {
729+ TOTAL_INPUT_LLM_TOKENS_BY_DATE
730+ . with_label_values ( & [ provider, model, date] )
731+ . inc_by ( tokens) ;
732+ }
733+
734+ pub fn increment_output_llm_tokens_by_date ( provider : & str , model : & str , tokens : u64 , date : & str ) {
735+ TOTAL_OUTPUT_LLM_TOKENS_BY_DATE
736+ . with_label_values ( & [ provider, model, date] )
737+ . inc_by ( tokens) ;
738+ }
739+
701740use actix_web:: HttpResponse ;
702741
703742pub async fn get ( ) -> Result < impl Responder , MetricsError > {
0 commit comments