@@ -33,6 +33,11 @@ pub(crate) const ROUTER_PARSE_ERRORS: &str = "ajj.router.parse_errors";
3333pub ( crate ) const ROUTER_PARSE_ERRORS_HELP : & str =
3434 "Number of parse errors encountered by ajj router methods. This implies no response was sent." ;
3535
36+ /// Metric for counting method not found errors.
37+ pub ( crate ) const ROUTER_METHOD_NOT_FOUND : & str = "ajj.router.method_not_found" ;
38+ pub ( crate ) const ROUTER_METHOD_NOT_FOUND_HELP : & str =
39+ "Number of times ajj router methods encountered a method not found error. This implies a response was sent." ;
40+
3641static DESCRIBE : LazyLock < ( ) > = LazyLock :: new ( || {
3742 metrics:: describe_counter!( ROUTER_CALLS , metrics:: Unit :: Count , ROUTER_CALLS_HELP ) ;
3843 metrics:: describe_counter!( ROUTER_ERRORS , metrics:: Unit :: Count , ROUTER_ERRORS_HELP ) ;
@@ -56,6 +61,11 @@ static DESCRIBE: LazyLock<()> = LazyLock::new(|| {
5661 metrics:: Unit :: Count ,
5762 ROUTER_PARSE_ERRORS_HELP
5863 ) ;
64+ metrics:: describe_counter!(
65+ ROUTER_METHOD_NOT_FOUND ,
66+ metrics:: Unit :: Count ,
67+ ROUTER_METHOD_NOT_FOUND_HELP
68+ ) ;
5969} ) ;
6070
6171/// Get or register a counter for calls to a specific service and method.
@@ -168,3 +178,20 @@ pub(crate) fn record_parse_error(service_name: &'static str) {
168178 let counter = parse_errors ( service_name) ;
169179 counter. increment ( 1 ) ;
170180}
181+
182+ /// Get or register a counter for method not found errors.
183+ pub ( crate ) fn method_not_found_errors ( service_name : & ' static str , method : & str ) -> Counter {
184+ let _ = & DESCRIBE ;
185+ metrics:: counter!( ROUTER_METHOD_NOT_FOUND , "service" => service_name. to_string( ) , "method" => method. to_string( ) )
186+ }
187+
188+ /// Record a method not found error.
189+ pub ( crate ) fn record_method_not_found (
190+ response_sent : bool ,
191+ service_name : & ' static str ,
192+ method : & str ,
193+ ) {
194+ let counter = method_not_found_errors ( service_name, method) ;
195+ counter. increment ( 1 ) ;
196+ record_output ( response_sent, service_name, method) ;
197+ }
0 commit comments