示例#1
0
        /// <summary>
        /// Constructor for the metric record.
        /// </summary>
        /// <param name="info">Meta-data info for the record.</param>
        /// <param name="timeStamp">Unix time stamp for the record measured as total
        /// seconds relative to Jan 01 1970. (UTC)</param>
        /// <param name="metrics">Collection of metrics in the record.</param>
        /// <param name="tags">Collection of tags in the record.</param>
        /// <param name="context">Context of the record.</param>
        public MetricsRecord(IMetricsInfo info,
                             long timeStamp,
                             IEnumerable <IImmutableMetric> metrics,
                             IEnumerable <MetricsTag> tags,
                             string context)
        {
            if (info == null)
            {
                throw new MetricsException("Record info cannot be null", new ArgumentNullException("info"));
            }

            if (timeStamp < 0)
            {
                throw new MetricsException(string.Empty,
                                           new ArgumentException("Timestamp cannot be less than zero", "timeStamp"));
            }

            if (metrics == null)
            {
                throw new MetricsException("Metrics list is null", new ArgumentNullException("metrics"));
            }

            if (tags == null)
            {
                throw new MetricsException("Tag list is null", new ArgumentNullException("tags"));
            }

            Name        = info.Name;
            Description = info.Description;
            Timestamp   = timeStamp;
            Metrics     = metrics;
            Tags        = tags;
            Context     = context;
        }
示例#2
0
        /// <summary>
        /// Creates a metric record by meta-data info. Creates the new record even
        /// if another one with same meta-data already exists.
        /// </summary>
        /// <param name="info">Meta-data info of the record.</param>
        /// <returns>Record builder for the record.</returns>
        public IMetricsRecordBuilder CreateRecord(IMetricsInfo info)
        {
            var value = new MetricsRecordBuilder(this, info);

            _recordBuilder.Add(value);
            return(value);
        }
示例#3
0
 /// <summary>
 /// Gauge Constructor
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 /// <param name="initValue">Initial gauge value.</param>
 public MutableDoubleGauge(IMetricsInfo info, double initValue)
     : base(info)
 {
     RegisterSnapshotRequestObserver(Observer.Create<SnapshotRequest>(this.GiveSnapshot,
         this.SnapshotError,
         UnSubscribe));
     _value = initValue;
 }
示例#4
0
 /// <summary>
 /// Gauge Constructor
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 /// <param name="initValue">Initial gauge value.</param>
 public MutableDoubleGauge(IMetricsInfo info, double initValue)
     : base(info)
 {
     RegisterSnapshotRequestObserver(Observer.Create <SnapshotRequest>(this.GiveSnapshot,
                                                                       this.SnapshotError,
                                                                       UnSubscribe));
     _value = initValue;
 }
示例#5
0
 /// <summary>
 /// Adds a double gauge to the record builder.
 /// </summary>
 /// <param name="info">Meta data info of the gauge.</param>
 /// <param name="value">Value of the gauge.</param>
 /// <returns>Self reference.</returns>
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value)
 {
     if (_recordBuilderFinalized)
     {
         throw new MetricsException("Record builder is already finalized. No more metrics can be added.");
     }
     _metrics.Add(new ImmutableDoubleGauge(info, value));
     return(this);
 }
示例#6
0
 /// <summary>
 /// Adds a tag to the record builder.
 /// </summary>
 /// <param name="info">Meta-data info of the tag.</param>
 /// <param name="value">Value of the tag.</param>
 /// <returns>Self reference.</returns>
 public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value)
 {
     if (_recordBuilderFinalized)
     {
         throw new MetricsException("Record builder is already finalized. No more tags can be added.");
     }
     _tags.Add(new MetricsTag(info, value));
     return(this);
 }
 /// <summary>
 /// Constructor. Called by metrics of numerical types.
 /// </summary>
 /// <param name="info">Meta-data for the metric</param>
 /// <param name="value">The numerical value of the metric. Numerical types can be
 /// directly type casted to double.</param>
 /// <param name="typeOfMetric">Type of metric - counter or gauge</param>
 /// <param name="onVisit">Action to take on receiving <see cref="IMetricsVisitor"/></param>
 public ImmutableMetricsImpl(IMetricsInfo info,
                             double value,
                             MetricType typeOfMetric,
                             Action <IMetricsVisitor> onVisit)
 {
     NumericValue = value;
     LongValue    = null;
     TypeOfMetric = typeOfMetric;
     _info        = info;
     _onVisit     = onVisit;
 }
