@@ -15,20 +15,13 @@ use crate::{get_config, CardanoNodePort, Config, Error, State};
1515
1616#[ derive( Clone ) ]
1717pub struct Metrics {
18- pub dcu : IntCounterVec ,
1918 pub usage : IntCounterVec ,
2019 pub reconcile_failures : IntCounterVec ,
2120 pub metrics_failures : IntCounterVec ,
2221}
2322
2423impl Default for Metrics {
2524 fn default ( ) -> Self {
26- let dcu = IntCounterVec :: new (
27- opts ! ( "dmtr_consumed_dcus" , "quantity of dcu consumed" , ) ,
28- & [ "project" , "service" , "service_type" , "tenancy" ] ,
29- )
30- . unwrap ( ) ;
31-
3225 let usage = IntCounterVec :: new (
3326 opts ! ( "usage" , "Feature usage" , ) ,
3427 & [ "feature" , "project" , "resource_name" , "tier" ] ,
@@ -54,7 +47,6 @@ impl Default for Metrics {
5447 . unwrap ( ) ;
5548
5649 Metrics {
57- dcu,
5850 usage,
5951 reconcile_failures,
6052 metrics_failures,
@@ -66,7 +58,6 @@ impl Metrics {
6658 pub fn register ( self , registry : & Registry ) -> Result < Self , prometheus:: Error > {
6759 registry. register ( Box :: new ( self . reconcile_failures . clone ( ) ) ) ?;
6860 registry. register ( Box :: new ( self . metrics_failures . clone ( ) ) ) ?;
69- registry. register ( Box :: new ( self . dcu . clone ( ) ) ) ?;
7061 registry. register ( Box :: new ( self . usage . clone ( ) ) ) ?;
7162
7263 Ok ( self )
@@ -84,22 +75,6 @@ impl Metrics {
8475 . inc ( )
8576 }
8677
87- pub fn count_dcu_consumed ( & self , project : & str , network : & str , dcu : f64 ) {
88- let service = format ! ( "{}-{}" , CardanoNodePort :: kind( & ( ) ) , network) ;
89- let service_type = format ! (
90- "{}.{}" ,
91- CardanoNodePort :: plural( & ( ) ) ,
92- CardanoNodePort :: group( & ( ) )
93- ) ;
94- let tenancy = "proxy" ;
95-
96- let dcu: u64 = dcu. ceil ( ) as u64 ;
97-
98- self . dcu
99- . with_label_values :: < & str > ( & [ project, & service, & service_type, tenancy] )
100- . inc_by ( dcu) ;
101- }
102-
10378 pub fn count_usage ( & self , project : & str , resource_name : & str , tier : & str , value : f64 ) {
10479 let feature = & CardanoNodePort :: kind ( & ( ) ) ;
10580 let value: u64 = value. ceil ( ) as u64 ;
@@ -228,27 +203,8 @@ pub fn run_metrics_collector(state: Arc<State>) {
228203 warn ! ( instance, "invalid network to the regex" ) ;
229204 continue ;
230205 }
231- let network_captures = network_captures. unwrap ( ) ;
232- let network = network_captures. get ( 1 ) . unwrap ( ) . as_str ( ) ;
233-
234- let dcu_per_second = config. dcu_per_second . get ( network) ;
235- if dcu_per_second. is_none ( ) {
236- let error = Error :: ConfigError ( format ! (
237- "dcu_per_package not configured to {} network" ,
238- network
239- ) ) ;
240- error ! ( error = error. to_string( ) ) ;
241- state. metrics . metrics_failure ( & error) ;
242- continue ;
243- }
244-
245- let dcu_per_second = dcu_per_second. unwrap ( ) ;
246206 let total_exec_time = result. value * ( interval as f64 ) ;
247207
248- let dcu = total_exec_time * dcu_per_second;
249-
250- state. metrics . count_dcu_consumed ( project, network, dcu) ;
251-
252208 if let Some ( tier) = result. metric . tier {
253209 state
254210 . metrics
0 commit comments