Пример #1
0
        /// <summary>
        /// Add a listener on sources that match a given Name predicate.
        /// </summary>
        /// <param name="client">The <see cref="IInfluxDBClient"/> to write data to.</param>
        /// <param name="sourceNamePredicate">A predicate to match <see cref="DiagnosticSource"/> names.</param>
        /// <param name="optionsCallback">Configuration callback</param>
        public static IDisposable Listen(IInfluxDBClient client, Func <string, bool> sourceNamePredicate, Action <DiagnosticListenerOptions> optionsCallback = null)
        {
            var listener = new DiagnosticSourceInfluxDB(client, sourceNamePredicate, optionsCallback);

            DiagnosticListener.AllListeners.Subscribe(listener);
            return(listener);
        }
Пример #2
0
 private DiagnosticSourceInfluxDB(IInfluxDBClient client, Func <string, bool> sourceNamePredicate, Action <DiagnosticListenerOptions> optionsCallback)
 {
     _sourceNamePredicate = sourceNamePredicate;
     _client          = client;
     _listenerOptions = new DiagnosticListenerOptions();
     optionsCallback?.Invoke(_listenerOptions);
 }
Пример #3
0
 internal DiagnosticListenerObserver(DiagnosticListener listener, IInfluxDBClient client, DiagnosticListenerOptions options)
 {
     _listener     = listener;
     _client       = client;
     _formatters   = new InfluxLineFormatterCollection(listener.Name, options);
     _onError      = options.OnError;
     _subscription = listener.Subscribe(this);
 }
 public InfluxDBRecorder(IConfiguration configuration,
                         IModuleClient moduleClient,
                         CancellationTokenSource cancellationTokenSource,
                         IInfluxDBClient influxDBClient)
 {
     Configuration           = configuration;
     ModuleClient            = moduleClient;
     CancellationTokenSource = cancellationTokenSource;
     InfluxDBClient          = influxDBClient;
 }
Пример #5
0
 public InfluxDBMonitor(IOptions <InfluxDBOptions> options, ILogger <InfluxDBMonitor> logger)
 {
     _logger = logger;
     if (!string.IsNullOrWhiteSpace(options.Value.Server) && !string.IsNullOrWhiteSpace(options.Value.Database))
     {
         _client = new InfluxDBClientBuilder(options.Value.Server, options.Value.Database)
                   .ForceFlushInterval(TimeSpan.FromSeconds(10))
                   .OnError(LogError)
                   .Build();
     }
 }
Пример #6
0
 public InfluxClient(IInfluxDBClient client, string dbName)
 {
     influx   = client;
     database = dbName;
 }
Пример #7
0
 public InfluxClient(string url, string dbName)
 {
     influx   = new InfluxDBClient(url);
     database = dbName;
 }