public ThrottlingMetrics( [NotNull] IThrottlingProvider provider, [NotNull] IMetricContext metricContext, [NotNull] ThrottlingMetricsOptions options) { eventSubscription = provider.Subscribe(this as IObserver <IThrottlingEvent>); resultSubscription = provider.Subscribe(this as IObserver <IThrottlingResult>); var integerGaugeConfig = new IntegerGaugeConfig { InitialValue = 0, ResetOnScrape = true }; var propertiesGaugeConfig = new IntegerGaugeConfig { InitialValue = 0, ResetOnScrape = true, SendZeroValues = false }; var floatingGaugeConfig = new FloatingGaugeConfig { InitialValue = 0, ResetOnScrape = true }; var summaryConfig = new SummaryConfig(); var counterConfig = new CounterConfig(); if (options.ScrapePeriod != null) { integerGaugeConfig.ScrapePeriod = options.ScrapePeriod; floatingGaugeConfig.ScrapePeriod = options.ScrapePeriod; summaryConfig.ScrapePeriod = options.ScrapePeriod; counterConfig.ScrapePeriod = options.ScrapePeriod; counterConfig.AggregationParameters = new Dictionary <string, string>().SetAggregationPeriod(options.ScrapePeriod.Value); } waitTimeSummary = metricContext.CreateSummary("queueWaitTime", summaryConfig); rejectionCounter = metricContext.CreateCounter("rejectionsCount", "status", counterConfig); maxCapacityLimit = metricContext.CreateIntegerGauge("maxCapacityLimit", integerGaugeConfig); maxCapacityConsumed = metricContext.CreateIntegerGauge("maxCapacityConsumed", integerGaugeConfig); maxCapacityUtilization = metricContext.CreateFloatingGauge("maxCapacityUtilization", floatingGaugeConfig); maxQueueLimit = metricContext.CreateIntegerGauge("maxQueueLimit", integerGaugeConfig); maxQueueSize = metricContext.CreateIntegerGauge("maxQueueSize", integerGaugeConfig); maxQueueUtilization = metricContext.CreateFloatingGauge("maxQueueUtilization", floatingGaugeConfig); maxConsumptionPerProperty = options.PropertiesWithConsumptionTracking .ToDictionary( property => property, property => metricContext .WithTag("scope", "property") .WithTag("propertyName", property) .CreateIntegerGauge("maxConsumption", "propertyValue", propertiesGaugeConfig)); propertyConsumptionTrackingThreshold = options.PropertyConsumptionTrackingThreshold; }
public static IDisposable CreateThrottlingMetrics( [NotNull] this IMetricContext context, [NotNull] IThrottlingProvider provider, [CanBeNull] ThrottlingMetricsOptions options = null) => new ThrottlingMetrics(provider, context.WithTag(WellKnownTagKeys.Component, "throttling"), options ?? new ThrottlingMetricsOptions());