Skip to content

Commit

Permalink
Change ConfigMetrics from Array to Dictionary (#422)
Browse files Browse the repository at this point in the history
* Change ConfigMetrics from array to dictionary

* add telemetry key for config
  • Loading branch information
BethanyZhou authored Jun 18, 2024
1 parent f44d051 commit c4f1529
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
14 changes: 11 additions & 3 deletions src/Authentication.Abstractions/Models/ConfigMetrics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,25 @@ public class ConfigMetrics: IExtensibleModel
/// </summary>
public string ConfigKey { get; private set; }

/// <summary>
/// The unique telemetry key of config. It's required for recording config telemetry. If not provided, it's same with ConfigKey.
/// </summary>
public string TelemetryKey { get; private set; }

/// <summary>
/// Config value in string format. It's required for recording config telemetry.
/// </summary>
public string ConfigValue { get; private set; }

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

public ConfigMetrics(string ConfigKey, string ConfigValue)
public ConfigMetrics(string configKey, string configValue): this(configKey, configKey, configValue){}

public ConfigMetrics(string configKey, string telemetryKey, string configValue)
{
this.ConfigKey = ConfigKey;
this.ConfigValue = ConfigValue;
this.ConfigKey = configKey;
this.TelemetryKey = telemetryKey;
this.ConfigValue = configValue;
}
}
}
6 changes: 3 additions & 3 deletions src/Common/MetricHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ private void PopulateConfigMetricsFromQos(AzurePSQoSEvent qos, IDictionary<strin
{
foreach (var configMetric in qos.ConfigMetrics)
{
eventProperties[configMetric.ConfigKey] = configMetric.ConfigValue;
eventProperties[configMetric.Value.TelemetryKey] = configMetric.Value.ConfigValue;
}
}
}
Expand Down Expand Up @@ -670,7 +670,7 @@ public class AzurePSQoSEvent
public string ParameterSetName { get; set; }
public string InvocationName { get; set; }

public List<ConfigMetrics> ConfigMetrics { get; private set; }
public Dictionary<string, ConfigMetrics> ConfigMetrics { get; private set; }

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

Expand All @@ -683,7 +683,7 @@ public AzurePSQoSEvent()
StartTime = DateTimeOffset.Now;
_timer = new Stopwatch();
_timer.Start();
ConfigMetrics = new List<ConfigMetrics>();
ConfigMetrics = new Dictionary<string, ConfigMetrics>();
CustomProperties = new Dictionary<string, string>();
}

Expand Down

0 comments on commit c4f1529

Please sign in to comment.