Skip to content

Commit 337b743

Browse files
authored
[release/7.x] Update Diagnostics shipped version (#5992)
* Update Diagnostics shipped version * Fixup api * PR feedback * Pr feedback
1 parent fe23058 commit 337b743

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

eng/dependabot/nuget.org/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<!-- Import references updated by Dependabot. -->
33
<PropertyGroup>
44
<!-- dotnet/diagnostics references -->
5-
<MicrosoftDiagnosticsMonitoringShippedVersion>8.0.452401</MicrosoftDiagnosticsMonitoringShippedVersion>
5+
<MicrosoftDiagnosticsMonitoringShippedVersion>8.0.510501</MicrosoftDiagnosticsMonitoringShippedVersion>
66
</PropertyGroup>
77
</Project>

src/Microsoft.Diagnostics.Monitoring.WebApi/Metrics/JsonCounterLogger.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ protected override async Task SerializeAsync(ICounterPayload counter)
4343
}
4444
else if (counter is CounterEndedPayload)
4545
{
46-
Logger.CounterEndedPayload(counter.Name);
46+
Logger.CounterEndedPayload(counter.CounterMetadata.CounterName);
4747
return;
4848
}
4949
else if (!counter.EventType.IsValuePublishedEvent())
@@ -70,12 +70,12 @@ protected override async Task SerializeAsync(ICounterPayload counter)
7070
Quantile quantile = aggregatePercentilePayload.Quantiles[i];
7171

7272
SerializeCounterValues(counter.Timestamp,
73-
counter.Provider,
74-
counter.Name,
73+
counter.CounterMetadata.ProviderName,
74+
counter.CounterMetadata.CounterName,
7575
counter.DisplayName,
7676
counter.Unit,
7777
counter.CounterType.ToString(),
78-
CounterUtilities.AppendPercentile(counter.Metadata, quantile.Percentage),
78+
CounterUtilities.AppendPercentile(counter.ValueTags, quantile.Percentage),
7979
quantile.Value);
8080

8181
if (i < aggregatePercentilePayload.Quantiles.Length - 1)
@@ -90,12 +90,12 @@ protected override async Task SerializeAsync(ICounterPayload counter)
9090
_bufferWriter.Clear();
9191

9292
SerializeCounterValues(counter.Timestamp,
93-
counter.Provider,
94-
counter.Name,
93+
counter.CounterMetadata.ProviderName,
94+
counter.CounterMetadata.CounterName,
9595
counter.DisplayName,
9696
counter.Unit,
9797
counter.CounterType.ToString(),
98-
counter.Metadata,
98+
counter.ValueTags,
9999
counter.Value);
100100
}
101101
await _stream.WriteAsync(_bufferWriter.WrittenMemory);

src/Microsoft.Diagnostics.Monitoring.WebApi/Metrics/MetricsStore.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public MetricKey(ICounterPayload metric)
3030
public override int GetHashCode()
3131
{
3232
HashCode code = new HashCode();
33-
code.Add(_metric.Provider);
34-
code.Add(_metric.Name);
33+
code.Add(_metric.CounterMetadata.ProviderName);
34+
code.Add(_metric.CounterMetadata.CounterName);
3535
return code.ToHashCode();
3636
}
3737

