@@ -4,9 +4,8 @@ use crate::{
44 log:: { ENCRYPT , ZERO_KMS } ,
55 postgresql:: { Column , KeysetIdentifier } ,
66 prometheus:: {
7- KEYSET_CIPHER_CACHE_HITS_TOTAL , KEYSET_CIPHER_CACHE_HITS_TOTAL ,
8- KEYSET_CIPHER_CACHE_MISS_TOTAL , KEYSET_CIPHER_INIT_DURATION_SECONDS ,
9- KEYSET_CIPHER_INIT_DURATION_SECONDS , KEYSET_CIPHER_INIT_TOTAL , KEYSET_CIPHER_INIT_TOTAL ,
7+ KEYSET_CIPHER_CACHE_HITS_TOTAL , KEYSET_CIPHER_CACHE_MISS_TOTAL ,
8+ KEYSET_CIPHER_INIT_DURATION_SECONDS , KEYSET_CIPHER_INIT_TOTAL ,
109 } ,
1110 proxy:: EncryptionService ,
1211} ;
@@ -97,17 +96,18 @@ impl ZeroKms {
9796 let identified_by = keyset_id. as_ref ( ) . map ( |id| id. 0 . clone ( ) ) ;
9897
9998 let start = Instant :: now ( ) ;
100- match ScopedCipher :: init ( zerokms_client, identified_by) . await {
101- Ok ( cipher) => {
102- let init_duration = start. elapsed ( ) ;
103- let init_duration_ms = init_duration. as_millis ( ) ;
99+ let result = ScopedCipher :: init ( zerokms_client, identified_by) . await ;
100+ let init_duration = start. elapsed ( ) ;
101+ let init_duration_ms = init_duration. as_millis ( ) ;
104102
105- histogram ! ( KEYSET_CIPHER_INIT_DURATION_SECONDS ) . record ( init_duration. as_secs_f64 ( ) ) ;
103+ histogram ! ( KEYSET_CIPHER_INIT_DURATION_SECONDS ) . record ( init_duration. as_secs_f64 ( ) ) ;
106104
107- if init_duration > Duration :: from_secs ( 1 ) {
108- warn ! ( target: ZERO_KMS , msg = "Slow ScopedCipher initialization" , ?keyset_id, init_duration_ms) ;
109- }
105+ if init_duration > Duration :: from_secs ( 1 ) {
106+ warn ! ( target: ZERO_KMS , msg = "Slow ScopedCipher initialization" , ?keyset_id, init_duration_ms) ;
107+ }
110108
109+ match result {
110+ Ok ( cipher) => {
111111 let arc_cipher = Arc :: new ( cipher) ;
112112
113113 counter ! ( KEYSET_CIPHER_INIT_TOTAL ) . increment ( 1 ) ;
@@ -130,11 +130,6 @@ impl ZeroKms {
130130 Ok ( arc_cipher)
131131 }
132132 Err ( err) => {
133- let init_duration = start. elapsed ( ) ;
134- let init_duration_ms = init_duration. as_millis ( ) ;
135-
136- histogram ! ( KEYSET_CIPHER_INIT_DURATION_SECONDS ) . record ( init_duration. as_secs_f64 ( ) ) ;
137-
138133 debug ! ( target: ZERO_KMS , msg = "Error initializing ZeroKMS ScopedCipher" , error = err. to_string( ) , init_duration_ms) ;
139134 warn ! (
140135 msg = "Error initializing ZeroKMS" ,
0 commit comments