Skip to content

Commit c4f1529

Browse files
authored
Change ConfigMetrics from Array to Dictionary (#422)
* Change ConfigMetrics from array to dictionary * add telemetry key for config
1 parent f44d051 commit c4f1529

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/Authentication.Abstractions/Models/ConfigMetrics.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,25 @@ public class ConfigMetrics: IExtensibleModel
2828
/// </summary>
2929
public string ConfigKey { get; private set; }
3030

31+
/// <summary>
32+
/// The unique telemetry key of config. It's required for recording config telemetry. If not provided, it's same with ConfigKey.
33+
/// </summary>
34+
public string TelemetryKey { get; private set; }
35+
3136
/// <summary>
3237
/// Config value in string format. It's required for recording config telemetry.
3338
/// </summary>
3439
public string ConfigValue { get; private set; }
3540

3641
public IDictionary<string, string> ExtendedProperties { get; } = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
3742

38-
public ConfigMetrics(string ConfigKey, string ConfigValue)
43+
public ConfigMetrics(string configKey, string configValue): this(configKey, configKey, configValue){}
44+
45+
public ConfigMetrics(string configKey, string telemetryKey, string configValue)
3946
{
40-
this.ConfigKey = ConfigKey;
41-
this.ConfigValue = ConfigValue;
47+
this.ConfigKey = configKey;
48+
this.TelemetryKey = telemetryKey;
49+
this.ConfigValue = configValue;
4250
}
4351
}
4452
}

src/Common/MetricHelper.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ private void PopulateConfigMetricsFromQos(AzurePSQoSEvent qos, IDictionary<strin
508508
{
509509
foreach (var configMetric in qos.ConfigMetrics)
510510
{
511-
eventProperties[configMetric.ConfigKey] = configMetric.ConfigValue;
511+
eventProperties[configMetric.Value.TelemetryKey] = configMetric.Value.ConfigValue;
512512
}
513513
}
514514
}
@@ -670,7 +670,7 @@ public class AzurePSQoSEvent
670670
public string ParameterSetName { get; set; }
671671
public string InvocationName { get; set; }
672672

673-
public List<ConfigMetrics> ConfigMetrics { get; private set; }
673+
public Dictionary<string, ConfigMetrics> ConfigMetrics { get; private set; }
674674

675675
public Dictionary<string, string> CustomProperties { get; private set; }
676676

@@ -683,7 +683,7 @@ public AzurePSQoSEvent()
683683
StartTime = DateTimeOffset.Now;
684684
_timer = new Stopwatch();
685685
_timer.Start();
686-
ConfigMetrics = new List<ConfigMetrics>();
686+
ConfigMetrics = new Dictionary<string, ConfigMetrics>();
687687
CustomProperties = new Dictionary<string, string>();
688688
}
689689

0 commit comments

Comments
 (0)