@@ -73,9 +73,9 @@ public void AddMetric(ICounterPayload metric)
7373
//Do not accept CounterEnded payloads.
7474
if (metric is CounterEndedPayload counterEnded)
7575
{
76-
if (_observedEndedCounters.Add((counterEnded.Provider, counterEnded.Name)))
76+
if (_observedEndedCounters.Add((counterEnded.CounterMetadata.ProviderName, counterEnded.CounterMetadata.CounterName)))
7777
{
78-
_logger.CounterEndedPayload(counterEnded.Name);
78+
_logger.CounterEndedPayload(counterEnded.CounterMetadata.CounterName);
7979
}
8080
return;
8181
}
@@ -137,7 +137,7 @@ public async Task SnapshotMetrics(Stream outputStream, CancellationToken token)
137137
{
138138
ICounterPayload metricInfo = metricGroup.Value.First();
139139

140-
string metricName = PrometheusDataModel.GetPrometheusNormalizedName(metricInfo.Provider, metricInfo.Name, metricInfo.Unit);
140+
string metricName = PrometheusDataModel.GetPrometheusNormalizedName(metricInfo.CounterMetadata.ProviderName, metricInfo.CounterMetadata.CounterName, metricInfo.Unit);
141141

142142
await WriteMetricHeader(metricInfo, writer, metricName);
143143

@@ -165,7 +165,7 @@ public async Task SnapshotMetrics(Stream outputStream, CancellationToken token)
165165

166166
private static string GetMetricLabels(ICounterPayload metric, double? quantile)
167167
{
168-
string metadata = metric.Metadata;
168+
string metadata = metric.ValueTags;
169169

170170
char separator = IsMeter(metric) ? '=' : ':';
171171
var metadataValues = CounterUtilities.GetMetadata(metadata, separator);
@@ -242,7 +242,7 @@ private static async Task WriteMetricDetails(
242242

243243
private static bool CompareMetrics(ICounterPayload first, ICounterPayload second)
244244
{
245-
return string.Equals(first.Name, second.Name);
245+
return string.Equals(first.CounterMetadata.CounterName, second.CounterMetadata.CounterName);
246246
}
247247

248248
public void Clear()

src/Tests/Microsoft.Diagnostics.Monitoring.Tool.UnitTests/MetricsFormattingTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public async Task HistogramFormat_Test()
4242
{
4343
List<ICounterPayload> payload = new();
4444

45-
payload.Add(new AggregatePercentilePayload(MeterName, InstrumentName, "DisplayName", string.Empty, string.Empty,
45+
payload.Add(new AggregatePercentilePayload(new CounterMetadata(MeterName, InstrumentName, meterTags: null, instrumentTags: null, scopeHash: null),
46+
"DisplayName", string.Empty, string.Empty,
4647
new Quantile[] { new Quantile(0.5, Value1), new Quantile(0.95, Value2), new Quantile(0.99, Value3) },
4748
Timestamp));
4849

@@ -51,7 +52,7 @@ public async Task HistogramFormat_Test()
5152

5253
// Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
5354
// should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
54-
string metricName = $"{MeterName.ToLowerInvariant()}_{payload[0].Name}";
55+
string metricName = $"{MeterName.ToLowerInvariant()}_{payload[0].CounterMetadata.CounterName}";
5556

5657
const string quantile_50 = "{quantile=\"0.5\"}";
5758
const string quantile_95 = "{quantile=\"0.95\"}";
@@ -68,15 +69,16 @@ public async Task HistogramFormat_Test()
6869
[Fact]
6970
public async Task GaugeFormat_Test()
7071
{
71-
ICounterPayload payload = new GaugePayload(MeterName, InstrumentName, "DisplayName", "", null, Value1, Timestamp);
72+
ICounterPayload payload = new GaugePayload(new CounterMetadata(MeterName, InstrumentName, meterTags: null, instrumentTags: null, scopeHash: null),
73+
"DisplayName", "", null, Value1, Timestamp);
7274

7375
MemoryStream stream = await GetMetrics(new() { payload });
7476

7577
List<string> lines = ReadStream(stream);
7678

7779
// Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
7880
// should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
79-
string metricName = $"{MeterName.ToLowerInvariant()}_{payload.Name}";
81+
string metricName = $"{MeterName.ToLowerInvariant()}_{payload.CounterMetadata.CounterName}";
8082

8183
Assert.Equal(3, lines.Count);
8284
Assert.Equal(FormattableString.Invariant($"# HELP {metricName}{payload.Unit} {payload.DisplayName}"), lines[0]);
@@ -87,15 +89,16 @@ public async Task GaugeFormat_Test()
8789
[Fact]
8890
public async Task CounterFormat_Test()
8991
{
90-
ICounterPayload payload = new RatePayload(MeterName, InstrumentName, "DisplayName", "", null, Value1, IntervalSeconds, Timestamp);
92+
ICounterPayload payload = new RatePayload(new CounterMetadata(MeterName, InstrumentName, meterTags: null, instrumentTags: null, scopeHash: null),
93+
"DisplayName", "", null, Value1, IntervalSeconds, Timestamp);
9194

9295
MemoryStream stream = await GetMetrics(new() { payload });
9396

9497
List<string> lines = ReadStream(stream);
9598

9699
// Question - this is manually recreating what PrometheusDataModel.GetPrometheusNormalizedName does to get the metric name;
97100
// should we call this method, or should this also be implicitly testing its behavior by having this hard-coded?
98-
string metricName = $"{MeterName.ToLowerInvariant()}_{payload.Name}";
101+
string metricName = $"{MeterName.ToLowerInvariant()}_{payload.CounterMetadata.CounterName}";
99102

100103
Assert.Equal(3, lines.Count);
101104
Assert.Equal($"# HELP {metricName}{payload.Unit} {payload.DisplayName}", lines[0]);

0 commit comments

Comments
 (0)