Ejemplo n.º 1
0
        public static IGauge Gauge(string name, string instance)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (String.IsNullOrEmpty(instance))
            {
                throw new ArgumentNullException(nameof(instance));
            }

            var parent = New(name, null, () => Factory.Gauge(name));

            return(New(name, instance, () => Factory.Gauge(parent, instance)));
        }
Ejemplo n.º 2
0
        /// <inheritdoc/>
        public IEnumerable <Collector> Provide(IMetricFactory metricFactory)
        {
            _connectedHeads  = metricFactory.Gauge("ConnectedHeads", "Number of connected heads");
            _headConnects    = metricFactory.Counter("HeadConnects", "Number of connections established from heads");
            _headDisconnects = metricFactory.Counter("HeadDisconnects", "Number of connections disconnected from heads");

            return(new Collector[]
            {
                _connectedHeads,
                _headConnects,
                _headDisconnects
            });
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public void Set(DataPoint dataPoint)
        {
            try
            {
                var timeSeries = dataPoint.TimeSeries.ToGuid();
                _dataPointsPerTimeSeries[timeSeries] = dataPoint;
                var gauge = _metricFactory.Gauge("datapoint", "This is a timeseries datapoint", "timeseries", "property", "trait");

                switch (dataPoint.MeasurementCase)
                {
                case DataPoint.MeasurementOneofCase.SingleValue:
                    gauge.WithLabels(timeSeries.ToString(), string.Empty, ValueTrait).Set(dataPoint.SingleValue.Value);
                    gauge.WithLabels(timeSeries.ToString(), string.Empty, ErrorTrait).Set(dataPoint.SingleValue.Error);
                    break;

                case DataPoint.MeasurementOneofCase.Vector2Value:
                    gauge.WithLabels(timeSeries.ToString(), XProperty, ValueTrait).Set(dataPoint.Vector2Value.X.Value);
                    gauge.WithLabels(timeSeries.ToString(), XProperty, ErrorTrait).Set(dataPoint.Vector2Value.X.Error);
                    gauge.WithLabels(timeSeries.ToString(), YProperty, ValueTrait).Set(dataPoint.Vector2Value.Y.Value);
                    gauge.WithLabels(timeSeries.ToString(), YProperty, ErrorTrait).Set(dataPoint.Vector2Value.Y.Error);
                    break;

                case DataPoint.MeasurementOneofCase.Vector3Value:
                    gauge.WithLabels(timeSeries.ToString(), XProperty, ValueTrait).Set(dataPoint.Vector3Value.X.Value);
                    gauge.WithLabels(timeSeries.ToString(), XProperty, ErrorTrait).Set(dataPoint.Vector3Value.X.Error);
                    gauge.WithLabels(timeSeries.ToString(), YProperty, ValueTrait).Set(dataPoint.Vector3Value.Y.Value);
                    gauge.WithLabels(timeSeries.ToString(), YProperty, ErrorTrait).Set(dataPoint.Vector3Value.Y.Error);
                    gauge.WithLabels(timeSeries.ToString(), ZProperty, ValueTrait).Set(dataPoint.Vector3Value.Z.Value);
                    gauge.WithLabels(timeSeries.ToString(), ZProperty, ErrorTrait).Set(dataPoint.Vector3Value.Z.Error);
                    break;
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Error setting datapoint gauges");
            }
        }
Ejemplo n.º 4
0
        public static IGauge Gauge(string name, string instance)
        {
            var parent = (IGauge)New(name, null, () => Factory.Gauge(name));

            return((IGauge)New(name, instance, () => Factory.Gauge(parent, instance)));
        }