示例#8
0
 /// <summary>
 /// Constructor. Called by metrics of numerical types.
 /// </summary>
 /// <param name="info">Meta-data for the metric</param>
 /// <param name="value">The numerical value of the metric. Numerical types can be 
 /// directly type casted to double.</param>
 /// <param name="typeOfMetric">Type of metric - counter or gauge</param>
 /// <param name="onVisit">Action to take on receiving <see cref="IMetricsVisitor"/></param>
 public ImmutableMetricsImpl(IMetricsInfo info,
     double value,
     MetricType typeOfMetric,
     Action<IMetricsVisitor> onVisit)
 {
     NumericValue = value;
     LongValue = null;
     TypeOfMetric = typeOfMetric;
     _info = info;
     _onVisit = onVisit;
 }
示例#9
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="info">Meta data of the stat.</param>
        /// <param name="valueName">Value (e.g. time, latency) the stat represents.</param>
        /// <param name="extendedStats"></Whether to show only mean (false) or mean,
        /// stdev, min, max etc.</param>
        public MutableStat(IMetricsInfo info, string valueName, bool extendedStats = true)
            : base(info)
        {
            ValueName          = valueName;
            _showExtendedStats = extendedStats;

            string name = info.Name + "-Num";
            string desc = "Number of samples for " + info.Description;

            _numSamplesInfo = new MetricsInfoImpl(name, desc);

            name             = info.Name + "-RunningAvg";
            desc             = "Average " + valueName + " for " + info.Description;
            _runningMeanInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-RunningStdev";
            desc            = "Standard deviation of " + valueName + " for " + info.Description;
            _runningStdInfo = new MetricsInfoImpl(name, desc);

            name             = info.Name + "-IntervalAvg";
            desc             = "Interval Average " + valueName + " for " + info.Description;
            _currentMeanInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-IntervalStdev";
            desc            = "Interval Standard deviation of " + valueName + " for " + info.Description;
            _currentStdInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-RunningMin";
            desc            = "Min " + valueName + " for " + info.Description;
            _runningMinInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-RunningMax";
            desc            = "Max " + valueName + " for " + info.Description;
            _runningMaxInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-IntervalMin";
            desc            = "Interval Min " + valueName + " for " + info.Description;
            _currentMinInfo = new MetricsInfoImpl(name, desc);

            name            = info.Name + "-IntervalMax";
            desc            = "Interval Max " + valueName + " for " + info.Description;
            _currentMaxInfo = new MetricsInfoImpl(name, desc);

            RegisterSnapshotRequestObserver(Observer.Create <SnapshotRequest>(this.GiveSnapshot,
                                                                              this.SnapshotError,
                                                                              UnSubscribe));
        }
示例#10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="info">Meta data of the stat.</param>
        /// <param name="valueName">Value (e.g. time, latency) the stat represents.</param>
        /// <param name="extendedStats"></Whether to show only mean (false) or mean, 
        /// stdev, min, max etc.</param>
        public MutableStat(IMetricsInfo info, string valueName, bool extendedStats = true)
            : base(info)
        {
            ValueName = valueName;
            _showExtendedStats = extendedStats;

            string name = info.Name + "-Num";
            string desc = "Number of samples for " + info.Description;
            _numSamplesInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-RunningAvg";
            desc = "Average " + valueName + " for " + info.Description;
            _runningMeanInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-RunningStdev";
            desc = "Standard deviation of " + valueName + " for " + info.Description;
            _runningStdInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-IntervalAvg";
            desc = "Interval Average " + valueName + " for " + info.Description;
            _currentMeanInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-IntervalStdev";
            desc = "Interval Standard deviation of " + valueName + " for " + info.Description;
            _currentStdInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-RunningMin";
            desc = "Min " + valueName + " for " + info.Description;
            _runningMinInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-RunningMax";
            desc = "Max " + valueName + " for " + info.Description;
            _runningMaxInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-IntervalMin";
            desc = "Interval Min " + valueName + " for " + info.Description;
            _currentMinInfo = new MetricsInfoImpl(name, desc);

            name = info.Name + "-IntervalMax";
            desc = "Interval Max " + valueName + " for " + info.Description;
            _currentMaxInfo = new MetricsInfoImpl(name, desc);

            RegisterSnapshotRequestObserver(Observer.Create<SnapshotRequest>(this.GiveSnapshot,
               this.SnapshotError,
               UnSubscribe));
        }
