Example #1
0
        /// <summary>
        /// Creates a new instance of <see cref="StatsdClient"/> class.
        /// </summary>
        /// <param name="channel">A channel to send data to statsd server. Possible implementations are <see cref="UdpChannel"/> and <see cref="TcpChannel"/></param>
        /// <param name="prefix">Prefix which is will be for every metric.</param>
        public StatsdClient(IChannel channel, string prefix = null)
        {
            if (prefix != null && (string.IsNullOrWhiteSpace(prefix) || prefix.EndsWith(".")))
            {
                const string message = "Must be either null or period delimited string and not end with '.'." +
                                       " For instance, 'my.favorite.prefix' is a right one.";
                throw new ArgumentException(message, nameof(prefix));
            }

            _writer  = new StatsdWriter(prefix);
            _channel = channel ?? throw new ArgumentNullException(nameof(channel));
        }
Example #2
0
        public StatsdWriterBenchmark()
        {
            _writer = new StatsdWriter("test");

            _metric1 = new Metric(new Timing("time", 1));
            _metric2 = new Metric(new Timing("time", 12));
            _metric3 = new Metric(new Timing("time", 123));
            _metric4 = new Metric(new Timing("time", 1234));
            _metric5 = new Metric(new Timing("time", 12345));
            _metric6 = new Metric(new Timing("time", 123456));
            _metric7 = new Metric(new Timing("time", 1234567));
            _metric8 = new Metric(new Timing("time", 12345678));
        }