/// <summary>
        /// Meter represents the metric that measurese the rate at which an event occurs. 
        /// You can use meter to count failed requests per second metric.
        /// </summary>
        /// <param name="telemetryClient">Telemetry client to associate the meter with.</param>
        /// <param name="name">Name of the meter.</param>
        /// <param name="aggregations">Aggregation to apply.</param>
        /// <returns>Returns a meter implementation.</returns>
        public static IMeter Meter(this TelemetryClient telemetryClient, string name, MeterAggregations aggregations = MeterAggregations.Rate)
        {
            var meter = new MeterImplementation(name, telemetryClient.Context, aggregations);

            var configuration = GetConfigurationFromClient(telemetryClient);
            configuration.RegisterCounter(meter);

            return meter;
        }
Ejemplo n.º 2
0
        public MeterImplementation(string name, TelemetryContext context, MeterAggregations aggregations)
            : base(name, context)
        {
            this.value = 0;
            this.shouldCalculateRate = (aggregations & MeterAggregations.Rate) == MeterAggregations.Rate;
            this.shouldCalculateSum  = (aggregations & MeterAggregations.Sum) == MeterAggregations.Sum;

            if (this.shouldCalculateRate)
            {
                timer = Stopwatch.StartNew();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Meter represents the metric that measurese the rate at which an event occurs.
        /// You can use meter to count failed requests per second metric.
        /// </summary>
        /// <param name="telemetryClient">Telemetry client to associate the meter with.</param>
        /// <param name="name">Name of the meter.</param>
        /// <param name="aggregations">Aggregation to apply.</param>
        /// <returns>Returns a meter implementation.</returns>
        public static IMeter Meter(this TelemetryClient telemetryClient, string name, MeterAggregations aggregations = MeterAggregations.Rate)
        {
            var meter = new MeterImplementation(name, telemetryClient.Context, aggregations);

            var configuration = GetConfigurationFromClient(telemetryClient);

            configuration.RegisterCounter(meter);

            return(meter);
        }