Beispiel #1
0
        private DiagnosticSourceAdapter(DiagnosticSourceAdapterOptions options)
        {
            _options = options;
            _metric  = Metrics.WithCustomRegistry(options.Registry)
                       .CreateCounter("diagnostic_events_total", "Total count of events received via the DiagnosticSource infrastructure.", new CounterConfiguration
            {
                LabelNames = new[]
                {
                    "source",   // Name of the DiagnosticSource
                    "event"     // Name of the event
                }
            });

            var newListenerObserver = new NewListenerObserver(OnNewListener);

            _newListenerSubscription = DiagnosticListener.AllListeners.Subscribe(newListenerObserver);
        }
Beispiel #2
0
 /// <summary>
 /// Starts listening for DiagnosticSource events and reporting them as Prometheus metrics.
 /// Dispose of the return value to stop listening.
 /// </summary>
 public static IDisposable StartListening(DiagnosticSourceAdapterOptions options) => new DiagnosticSourceAdapter(options);