示例#11
0
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, long value)
 {
     _longMetricVals[info.Name] = value;
     return(this);
 }
示例#12
0
 public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value)
 {
     _tagVals[info.Name] = value;
     return(this);
 }
示例#13
0
 public void Gauge(IMetricsInfo info, double value)
 {
     DoubleGauge = value;
 }
示例#14
0
 public IMetricsRecordBuilder CreateRecord(IMetricsInfo info)
 {
     throw new System.NotImplementedException();
 }
示例#15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="collector">The parent collector that creates the record builder.</param>
 /// <param name="info">Meta-data info of the record-builder.</param>
 public MetricsRecordBuilder(IMetricsCollector collector, IMetricsInfo info)
 {
     _parentCollector = collector;
     _info            = info;
 }
示例#16
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta-data of the metric.</param>
 /// <param name="extended">If false, outputs only current mean, otherwise outputs
 /// everything(mean, variance, min, max overall and of current interval.</param>
 public MutableRate(IMetricsInfo info, bool extended = true)
     : base(info, "Time", extended)
 {
 }
示例#17
0
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value)
 {
     _doubleMetricVals[info.Name] = value;
     return this;
 }
示例#18
0
 /// <summary>
 /// Protected Constructor
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 protected MutableMetricBase(IMetricsInfo info)
 {
     Info     = info;
     _changed = true;
 }
示例#19
0
 /// <summary>
 /// Creates new tag
 /// </summary>
 /// <param name="info">Meta-data of the tag.</param>
 /// <param name="value">Value of the tag.</param>
 /// <returns>The new tag.</returns>
 public MetricsTag CreateTag(IMetricsInfo info, string value)
 {
     return new MetricsTag(info, value);
 }
示例#20
0
 /// <summary>
 /// Constructor for tags.
 /// </summary>
 /// <param name="info">Meta data for tags.</param>
 /// <param name="value">Value of the tag.</param>
 internal MetricsTag(IMetricsInfo info, string value)
 {
     _info  = info;
     _value = value;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the gauge</param>
 /// <param name="value">Value of the gauge</param>
 public ImmutableDoubleGauge(IMetricsInfo info, double value)
     : base(info, value, MetricType.Gauge, (visitor) => visitor.Gauge(info, value))
 {
 }
示例#22
0
 /// <summary>
 /// Gauge Constructor. Initializes gauge to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableLongGauge(IMetricsInfo info) : this(info, 0)
 {
 }
示例#23
0
 public void Gauge(IMetricsInfo info, long value)
 {
     LongGauge = value;
 }
示例#24
0
 public void Counter(IMetricsInfo info, long value)
 {
     CounterValue = value;
 }
示例#25
0
 public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value)
 {
     throw new System.NotImplementedException();
 }
 public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value)
 {
     throw new System.NotImplementedException();
 }
示例#27
0
 public IMetricsRecordBuilder AddCounter(IMetricsInfo info, long value)
 {
     throw new System.NotImplementedException();
 }
示例#28
0
 /// <summary>
 /// Gauge Constructor. Initializes gauge to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableLongGauge(IMetricsInfo info) : this(info, 0)
 {
 }
示例#29
0
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value)
 {
     throw new System.NotImplementedException();
 }
示例#30
0
 /// <summary>
 /// Counter Constructor. Initializes counter to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableCounter(IMetricsInfo info) : this(info, 0)
 {
 }
