コード例 #1
0
 public DatadogTcpClient(DatadogConfiguration config, LogFormatter formatter, string apiKey)
 {
     _config    = config;
     _formatter = formatter;
     _apiKey    = apiKey;
     SelfLog.WriteLine("Creating TCP client with config: {0}", config);
 }
コード例 #2
0
 public DatadogSink(string apiKey, string source, string service, string host, string[] tags,
                    DatadogConfiguration config, int queueLimit, int?batchSizeLimit = null, TimeSpan?batchPeriod = null,
                    Action <Exception> exceptionHandler = null)
     : base(batchSizeLimit ?? DefaultBatchSizeLimit, batchPeriod ?? DefaultBatchPeriod, queueLimit)
 {
     _client           = CreateDatadogClient(apiKey, source, service, host, tags, config);
     _exceptionHandler = exceptionHandler;
 }
コード例 #3
0
 public DatadogHttpClient(DatadogConfiguration config, LogFormatter formatter, string apiKey)
 {
     _config = config;
     _client = new HttpClient();
     _client.DefaultRequestHeaders.Add("DD-API-KEY", apiKey);
     _client.DefaultRequestHeaders.Add("DD-EVP-ORIGIN", "Serilog.Sinks.Datadog.Logs");
     _client.DefaultRequestHeaders.Add("DD-EVP-ORIGIN-VERSION", _version);
     _url       = $"{config.Url}/api/v2/logs";
     _formatter = formatter;
 }
コード例 #4
0
        private static IDatadogClient CreateDatadogClient(string apiKey, string source, string service, string host,
                                                          string[] tags, DatadogConfiguration configuration)
        {
            var logFormatter = new LogFormatter(source, service, host, tags);

            if (configuration.UseTCP)
            {
                return(new DatadogTcpClient(configuration, logFormatter, apiKey));
            }
            return(new DatadogHttpClient(configuration, logFormatter, apiKey));
        }
コード例 #5
0
        public static DatadogSink Create(string apiKey, string source, string service, string host, string[] tags,
                                         DatadogConfiguration config, int?batchSizeLimit = null, TimeSpan?batchPeriod = null,
                                         int?queueLimit = null, Action <Exception> exceptionHandler = null)
        {
            if (queueLimit.HasValue)
            {
                return(new DatadogSink(apiKey, source, service, host, tags, config, queueLimit.Value, batchSizeLimit,
                                       batchPeriod, exceptionHandler));
            }

            return(new DatadogSink(apiKey, source, service, host, tags, config, batchSizeLimit, batchPeriod,
                                   exceptionHandler));
        }
コード例 #6
0
        public DatadogSink(string apiKey, string source, string service, string host, string[] tags, DatadogConfiguration config) : base(BatchSizeLimit, Period)
        {
            _apiKey  = apiKey;
            _source  = source;
            _service = service;
            _host    = host;
            _tags    = tags != null?string.Join(",", tags) : null;

            _client = new DatadogClient(config);
        }
コード例 #7
0
 public DatadogSink(string apiKey, DatadogConfiguration config) : base(BatchSizeLimit, Period)
 {
     _apiKey = apiKey;
     _client = new DatadogClient(config);
 }