Skip to content

Commit 5f5b6bc

Browse files
authored
Support Meter.TelemetrySchemaUrl in SDK, Exporter.InMemory and Exporter.Console (#6714)
1 parent c2095be commit 5f5b6bc

File tree

11 files changed

+40
-2
lines changed

11 files changed

+40
-2
lines changed

src/OpenTelemetry.Exporter.Console/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Notes](../../RELEASENOTES.md).
88

99
* Added support for `ActivitySource.TelemetrySchemaUrl` property.
1010
([#6713](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6713))
11+
* Added support for `Meter.TelemetrySchemaUrl` property.
12+
([#6714](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6714))
1113

1214
## 1.14.0
1315

src/OpenTelemetry.Exporter.Console/ConsoleActivityExporter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public override ExportResult Export(in Batch<Activity> batch)
120120

121121
if (!string.IsNullOrEmpty(activity.Source.TelemetrySchemaUrl))
122122
{
123-
this.WriteLine($" Schema Url: {activity.Source.TelemetrySchemaUrl}");
123+
this.WriteLine($" Schema URL: {activity.Source.TelemetrySchemaUrl}");
124124
}
125125

126126
if (activity.Source.Tags?.Any() == true)

src/OpenTelemetry.Exporter.Console/ConsoleMetricExporter.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public override ExportResult Export(in Batch<Metric> batch)
7373
this.WriteLine($"\tVersion: {metric.MeterVersion}");
7474
}
7575

76+
if (!string.IsNullOrEmpty(metric.InstrumentIdentity.MeterSchemaUrl))
77+
{
78+
this.WriteLine($"\tSchema URL: {metric.MeterSchemaUrl}");
79+
}
80+
7681
if (metric.MeterTags?.Any() == true)
7782
{
7883
this.WriteLine("\tTags:");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
OpenTelemetry.Metrics.MetricSnapshot.MeterSchemaUrl.get -> string!

src/OpenTelemetry.Exporter.InMemory/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Notes](../../RELEASENOTES.md).
66

77
## Unreleased
88

9+
* Added support for `Meter.TelemetrySchemaUrl` property.
10+
([#6714](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6714))
11+
912
## 1.14.0
1013

1114
Released 2025-Nov-12

src/OpenTelemetry.Exporter.InMemory/MetricSnapshot.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,9 @@ public MetricSnapshot(Metric metric)
4141

4242
public string MeterVersion => this.instrumentIdentity.MeterVersion;
4343

44+
#pragma warning disable CA1056 // Change the type of property from 'string' to 'System.Uri'
45+
public string MeterSchemaUrl => this.instrumentIdentity.MeterSchemaUrl;
46+
#pragma warning restore CA1056 // Change the type of property from 'string' to 'System.Uri'
47+
4448
public IReadOnlyList<MetricPoint> MetricPoints { get; }
4549
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
OpenTelemetry.Metrics.Metric.MeterSchemaUrl.get -> string!
12
OpenTelemetry.Metrics.MetricReaderTemporalityPreference.LowMemory = 3 -> OpenTelemetry.Metrics.MetricReaderTemporalityPreference

src/OpenTelemetry/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Notes](../../RELEASENOTES.md).
99
* Added `LowMemory` temporality as an option in the OTLP metrics exporter.
1010
([#6648](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6648))
1111

12+
* Added support for `Meter.TelemetrySchemaUrl` property.
13+
([#6714](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6714))
14+
1215
## 1.14.0
1316

1417
Released 2025-Nov-12

src/OpenTelemetry/Metrics/Metric.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,13 @@ internal Metric(
231231
/// </summary>
232232
public string MeterVersion => this.InstrumentIdentity.MeterVersion;
233233

234+
/// <summary>
235+
/// Gets the meter schema URL for the metric stream.
236+
/// </summary>
237+
#pragma warning disable CA1056 // Change the type of property from 'string' to 'System.Uri'
238+
public string MeterSchemaUrl => this.InstrumentIdentity.MeterSchemaUrl;
239+
#pragma warning restore CA1056 // Change the type of property from 'string' to 'System.Uri'
240+
234241
/// <summary>
235242
/// Gets the attributes (tags) for the metric stream.
236243
/// </summary>

src/OpenTelemetry/Metrics/MetricStreamIdentity.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public MetricStreamIdentity(Instrument instrument, MetricStreamConfiguration? me
1616
this.MeterName = instrument.Meter.Name;
1717
this.MeterVersion = instrument.Meter.Version ?? string.Empty;
1818
this.MeterTags = instrument.Meter.Tags != null ? new Tags(instrument.Meter.Tags.ToArray()) : null;
19+
this.MeterSchemaUrl = instrument.Meter.TelemetrySchemaUrl ?? string.Empty;
1920
this.InstrumentName = metricStreamConfiguration?.Name ?? instrument.Name;
2021
this.Unit = instrument.Unit ?? string.Empty;
2122
this.Description = metricStreamConfiguration?.Description ?? instrument.Description ?? string.Empty;
@@ -33,6 +34,7 @@ public MetricStreamIdentity(Instrument instrument, MetricStreamConfiguration? me
3334
hashCode.Add(this.InstrumentType);
3435
hashCode.Add(this.MeterName);
3536
hashCode.Add(this.MeterVersion);
37+
hashCode.Add(this.MeterSchemaUrl);
3638
hashCode.Add(this.MeterTags);
3739
hashCode.Add(this.InstrumentName);
3840
hashCode.Add(this.HistogramRecordMinMax);
@@ -65,6 +67,7 @@ public MetricStreamIdentity(Instrument instrument, MetricStreamConfiguration? me
6567
hash = (hash * 31) + this.InstrumentType.GetHashCode();
6668
hash = (hash * 31) + this.MeterName.GetHashCode();
6769
hash = (hash * 31) + this.MeterVersion.GetHashCode();
70+
hash = (hash * 31) + this.MeterSchemaUrl.GetHashCode();
6871
hash = (hash * 31) + this.MeterTags?.GetHashCode() ?? 0;
6972
hash = (hash * 31) + this.InstrumentName.GetHashCode();
7073
hash = (hash * 31) + this.HistogramRecordMinMax.GetHashCode();
@@ -92,6 +95,8 @@ public MetricStreamIdentity(Instrument instrument, MetricStreamConfiguration? me
9295

9396
public string MeterVersion { get; }
9497

98+
public string MeterSchemaUrl { get; }
99+
95100
public Tags? MeterTags { get; }
96101

97102
public string InstrumentName { get; }
@@ -138,6 +143,7 @@ public bool Equals(MetricStreamIdentity other)
138143
return this.InstrumentType == other.InstrumentType
139144
&& this.MeterName == other.MeterName
140145
&& this.MeterVersion == other.MeterVersion
146+
&& this.MeterSchemaUrl == other.MeterSchemaUrl
141147
&& this.InstrumentName == other.InstrumentName
142148
&& this.Unit == other.Unit
143149
&& this.Description == other.Description

0 commit comments

Comments
 (0)