public SimpleMetricOutput(DoubleMetric doubleMetric) { Entity = Enum.GetName(typeof(MetricEntity), doubleMetric.MetricEntity); Instance = doubleMetric.Instance; Name = doubleMetric.Name; Value = doubleMetric.Value.Get(); }
public static DoubleMetric MetricFromEmpty <S, T>(Analyzer <S, T> analyzer, string name, string instance, MetricEntity metricEntity = MetricEntity.Column) where S : State <S>, IState where T : IMetric { EmptyStateException emptyState = new EmptyStateException($"Empty state for analyzer {analyzer}, all input values were NULL."); return(DoubleMetric.Create(metricEntity, name, instance, new Try <double>(ExceptionExt.WrapIfNecessary(emptyState)))); }
public void DoubleMetric_should_flatten_and_return_itself() { DoubleMetric metric = new DoubleMetric(MetricEntity.Column, "metric-name", "instance-name", Try <double> .From(() => 50)); metric.Flatten().ShouldBe(new List <DoubleMetric> { metric }); }
/// <inheritdoc cref="Analyzer{S,M}.ComputeMetricFrom"/> public override DoubleMetric ComputeMetricFrom(Option <S> state) { DoubleMetric metric = state.HasValue switch { true => AnalyzersExt.MetricFromValue(new Try <double>(state.Value.GetMetricValue()), Name, Instance, _metricEntity), _ => AnalyzersExt.MetricFromEmpty(this, Name, Instance, _metricEntity) }; return(metric); } }
public static DoubleMetric MetricFromValue(Try <double> value, string name, string instance, MetricEntity metricEntity = MetricEntity.Column) => DoubleMetric.Create(metricEntity, name, instance, value.Get());
public static DoubleMetric MetricFromFailure(Exception exception, string name, string instance, MetricEntity metricEntity = MetricEntity.Column) => DoubleMetric.Create(metricEntity, name, instance, new Try <double>(ExceptionExt.WrapIfNecessary(exception)));
/// <summary> /// Equality method of two <see cref="DoubleMetric"/> instances. /// </summary> /// <param name="other">The other <see cref="DoubleMetric"/> instance.</param> /// <returns>true if the equality is satisfied, otherwise false.</returns> public bool Equals(DoubleMetric other) => other != null && Name == other.Name && Instance == other.Instance && MetricEntity == other.MetricEntity && Value.IsSuccess == other.Value.IsSuccess && Value.GetOrElse(() => 0).Get() == other.Value.GetOrElse(() => 0).Get();