5757 appenderNextIndex metric.Int64Gauge
5858 appenderSignedSize metric.Int64Gauge
5959 appenderWitnessedSize metric.Int64Gauge
60+ appenderWitnessRequests metric.Int64Counter
6061
6162 followerEntriesProcessed metric.Int64Gauge
6263 followerLag metric.Int64Gauge
@@ -139,6 +140,7 @@ func init() {
139140 if err != nil {
140141 klog .Exitf ("Failed to create followerEntriesProcessed metric: %v" , err )
141142 }
143+
142144 followerLag , err = meter .Int64Gauge (
143145 "tessera.follower.lag" ,
144146 metric .WithDescription ("Number of unprocessed entries in the current integrated tree" ),
@@ -147,6 +149,14 @@ func init() {
147149 klog .Exitf ("Failed to create followerLag metric: %v" , err )
148150 }
149151
152+ appenderWitnessRequests , err = meter .Int64Counter (
153+ "tessera.appender.witness.requests" ,
154+ metric .WithDescription ("Number of attempts to witness a log checkpoint" ),
155+ metric .WithUnit ("{call}" ))
156+ if err != nil {
157+ klog .Exitf ("Failed to create appenderWitnessRequests metric: %v" , err )
158+ }
159+
150160}
151161
152162// Add adds a new entry to be sequenced.
@@ -523,16 +533,21 @@ func (o AppendOptions) CheckpointPublisher(lr LogReader, httpClient *http.Client
523533 }
524534 appenderSignedSize .Record (ctx , otel .Clamp64 (size ))
525535
536+ witAttr := []attribute.KeyValue {}
526537 cp , err = wg .Witness (ctx , cp )
527538 if err != nil {
528539 if ! o .witnessOpts .FailOpen {
540+ appenderWitnessRequests .Add (ctx , 1 , metric .WithAttributes (attribute .String ("error.type" , "failed" )))
529541 return nil , err
530542 }
531543 klog .Warningf ("WitnessGateway: failing-open despite error: %v" , err )
544+ witAttr = append (witAttr , attribute .String ("error.type" , "failed_open" ))
532545 }
546+
547+ appenderWitnessRequests .Add (ctx , 1 , metric .WithAttributes (witAttr ... ))
533548 appenderWitnessedSize .Record (ctx , otel .Clamp64 (size ))
534549
535- return cp , err
550+ return cp , nil
536551 }
537552}
538553
0 commit comments