public InfluxDbMetricsReporter(
            MetricsReportingInfluxDbOptions options,
            ILineProtocolClient lineProtocolClient)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.FlushInterval < TimeSpan.Zero)
            {
                throw new InvalidOperationException($"{nameof(MetricsReportingInfluxDbOptions.FlushInterval)} must not be less than zero");
            }

            _lineProtocolClient = lineProtocolClient ?? throw new ArgumentNullException(nameof(lineProtocolClient));

            Formatter = options.MetricsOutputFormatter ?? _defaultMetricsOutputFormatter;

            FlushInterval = options.FlushInterval > TimeSpan.Zero
                ? options.FlushInterval
                : AppMetricsConstants.Reporting.DefaultFlushInterval;

            Filter = options.Filter;

            Logger.Info($"Using Metrics Reporter {this}. Url: {options.InfluxDb.BaseUri + options.InfluxDb.Endpoint} FlushInterval: {FlushInterval}");
        }
 public LineProtocolEmitter(ILineProtocolClient client)
 {
     if (client == null)
     {
         throw new ArgumentNullException(nameof(client));
     }
     _client = client;
 }
Esempio n. 3
0
 public InfluxDbReporter(ILineProtocolClient lineProtocolClient,
     ILineProtocolPayloadBuilder payloadBuilder,
     TimeSpan reportInterval,
     ILoggerFactory loggerFactory,
     Func<string, string, string> metricNameFormatter)
     : this(lineProtocolClient, payloadBuilder, reportInterval, typeof(InfluxDbReporter).Name,
         loggerFactory, metricNameFormatter)
 {
 }
 public override CollectorConfiguration InfluxDB(Uri serverBaseAddress, string database, string username = null, string password = null)
 {
     if (string.Compare(serverBaseAddress.Scheme, "udp", ignoreCase: true) == 0)
     {
         _client = new LineProtocolUdpClient(serverBaseAddress, database, username, password);
     }
     else
     {
         _client = new LineProtocolClient(serverBaseAddress, database, username, password);
     }
     return(_configuration);
 }
Esempio n. 5
0
        public InfluxDbReporter(ILineProtocolClient lineProtocolClient,
            ILineProtocolPayloadBuilder payloadBuilder,
            TimeSpan reportInterval,
            string name, ILoggerFactory loggerFactory,
            Func<string, string, string> metricNameFormatter)
        {
            ReportInterval = reportInterval;
            Name = name;

            _payloadBuilder = payloadBuilder;
            _metricNameFormatter = metricNameFormatter;
            _logger = loggerFactory.CreateLogger<InfluxDbReporter>();
            _lineProtocolClient = lineProtocolClient;
        }
Esempio n. 6
0
        public AliTSDBMetricsReporter(
            MetricsReportingAliTSDBOptions options,
            ILineProtocolClient lineProtocolClient)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            if (options.FlushInterval < TimeSpan.Zero)
            {
                throw new InvalidOperationException($"{nameof(MetricsReportingAliTSDBOptions.FlushInterval)} must not be less than zero");
            }

            _lineProtocolClient = lineProtocolClient ?? throw new ArgumentNullException(nameof(lineProtocolClient));

            Formatter = options.MetricsOutputFormatter ?? _defaultMetricsOutputFormatter;

            FlushInterval = options.FlushInterval > TimeSpan.Zero
                ? options.FlushInterval
                : AppMetricsConstants.Reporting.DefaultFlushInterval;
        }
 public TelegrafCollectorConfiguration Udp(string hostname, int port)
 {
     _client = new MetricUdpSender(hostname, port);
     return(_configuration);
 }
 public TelegrafCollectorConfiguration Tcp(string hostname, int port, TcpSenderSettings senderSettings)
 {
     _client = new MetricTcpSender(hostname, port, senderSettings);
     return(_configuration);
 }