/// <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; }
/// <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); }
/// <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; }
/// <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; }
/// <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); }
/// <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; }
/// <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; }
/// <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)); }
/// <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)); }
public IMetricsRecordBuilder AddGauge(IMetricsInfo info, long value) { _longMetricVals[info.Name] = value; return(this); }
public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value) { _tagVals[info.Name] = value; return(this); }
public void Gauge(IMetricsInfo info, double value) { DoubleGauge = value; }
public IMetricsRecordBuilder CreateRecord(IMetricsInfo info) { throw new System.NotImplementedException(); }
/// <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; }
/// <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) { }
public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value) { _doubleMetricVals[info.Name] = value; return this; }
/// <summary> /// Protected Constructor /// </summary> /// <param name="info">Meta-data info. of the metric.</param> protected MutableMetricBase(IMetricsInfo info) { Info = info; _changed = true; }
/// <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); }
/// <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)) { }
/// <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) { }
public void Gauge(IMetricsInfo info, long value) { LongGauge = value; }
public void Counter(IMetricsInfo info, long value) { CounterValue = value; }
public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value) { throw new System.NotImplementedException(); }
public IMetricsRecordBuilder AddCounter(IMetricsInfo info, long value) { throw new System.NotImplementedException(); }
public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value) { throw new System.NotImplementedException(); }
/// <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) { }
/// <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)) { }
public IMetricsRecordBuilder AddGauge(IMetricsInfo info, double value) { _doubleMetricVals[info.Name] = value; return(this); }
/// <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) { }
public IMetricsRecordBuilder AddTag(IMetricsInfo info, string value) { _tagVals[info.Name] = value; return this; }
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)); }
/// <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)) { }