public MetricsData GetMetricByNameAndTag(string metric, ActuatorTag actuatorTag) { if (actuatorTag is null) { throw new ArgumentNullException(nameof(actuatorTag)); } var metricData = GetMetricByName(metric); var area = metricData.AvailableTags.FirstOrDefault(x => x.Tag == actuatorTag.Tag); if (area == null) { throw new UnknownTagErrorException(metric, actuatorTag); } if (!area.Values.ContainsKey(actuatorTag.Value)) { throw new UnknownTagErrorException(metric, actuatorTag); } var tagData = area.Values.FirstOrDefault(x => x.Key == actuatorTag.Value); return(new MetricsData() { Name = tagData.Key, BaseUnit = null !, Description = string.Empty, Measurements = new List <Measurement>() { new Measurement() { Statistic = tagData.Key, Value = tagData.Value } }, });
public UnknownTagErrorException(string name, ActuatorTag actuatorTag) : base($"The is no Tag {actuatorTag} in {name} ") { Name = name; ActuatorTag = actuatorTag; }