Esempio n. 1
0
        /// <summary>
        /// Casts the provided timer to the timer implementation of this provider.
        /// </summary>
        /// <exception cref="ArgumentException">If the timer was not created by the AppMetrics
        /// provider (<see cref="CreateDriverMetricsProvider(App.Metrics.IMetricsRoot)"/>).</exception>
        public static IAppMetricsTimer ToAppMetricsTimer(this IDriverTimer timer)
        {
            MetricsExtensions.ThrowIfNull(timer, nameof(timer));

            if (timer is IAppMetricsTimer appMetricsTimer)
            {
                return(appMetricsTimer);
            }

            throw new ArgumentException("Timer was not created by the AppMetricsDriverProvider, " +
                                        $"it's type is {timer.GetType().Name} and doesn't implement IAppMetricsTimer.");
        }
Esempio n. 2
0
        /// <summary>
        /// Casts the provided gauge to the gauge implementation of this provider.
        /// </summary>
        /// <exception cref="ArgumentException">If the gauge was not created by the AppMetrics
        /// provider (<see cref="CreateDriverMetricsProvider(App.Metrics.IMetricsRoot)"/>).</exception>
        public static IAppMetricsGauge ToAppMetricsGauge(this IDriverGauge gauge)
        {
            MetricsExtensions.ThrowIfNull(gauge, nameof(gauge));

            if (gauge is IAppMetricsGauge appMetricsGauge)
            {
                return(appMetricsGauge);
            }

            throw new ArgumentException("Gauge was not created by the AppMetricsDriverProvider, " +
                                        $"it's type is {gauge.GetType().Name} and doesn't implement IAppMetricsGauge.");
        }
Esempio n. 3
0
 /// <summary>
 /// Utility method that wraps a call to <see cref="IDriverMetrics.GetSessionMetric{TMetricType}"/> with the appropriate AppMetrics based counter type
 /// as the type parameter. For more information see the API docs of <see cref="IDriverMetrics.GetSessionMetric{TMetricType}"/>.
 /// </summary>
 public static IAppMetricsCounter GetSessionCounter(this IDriverMetrics driverMetrics, SessionMetric sessionMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, sessionMetric);
     return(driverMetrics.GetSessionMetric <IAppMetricsCounter>(sessionMetric));
 }
Esempio n. 4
0
 /// <summary>
 /// Utility method that wraps a call to <see cref="IDriverMetrics.GetNodeMetric{TMetricType}"/> with the appropriate AppMetrics based timer type
 /// as the type parameter. For more information see the API docs of <see cref="IDriverMetrics.GetNodeMetric{TMetricType}"/>.
 /// </summary>
 public static IAppMetricsTimer GetNodeTimer(this IDriverMetrics driverMetrics, Host host, NodeMetric nodeMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, host, nodeMetric);
     return(driverMetrics.GetNodeMetric <IAppMetricsTimer>(host, nodeMetric));
 }
Esempio n. 5
0
 private static void ThrowIfNull(IDriverMetrics driverMetrics, Host host, NodeMetric nodeMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, nameof(driverMetrics));
     MetricsExtensions.ThrowIfNull(host, nameof(host));
     MetricsExtensions.ThrowIfNull(nodeMetric, nameof(nodeMetric));
 }
Esempio n. 6
0
 private static void ThrowIfNull(IDriverMetrics driverMetrics, SessionMetric sessionMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, nameof(driverMetrics));
     MetricsExtensions.ThrowIfNull(sessionMetric, nameof(sessionMetric));
 }
Esempio n. 7
0
 /// <summary>
 /// Utility method that wraps a call to <see cref="IDriverMetrics.GetSessionMetric{TMetricType}"/> with the appropriate AppMetrics based gauge type
 /// as the type parameter. For more information see the API docs of <see cref="IDriverMetrics.GetSessionMetric{TMetricType}"/>.
 /// </summary>
 public static IAppMetricsGauge GetSessionGauge(this IDriverMetrics driverMetrics, SessionMetric sessionMetric)
 {
     MetricsExtensions.ThrowIfNull(driverMetrics, sessionMetric);
     return(driverMetrics.GetSessionMetric <IAppMetricsGauge>(sessionMetric));
 }