public void WriteTrace(Span[] trace)
        {
            if (_synchronousSend)
            {
                _api.SendTracesAsync(new[] { trace }).Wait();
                return;
            }

            var success = _tracesBuffer.Push(trace);

            if (!success)
            {
                Log.Debug("Trace buffer is full. Dropping a trace from the buffer.");
            }

            if (_statsd != null)
            {
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedTraces);
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedSpans, trace.Length);

                if (!success)
                {
                    _statsd.AppendIncrementCount(TracerMetricNames.Queue.DroppedTraces);
                    _statsd.AppendIncrementCount(TracerMetricNames.Queue.DroppedSpans, trace.Length);
                }

                _statsd.Send();
            }
        }
Example #2
0
 public void Event(string title, string text, string alertType = null, string aggregationKey = null, string sourceType = null, int?dateHappened = null, string priority = null, string hostname = null, string[] tags = null)
 {
     if (_statsD == null)
     {
         return;
     }
     _statsD.Send(title, text, alertType, aggregationKey, sourceType, dateHappened, priority, hostname, tags);
 }
 static WaitCallback CreateSender(int sends, int threads, int which, IStatsd statsd, ManualResetEvent done)
 {
     return x => {
         for (int i = 0; i < sends; i++)
             if (which == (i % threads))
                 statsd.Send(i.ToString());
         done.Set();
     };
 }
Example #4
0
 static WaitCallback CreateSender(int sends, int threads, int which, IStatsd statsd, ManualResetEvent done)
 {
     return(x => {
         for (int i = 0; i < sends; i++)
         {
             if (which == (i % threads))
             {
                 statsd.Send(i.ToString());
             }
         }
         done.Set();
     });
 }
Example #5
0
        public void WriteTrace(List <Span> trace)
        {
            var success = _tracesBuffer.Push(trace);

            if (!success)
            {
                Log.Debug("Trace buffer is full, dropping it.");
            }

            if (_statsd != null)
            {
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedTraces);
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedSpans, trace.Count);

                if (!success)
                {
                    _statsd.AppendIncrementCount(TracerMetricNames.Queue.DroppedTraces);
                }

                _statsd.Send();
            }
        }
Example #6
0
        public void WriteTrace(Span[] trace)
        {
            var success = _tracesBuffer.Push(trace);

            if (!success)
            {
                Log.Debug("Trace buffer is full. Dropping a trace from the buffer.");
            }

            if (_statsd != null)
            {
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedTraces);
                _statsd.AppendIncrementCount(TracerMetricNames.Queue.EnqueuedSpans, trace.Length);

                if (!success)
                {
                    _statsd.AppendIncrementCount(TracerMetricNames.Queue.DroppedTraces);
                    _statsd.AppendIncrementCount(TracerMetricNames.Queue.DroppedSpans, trace.Length);
                }

                _statsd.Send();
            }
        }
Example #7
0
        public void Publish(Metric metric)
        {
            Log.DebugFormat("{0} | {1} | {2}", metric.Name, metric.Value, metric.Type);

            switch (metric.Type)
            {
            case MetricType.Gauge:
                _statsdClient.Send <Statsd.Gauge>(metric.Name, metric.Value);
                return;

            case MetricType.Count:
                break;

            case MetricType.Timing:
                break;

            default:
                throw new NotSupportedException();
            }

            throw new NotSupportedException();
        }
Example #8
0
 public static void Send(this IStatsd statsd, Action actionToTime, string statName, double sampleRate = 1) =>
 statsd.Send(actionToTime, statName.AsSpan(), sampleRate);
Example #9
0
 public static void Send <TCommandType>(this IStatsd statsd, string name, double value, bool isDeltaValue) where TCommandType : IAllowsDouble, IAllowsDelta =>
 statsd.Send <TCommandType>(name.AsSpan(), value, isDeltaValue);
Example #10
0
 public static void Send <TCommandType>(this IStatsd statsd, string name, int value) where TCommandType : IAllowsInteger =>
 statsd.Send <TCommandType>(name.AsSpan(), value);
 public void send_counters()
 {
     Parallel.For(0, ThreadCount, x => _stats.Send <Statsd.Counting>(Guid.NewGuid().ToString(), 5));
     Assert.That(DistinctMetricsSent(), Is.EqualTo(ThreadCount));
 }
Example #12
0
 /// <summary>
 /// Send a counter value.
 /// </summary>
 /// <param name="statName">Name of the metric.</param>
 /// <param name="value">Value of the counter. Defaults to 1.</param>
 /// <param name="sampleRate">Sample rate to reduce the load on your metric server. Defaults to 1 (100%).</param>
 public static void Counter(string statName, int value = 1, double sampleRate = 1)
 {
     _statsD.Send <Statsd.Counting>(BuildNamespacedStatName(statName), value, sampleRate);
 }
 public static void Counter(string statName, int value = 1, object tags = null, double sampleRate = 1)
 {
     _statsD.Send <Counting>(statName, value, sampleRate, tags);
 }