public HttpHandlerDiagnosticListenerObserver( HttpHandlerObserverConfig config, Collector <Counter.Child> counter, Collector <Summary.Child> summary ) { _config = config; _requestFetcher = new PropertyFetcher("Request"); _responseFetcher = new PropertyFetcher("Response"); _requestCounter = counter; _requestSummary = summary; }
/// <summary> /// Adds the HttpHandler obsever for the HttpHandlerDiagnosticListener /// </summary> /// <param name="o"></param> /// <param name="configure">Configuration options for the observer</param> public static void AddHttpHandlerObserver(this SubscribeOptions o, Action <HttpHandlerObserverConfig> configure) { var config = new HttpHandlerObserverConfig(); configure?.Invoke(config); var counter = Metrics.CreateCounter("outgoing_http_requests", "Outgoing HTTP Requests Count", new CounterConfiguration { SuppressInitialValue = true, LabelNames = new[] { "host", "method", "endpoint", "status" } }); var summary = Metrics.CreateSummary("outgoing_http_requests_time", "Response times in milliseconds", new SummaryConfiguration { SuppressInitialValue = true, LabelNames = new[] { "host", "method", "endpoint", "status" } }); o.AddSubscriber("HttpHandlerDiagnosticListener", new HttpHandlerDiagnosticListenerObserver(config, counter, summary)); }