/// <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."); }
/// <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."); }
/// <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)); }
/// <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)); }
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)); }
private static void ThrowIfNull(IDriverMetrics driverMetrics, SessionMetric sessionMetric) { MetricsExtensions.ThrowIfNull(driverMetrics, nameof(driverMetrics)); MetricsExtensions.ThrowIfNull(sessionMetric, nameof(sessionMetric)); }
/// <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)); }