Exemplo n.º 1
0
        /// <summary>
        /// Create a new Statsd client
        /// </summary>
        /// <typeparam name="T">Statsd client to use</typeparam>
        /// <param name="configure">configuration block</param>
        /// <returns></returns>
        public static Statsd New <T>(Action <StatsdOptions> configure) where T : BaseCommunicationProvider, new()
        {
            var options = new StatsdOptions();

            configure?.Invoke(options);
            return(new Statsd(options, new T()));
        }
 internal BaseCommunicationProvider Construct(StatsdOptions options)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     this.Options = options;
     return(this);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create a statsd client
 /// </summary>
 /// <param name="options">client options </param>
 /// <param name="provider">provider, defaults to udp if none is passed</param>
 public Statsd(StatsdOptions options, BaseCommunicationProvider provider = null)
 {
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (provider == null)
     {
         provider = new Udp();
     }
     if (string.IsNullOrEmpty(options.HostOrIp))
     {
         options.LogEvent("No host or ip provided, failing back to null output", EventType.Error);
         _provider = new NullChannel();
     }
     if (options.Port < 0)
     {
         options.LogEvent("port provided, failing back to null output", EventType.Error);
         _provider = new NullChannel();
     }
     this.options = options;
     _provider    = provider.Construct(options);
 }
Exemplo n.º 4
0
#pragma warning restore CC0022
        /// <summary>
        /// Create a new Statsd client. Defaults to Udp
        /// </summary>
        /// <param name="options">client options</param>
        /// <returns></returns>
        public static Statsd New(StatsdOptions options) => Statsd.New <Udp>(options);
Exemplo n.º 5
0
        /// <summary>
        /// Create a new Statsd client
        /// </summary>
        /// <typeparam name="T">Statsd client to use</typeparam>
        /// <param name="options">client options</param>
        /// <returns></returns>
#pragma warning disable CC0022 // should dispose
        public static Statsd New <T>(StatsdOptions options) where T : BaseCommunicationProvider, new() => new Statsd(options, new T());