@@ -20,7 +20,7 @@ public IngestionMetrics(IMeterFactory meterFactory)
2020
2121 batchDuration = meter . CreateHistogram < double > ( BatchDurationInstrumentName , unit : "seconds" , "Message batch processing duration in seconds" ) ;
2222 ingestionDuration = meter . CreateHistogram < double > ( MessageDurationInstrumentName , unit : "seconds" , description : "Audit message processing duration in seconds" ) ;
23- consecutiveBatchFailureGauge = meter . CreateGauge < long > ( $ "{ InstrumentPrefix } .consecutive_batch_failure_total", description : "Consecutive audit ingestion batch failure" ) ;
23+ consecutiveBatchFailureGauge = meter . CreateObservableGauge ( $ "{ InstrumentPrefix } .consecutive_batch_failure_total", ( ) => consecutiveBatchFailures , description : "Consecutive audit ingestion batch failure" ) ;
2424 failureCounter = meter . CreateCounter < long > ( $ "{ InstrumentPrefix } .failures_total", description : "Audit ingestion failure count" ) ;
2525 }
2626
@@ -56,14 +56,15 @@ void RecordBatchOutcome(bool success)
5656 {
5757 consecutiveBatchFailures ++ ;
5858 }
59-
60- consecutiveBatchFailureGauge . Record ( consecutiveBatchFailures ) ;
6159 }
6260
6361 long consecutiveBatchFailures ;
6462
6563 readonly Histogram < double > batchDuration ;
66- readonly Gauge < long > consecutiveBatchFailureGauge ;
64+ #pragma warning disable IDE0052
65+ // this can be changed to Gauge<T> once we can use the latest version of System.Diagnostics.DiagnosticSource
66+ readonly ObservableGauge < long > consecutiveBatchFailureGauge ;
67+ #pragma warning restore IDE0052
6768 readonly Histogram < double > ingestionDuration ;
6869 readonly Counter < long > failureCounter ;
6970
0 commit comments