Exemple #1
0
        public void Route(Stats stats)
        {
            switch (stats.Kind)
            {
            case StatsKind.Event:
                this._serializers.EventSerializer.SerializeTo(ref stats.Event, _serializedMetric);
                break;

            case StatsKind.Metric:
                if (!RouteMetric(ref stats.Metric))
                {
                    return;
                }

                break;

            case StatsKind.ServiceCheck:
                this._serializers.ServiceCheckSerializer.SerializeTo(ref stats.ServiceCheck, _serializedMetric);
                break;

            default:
                throw new ArgumentException($"{stats.Kind} is not supported");
            }

            _bufferBuilder.Add(_serializedMetric);
        }
 public void OnNewValue(string metric)
 {
     if (!_bufferBuilder.Add(metric))
     {
         throw new InvalidOperationException($"The metric size exceeds the buffer capacity: {metric}");
     }
     _stopwatch = null;
 }