1+ use crate :: log;
12use anyhow:: Result ;
23use futures:: future:: join_all;
34use std:: collections:: HashMap ;
@@ -30,9 +31,9 @@ pub async fn get_envs(env_vars: HashMap<String, String>) -> Result<HashMap<Strin
3031 results. insert ( key, value) ;
3132 } ) ;
3233 }
33- Err ( error) => eprintln ! ( "[crypteia] ssm: Parameter error {err} ", err = error) ,
34+ Err ( error) => log :: cloudwatch_metric ( " ssm" , " error", true , Some ( error. to_string ( ) ) ) ,
3435 } ,
35- Err ( error) => eprintln ! ( "[crypteia] ssm: JoinError {err}" , err = error) ,
36+ Err ( error) => log :: cloudwatch_metric ( " ssm" , "error" , true , Some ( error. to_string ( ) ) ) ,
3637 }
3738 }
3839 Ok ( results)
@@ -57,9 +58,14 @@ async fn ssm_get_parameter(
5758 }
5859 }
5960 Err ( error) => {
60- eprintln ! (
61- "[crypteia] ssm: Error calling ssm:GetParameter. Environment variable: {name} Path: {path} Error: {err}" ,
62- err = error
61+ log:: cloudwatch_metric (
62+ "ssm" ,
63+ "error" ,
64+ true ,
65+ Some ( format ! (
66+ "Error calling ssm:GetParameter. Environment variable: {} Path: {} Error: {}" ,
67+ name, path, error
68+ ) ) ,
6369 ) ;
6470 }
6571 }
@@ -100,9 +106,14 @@ async fn ssm_get_parameters_by_path(
100106 token = response. next_token ;
101107 }
102108 Err ( error) => {
103- eprintln ! (
104- "[crypteia] ssm: Error calling ssm:GetParametersByPath. Environment variable: {name} Path: {path} Error: {err}" ,
105- err = error
109+ log:: cloudwatch_metric (
110+ "ssm" ,
111+ "error" ,
112+ true ,
113+ Some ( format ! (
114+ "Error calling ssm:GetParametersByPath. Environment variable: {} Path: {} Error: {}" ,
115+ name, path, error
116+ ) ) ,
106117 ) ;
107118 break ;
108119 }
0 commit comments