protected GrpcRequestMiddlewareBase(GrpcMetricsOptionsBase?options, TCollector?customMetric) { MetricFactory = Metrics.WithCustomRegistry(options?.Registry ?? Metrics.DefaultRegistry); if (customMetric != null) { _metric = customMetric; ValidateNoUnexpectedLabelNames(); } else { _metric = CreateMetricInstance(DefaultLabels); } }
/// <summary> /// Initializes a new instance of the <see cref="MetricFactory"/> class. /// </summary> /// <param name="innerMetricFactory">The inner <see cref="Prometheus.MetricFactory"/> for Prometheus.</param> public MetricFactory(Prometheus.MetricFactory innerMetricFactory) { _innerMetricFactory = innerMetricFactory; }
protected override ICollector <ICounter> CreateMetricInstance(string[] labelNames) => MetricFactory.CreateCounter( "grpc_requests_received_total", "Number of gRPC requests received (including those currently being processed).", new CounterConfiguration { LabelNames = labelNames });