示例#31
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the counter</param>
 /// <param name="value">Value of the counter</param>
 public ImmutableCounter(IMetricsInfo info, long value)
     : base(info, value, MetricType.Counter, (visitor) => visitor.Counter(info, value))
 {
 }
示例#32
0
 public void Gauge(IMetricsInfo info, long value)
 {
     LongGauge = value;
 }
示例#33
0
 /// <summary>
 /// Constructor for tags.
 /// </summary>
 /// <param name="info">Meta data for tags.</param>
 /// <param name="value">Value of the tag.</param>
 internal MetricsTag(IMetricsInfo info, string value)
 {
     _info = info;
     _value = value;
 }
示例#34
0
 public void Counter(IMetricsInfo info, long value)
 {
     CounterValue = value;
 }
示例#35
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the gauge</param>
 /// <param name="value">Value of the gauge</param>
 public ImmutableDoubleGauge(IMetricsInfo info, double value)
     : base(info, value, MetricType.Gauge, (visitor) => visitor.Gauge(info, value))
 {
 }
示例#36
0
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value)
 {
     _doubleMetricVals[info.Name] = value;
     return(this);
 }
示例#37
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the counter</param>
 /// <param name="value">Value of the counter</param>
 public ImmutableCounter(IMetricsInfo info, long value)
     : base(info, value, MetricType.Counter, (visitor) => visitor.Counter(info, value))
 {
 }
示例#38
0
 public IMetricsRecordBuilder CreateRecord(IMetricsInfo info)
 {
     throw new System.NotImplementedException();
 }
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value)
 {
     throw new System.NotImplementedException();
 }
示例#40
0
 public void Gauge(IMetricsInfo info, double value)
 {
     DoubleGauge = value;
 }
示例#41
0
 /// <summary>
 /// Gauge Constructor. Initializes gauge to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableDoubleGauge(IMetricsInfo info)
     : this(info, 0)
 {
 }
示例#42
0
 public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value)
 {
     _tagVals[info.Name] = value;
     return this;
 }
示例#43
0
 /// <summary>
 /// Counter Constructor. Initializes counter to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableCounter(IMetricsInfo info) : this(info, 0)
 {
 }
示例#44
0
 public IMetricsRecordBuilder AddGauge(IMetricsInfo info, long value)
 {
     _longMetricVals[info.Name] = value;
     return this;
 }
 /// <summary>
 /// Creates new tag
 /// </summary>
 /// <param name="info">Meta-data of the tag.</param>
 /// <param name="value">Value of the tag.</param>
 /// <returns>The new tag.</returns>
 public MetricsTag CreateTag(IMetricsInfo info, string value)
 {
     return(new MetricsTag(info, value));
 }
 public IMetricsRecordBuilder AddCounter(IMetricsInfo info, long value)
 {
     throw new System.NotImplementedException();
 }
示例#47
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta-data of the metric.</param>
 /// <param name="extended">If false, outputs only current mean, otherwise outputs 
 /// everything(mean, variance, min, max overall and of current interval.</param>
 public MutableRate(IMetricsInfo info, bool extended = true)
     : base(info, "Time", extended)
 {
 }
示例#48
0
 /// <summary>
 /// Gauge Constructor. Initializes gauge to zero.
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 public MutableDoubleGauge(IMetricsInfo info)
     : this(info, 0)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the gauge</param>
 /// <param name="value">Value of the gauge</param>
 public ImmutableLongGauge(IMetricsInfo info, long value)
     : base(info, value, MetricType.Gauge, (visitor) => visitor.Gauge(info, value))
 {
 }
示例#50
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="info">Meta data of the gauge</param>
 /// <param name="value">Value of the gauge</param>
 public ImmutableLongGauge(IMetricsInfo info, long value)
     : base(info, value, MetricType.Gauge, (visitor) => visitor.Gauge(info, value))
 {
 }
示例#51
0
 /// <summary>
 /// Protected Constructor
 /// </summary>
 /// <param name="info">Meta-data info. of the metric.</param>
 protected MutableMetricBase(IMetricsInfo info)
 {
     Info = info;
     _changed = true;
 }