public override bool TryBinaryOperation(BinaryOperationBinder binder, object arg, out object result)
            {
                if (binder.Operation == ExpressionType.AddAssign)
                {
                    var quantity = (int)arg;
                    var name     = String.Join(".", _parts);
                    switch (_metricType)
                    {
                    case MetricType.COUNT:
                        _statsd.LogCount(name, quantity);
                        break;

                    case MetricType.GAUGE:
                        _statsd.LogGauge(name, quantity);
                        break;

                    case MetricType.TIMING:
                        _statsd.LogTiming(name, quantity);
                        break;

                    case MetricType.SET:
                        _statsd.LogSet(name, quantity);
                        break;
                    }
                    result = null;
                    return(true);
                }
                result = null;
                return(false);
            }
예제 #2
0
        public void Dispose()
        {
            if (_disposed)
            {
                return;
            }

            _disposed = true;
            _stopWatch.Stop();
            _client.LogTiming(_name, _stopWatch.ElapsedMilliseconds);
        }
예제 #3
0
            private static void IntHandler(IStatsd client, string metricType, string name, object arg)
            {
                var value = Convert.ToInt32(arg);

                switch (metricType)
                {
                case MetricType.COUNT:
                    client.LogCount(name, value);
                    break;

                case MetricType.GAUGE:
                    client.LogGauge(name, value);
                    break;

                case MetricType.TIMING:
                    client.LogTiming(name, value);
                    break;

                case MetricType.SET:
                    client.LogSet(name, value);
                    break;
                }
            }
 /// <summary>
 /// Log a timing metric
 /// </summary>
 /// <param name="client">The statsd client instance.</param>
 /// <param name="name">The namespace of the timing metric.</param>
 /// <param name="duration">The duration to log (will be converted into milliseconds)</param>
 public static void LogTiming(this IStatsd client, string name, TimeSpan duration)
 {
     client.LogTiming(name, (int)duration.TotalMilliseconds);
 }
예제 #5
0
 public void Timer(string statName, int milliseconds)
 {
     _client.LogTiming(statName, milliseconds);
 }
예제 #6
0
 public void LogTiming(string name, long milliseconds, Dictionary <string, string> tags = null)
 {
     RunSafe(() =>
             _statsd.LogTiming(BuildName(name, tags), milliseconds));
 }
예제 #7
0
 /// <summary>
 /// Stops the internal timer and logs a latency metric.
 /// </summary>
 public void Dispose()
 {
     _stopwatch.Stop();
     _client.LogTiming(_name, (int)_stopwatch.ElapsedMilliseconds);
 }
 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     _stopwatch.Stop();
     _statsd.LogTiming(_name, (int)_stopwatch.ElapsedMilliseconds);
 }
예제 #9
0
 public void LogTiming(string name, long milliseconds)
 {
     _statsdClient.LogTiming(string.Format("{0}.{1}", GetStandardPrefix, name), milliseconds);
 }