Esempio n. 1
0
 public SimpleMetricOutput(DoubleMetric doubleMetric)
 {
     Entity   = Enum.GetName(typeof(MetricEntity), doubleMetric.MetricEntity);
     Instance = doubleMetric.Instance;
     Name     = doubleMetric.Name;
     Value    = doubleMetric.Value.Get();
 }
Esempio n. 2
0
        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))));
        }
Esempio n. 3
0
        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
            });
        }
Esempio n. 4
0
        /// <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);
        }
    }
Esempio n. 5
0
 public static DoubleMetric MetricFromValue(Try <double> value, string name, string instance,
                                            MetricEntity metricEntity = MetricEntity.Column) =>
 DoubleMetric.Create(metricEntity, name, instance, value.Get());
Esempio n. 6
0
 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)));
Esempio n. 7
0
 /// <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();