@@ -54,6 +54,7 @@ const searchFilter = {
54
54
* @param cb - The callback triggered after the negotiation.
55
55
*/
56
56
function _negotiateProtocolVersion ( client : any , logger : werelogs . Logger , cb : any ) {
57
+ const startDate = Date . now ( ) ;
57
58
return client . kmip . request ( logger , 'Discover Versions' , [
58
59
KMIP . Structure ( 'Protocol Version' , [
59
60
KMIP . Integer ( 'Protocol Version Major' , 1 ) ,
@@ -68,10 +69,14 @@ function _negotiateProtocolVersion(client: any, logger: werelogs.Logger, cb: any
68
69
KMIP . Integer ( 'Protocol Version Minor' , 2 ) ,
69
70
] ) ,
70
71
] , ( err , response ) => {
72
+ const kmipLog = {
73
+ host : client . host ,
74
+ latencyMs : Date . now ( ) - startDate
75
+ } ;
71
76
if ( err ) {
72
77
const error = arsenalErrorKMIP ( err ) ;
73
78
logger . error ( 'KMIP::negotiateProtocolVersion' ,
74
- { error,
79
+ { error, kmip : kmipLog ,
75
80
vendorIdentification : client . vendorIdentification } ) ;
76
81
return cb ( error ) ;
77
82
}
@@ -83,7 +88,7 @@ function _negotiateProtocolVersion(client: any, logger: werelogs.Logger, cb: any
83
88
majorVersions . length !== minorVersions . length ) {
84
89
const error = arsenalErrorKMIP ( 'No suitable protocol version' ) ;
85
90
logger . error ( 'KMIP::negotiateProtocolVersion' ,
86
- { error,
91
+ { error, kmip : kmipLog ,
87
92
vendorIdentification : client . vendorIdentification } ) ;
88
93
return cb ( error ) ;
89
94
}
@@ -100,13 +105,18 @@ function _negotiateProtocolVersion(client: any, logger: werelogs.Logger, cb: any
100
105
* @param cb - The callback triggered after the extension mapping
101
106
*/
102
107
function _mapExtensions ( client : any , logger : werelogs . Logger , cb : any ) {
108
+ const startDate = Date . now ( ) ;
103
109
return client . kmip . request ( logger , 'Query' , [
104
110
KMIP . Enumeration ( 'Query Function' , 'Query Extension Map' ) ,
105
111
] , ( err , response ) => {
112
+ const kmipLog = {
113
+ host : client . host ,
114
+ latencyMs : Date . now ( ) - startDate
115
+ } ;
106
116
if ( err ) {
107
117
const error = arsenalErrorKMIP ( err ) ;
108
118
logger . error ( 'KMIP::mapExtensions' ,
109
- { error,
119
+ { error, kmip : kmipLog ,
110
120
vendorIdentification : client . vendorIdentification } ) ;
111
121
return cb ( error ) ;
112
122
}
@@ -115,7 +125,7 @@ function _mapExtensions(client: any, logger: werelogs.Logger, cb: any) {
115
125
if ( extensionNames . length !== extensionTags . length ) {
116
126
const error = arsenalErrorKMIP ( 'Inconsistent extension list' ) ;
117
127
logger . error ( 'KMIP::mapExtensions' ,
118
- { error,
128
+ { error, kmip : kmipLog ,
119
129
vendorIdentification : client . vendorIdentification } ) ;
120
130
return cb ( error ) ;
121
131
}
@@ -133,13 +143,18 @@ function _mapExtensions(client: any, logger: werelogs.Logger, cb: any) {
133
143
* @param cb - The callback triggered after the information discovery
134
144
*/
135
145
function _queryServerInformation ( client : any , logger : werelogs . Logger , cb : any ) {
146
+ const startDate = Date . now ( ) ;
136
147
client . kmip . request ( logger , 'Query' , [
137
148
KMIP . Enumeration ( 'Query Function' , 'Query Server Information' ) ,
138
149
] , ( err , response ) => {
150
+ const kmipLog = {
151
+ host : client . host ,
152
+ latencyMs : Date . now ( ) - startDate
153
+ } ;
139
154
if ( err ) {
140
155
const error = arsenalErrorKMIP ( err ) ;
141
156
logger . warn ( 'KMIP::queryServerInformation' ,
142
- { error } ) ;
157
+ { error, kmip : kmipLog } ) ;
143
158
/* no error returned, caller can keep going */
144
159
return cb ( ) ;
145
160
}
@@ -151,7 +166,8 @@ function _queryServerInformation(client: any, logger: werelogs.Logger, cb: any)
151
166
logger . info ( 'KMIP Server identified' ,
152
167
{ vendorIdentification : client . vendorIdentification ,
153
168
serverInformation : client . serverInformation ,
154
- negotiatedProtocolVersion : client . kmip . protocolVersion } ) ;
169
+ negotiatedProtocolVersion : client . kmip . protocolVersion ,
170
+ kmip : kmipLog } ) ;
155
171
return cb ( ) ;
156
172
} ) ;
157
173
}
@@ -167,14 +183,19 @@ function _queryServerInformation(client: any, logger: werelogs.Logger, cb: any)
167
183
* @param cb - The callback triggered after the information discovery
168
184
*/
169
185
function _queryOperationsAndObjects ( client : any , logger : werelogs . Logger , cb : any ) {
186
+ const startDate = Date . now ( ) ;
170
187
return client . kmip . request ( logger , 'Query' , [
171
188
KMIP . Enumeration ( 'Query Function' , 'Query Operations' ) ,
172
189
KMIP . Enumeration ( 'Query Function' , 'Query Objects' ) ,
173
190
] , ( err , response ) => {
191
+ const kmipLog = {
192
+ host : client . host ,
193
+ latencyMs : Date . now ( ) - startDate
194
+ } ;
174
195
if ( err ) {
175
196
const error = arsenalErrorKMIP ( err ) ;
176
197
logger . error ( 'KMIP::queryOperationsAndObjects' ,
177
- { error,
198
+ { error, kmip : kmipLog ,
178
199
vendorIdentification : client . vendorIdentification } ) ;
179
200
return cb ( error ) ;
180
201
}
@@ -205,10 +226,12 @@ function _queryOperationsAndObjects(client: any, logger: werelogs.Logger, cb: an
205
226
supportsEncrypt, supportsDecrypt,
206
227
supportsActivate, supportsRevoke,
207
228
supportsCreate, supportsDestroy,
208
- supportsQuery, supportsSymmetricKeys } ) ;
229
+ supportsQuery, supportsSymmetricKeys,
230
+ kmip : kmipLog } ) ;
209
231
} else {
210
232
logger . info ( 'KMIP Server provides the necessary feature set' ,
211
- { vendorIdentification : client . vendorIdentification } ) ;
233
+ { vendorIdentification : client . vendorIdentification ,
234
+ kmip : kmipLog } ) ;
212
235
}
213
236
return cb ( ) ;
214
237
} ) ;
@@ -219,6 +242,7 @@ export default class Client implements KMSInterface {
219
242
vendorIdentification : string ;
220
243
serverInformation : any [ ] ;
221
244
kmip : KMIP ;
245
+ host : string ;
222
246
223
247
/**
224
248
* Construct a high level KMIP driver suitable for cloudserver
@@ -255,6 +279,7 @@ export default class Client implements KMSInterface {
255
279
CodecClass : any ,
256
280
TransportClass : any ,
257
281
) {
282
+ this . host = options . kmip . transport . tls . host ;
258
283
this . options = options . kmip . client || { } ;
259
284
this . vendorIdentification = '' ;
260
285
this . serverInformation = [ ] ;
@@ -567,20 +592,23 @@ export default class Client implements KMSInterface {
567
592
}
568
593
569
594
healthcheck ( logger , cb ) {
595
+ const kmipLog = { host : this . host } ;
570
596
// the bucket does not have to exist, just passing a common bucket name here
571
597
this . createBucketKey ( 'kmip-healthcheck-test-bucket' , logger , ( err , bucketKeyId ) => {
572
598
if ( err ) {
573
599
logger . error ( 'KMIP::healthcheck: failure to create a test bucket key' , {
574
- error : err ,
600
+ error : err , kmip : kmipLog ,
575
601
} ) ;
576
602
return cb ( err ) ;
577
603
}
578
- logger . debug ( 'KMIP::healthcheck: success creating a test bucket key' ) ;
604
+ logger . debug ( 'KMIP::healthcheck: success creating a test bucket key' ,
605
+ { kmip : kmipLog } ) ;
579
606
this . destroyBucketKey ( bucketKeyId , logger , err => {
580
607
if ( err ) {
581
608
logger . error ( 'KMIP::healthcheck: failure to remove the test bucket key' , {
582
609
bucketKeyId,
583
610
error : err ,
611
+ kmip : kmipLog ,
584
612
} ) ;
585
613
}
586
614
} ) ;
0 commit comments