@@ -11,16 +11,17 @@ public class IngestionMetrics
1111{
1212 public const string MeterName = "Particular.ServiceControl.Audit" ;
1313
14+ public static readonly string BatchDurationInstrumentName = $ "{ InstrumentPrefix } .batch_duration_seconds";
15+ public static readonly string MessageDurationInstrumentName = $ "{ InstrumentPrefix } .message_duration_seconds";
16+
1417 public IngestionMetrics ( IMeterFactory meterFactory )
1518 {
1619 var meter = meterFactory . Create ( MeterName , MeterVersion ) ;
1720
18- var durationBucketsInSeconds = new InstrumentAdvice < double > { HistogramBucketBoundaries = [ 0.01 , 0.05 , 0.1 , 0.5 , 1 , 5 ] } ;
19-
20- batchDuration = meter . CreateHistogram ( CreateInstrumentName ( "batch_duration_seconds" ) , unit : "seconds" , "Message batch processing duration in seconds" , advice : durationBucketsInSeconds ) ;
21- ingestionDuration = meter . CreateHistogram ( CreateInstrumentName ( "message_duration_seconds" ) , unit : "seconds" , description : "Audit message processing duration in seconds" , advice : durationBucketsInSeconds ) ;
22- consecutiveBatchFailureGauge = meter . CreateGauge < long > ( CreateInstrumentName ( "consecutive_batch_failure_total" ) , description : "Consecutive audit ingestion batch failure" ) ;
23- failureCounter = meter . CreateCounter < long > ( CreateInstrumentName ( "failures_total" ) , description : "Audit ingestion failure count" ) ;
21+ batchDuration = meter . CreateHistogram < double > ( BatchDurationInstrumentName , unit : "seconds" , "Message batch processing duration in seconds" ) ;
22+ 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" ) ;
24+ failureCounter = meter . CreateCounter < long > ( $ "{ InstrumentPrefix } .failures_total", description : "Audit ingestion failure count" ) ;
2425 }
2526
2627 public MessageMetrics BeginIngestion ( MessageContext messageContext ) => new ( messageContext , ingestionDuration ) ;
@@ -59,8 +60,6 @@ void RecordBatchOutcome(bool success)
5960 consecutiveBatchFailureGauge . Record ( consecutiveBatchFailures ) ;
6061 }
6162
62- static string CreateInstrumentName ( string instrumentName ) => $ "sc.audit.ingestion.{ instrumentName . ToLower ( ) } ";
63-
6463 long consecutiveBatchFailures ;
6564
6665 readonly Histogram < double > batchDuration ;
@@ -69,6 +68,7 @@ void RecordBatchOutcome(bool success)
6968 readonly Counter < long > failureCounter ;
7069
7170 const string MeterVersion = "0.1.0" ;
71+ const string InstrumentPrefix = "sc.audit.ingestion" ;
7272
7373 static readonly string SagaUpdateMessageType = typeof ( SagaUpdatedMessage ) . FullName ;
7474}
0 commit comments