From 275a4463cf40020bb6a56a2b43c782e43cd9e9c9 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 25 Jan 2025 04:34:54 +1100 Subject: [PATCH] [repo] remove redundant interpolation (#6098) Co-authored-by: Mikel Blanchard --- docs/metrics/extending-the-sdk/MyExporter.cs | 2 +- .../OtlpMetricsExporterTests.cs | 2 +- .../Metrics/MetricApiTests.cs | 26 +++++++++---------- .../Metrics/MetricExemplarTests.cs | 14 +++++----- .../Metrics/MetricViewTests.cs | 14 +++++----- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/metrics/extending-the-sdk/MyExporter.cs b/docs/metrics/extending-the-sdk/MyExporter.cs index 228d3e0c342..e6c6211c012 100644 --- a/docs/metrics/extending-the-sdk/MyExporter.cs +++ b/docs/metrics/extending-the-sdk/MyExporter.cs @@ -28,7 +28,7 @@ public override ExportResult Export(in Batch batch) sb.Append(", "); } - sb.Append($"{metric.Name}"); + sb.Append(metric.Name); foreach (ref readonly var metricPoint in metric.GetMetricPoints()) { diff --git a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs index 78c2d033383..b666f129ff6 100644 --- a/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs +++ b/test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/OtlpMetricsExporterTests.cs @@ -917,7 +917,7 @@ public void MetricsSerialization_ExpandsBufferForMetricsAndSerializes() new("key2", "value2"), }; - using var meter = new Meter(name: $"{Utils.GetCurrentMethodName()}", version: "0.0.1", tags: meterTags); + using var meter = new Meter(name: Utils.GetCurrentMethodName(), version: "0.0.1", tags: meterTags); using var provider = Sdk.CreateMeterProviderBuilder() .AddMeter(meter.Name) .AddInMemoryExporter(metrics) diff --git a/test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs index e2dcb89d3d2..bdf93ae7598 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs @@ -125,7 +125,7 @@ public void MetricUnitIsExportedCorrectly(string? unit) { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -147,7 +147,7 @@ public void MetricDescriptionIsExportedCorrectly(string? description) { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -173,7 +173,7 @@ public void MetricInstrumentationScopeIsExportedCorrectly() "MeterTagKey", "MeterTagValue"), }; - using var meter = new Meter($"{meterName}", meterVersion, meterTags); + using var meter = new Meter(meterName, meterVersion, meterTags); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) .AddInMemoryExporter(exportedItems)); @@ -264,7 +264,7 @@ public void DuplicateInstrumentRegistration_NoViews_IdenticalInstruments() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -297,7 +297,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -343,7 +343,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -389,7 +389,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -433,7 +433,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -478,8 +478,8 @@ public void DuplicateInstrumentNamesFromDifferentMetersWithSameNameDifferentVers { var exportedItems = new List(); - using var meter1 = new Meter($"{Utils.GetCurrentMethodName()}", "1.0"); - using var meter2 = new Meter($"{Utils.GetCurrentMethodName()}", "2.0"); + using var meter1 = new Meter(Utils.GetCurrentMethodName(), "1.0"); + using var meter2 = new Meter(Utils.GetCurrentMethodName(), "2.0"); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter1.Name) @@ -1592,7 +1592,7 @@ public void SetupSdkProviderWithNoReader(bool hasViews) [Fact] public void UnsupportedMetricInstrument() { - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var exportedItems = new List(); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder @@ -1627,7 +1627,7 @@ public void GaugeIsExportedCorrectly() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1656,7 +1656,7 @@ public void GaugeHandlesNoNewMeasurementsCorrectlyWithTemporality(MetricReaderTe { var exportedMetrics = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) .AddInMemoryExporter(exportedMetrics, metricReaderOptions => diff --git a/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs index 7ed01e46a72..b6122c97005 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs @@ -69,7 +69,7 @@ public void TestExemplarsCounter(MetricReaderTemporalityPreference temporality) DateTime testStartTime = DateTime.UtcNow; var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var counterDouble = meter.CreateCounter("testCounterDouble"); var counterLong = meter.CreateCounter("testCounterLong"); @@ -192,7 +192,7 @@ public void TestExemplarsObservable(MetricReaderTemporalityPreference temporalit int measurementIndex = 0; - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var gaugeDouble = meter.CreateObservableGauge("testGaugeDouble", () => measurementValues[measurementIndex].Value); var gaugeLong = meter.CreateObservableGauge("testGaugeLong", () => (long)measurementValues[measurementIndex].Value); var counterDouble = meter.CreateObservableCounter("counterDouble", () => measurementValues[measurementIndex].Value); @@ -275,7 +275,7 @@ public void TestExemplarsHistogramWithBuckets(MetricReaderTemporalityPreference DateTime testStartTime = DateTime.UtcNow; var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var histogramWithBucketsAndMinMaxDouble = meter.CreateHistogram("histogramWithBucketsAndMinMaxDouble"); var histogramWithBucketsDouble = meter.CreateHistogram("histogramWithBucketsDouble"); var histogramWithBucketsAndMinMaxLong = meter.CreateHistogram("histogramWithBucketsAndMinMaxLong"); @@ -425,7 +425,7 @@ public void TestExemplarsHistogramWithoutBuckets(MetricReaderTemporalityPreferen DateTime testStartTime = DateTime.UtcNow; var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var histogramWithoutBucketsAndMinMaxDouble = meter.CreateHistogram("histogramWithoutBucketsAndMinMaxDouble"); var histogramWithoutBucketsDouble = meter.CreateHistogram("histogramWithoutBucketsDouble"); var histogramWithoutBucketsAndMinMaxLong = meter.CreateHistogram("histogramWithoutBucketsAndMinMaxLong"); @@ -553,7 +553,7 @@ public void TestExemplarsExponentialHistogram(MetricReaderTemporalityPreference DateTime testStartTime = DateTime.UtcNow; var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var exponentialHistogramWithMinMaxDouble = meter.CreateHistogram("exponentialHistogramWithMinMaxDouble"); var exponentialHistogramDouble = meter.CreateHistogram("exponentialHistogramDouble"); var exponentialHistogramWithMinMaxLong = meter.CreateHistogram("exponentialHistogramWithMinMaxLong"); @@ -674,7 +674,7 @@ public void TestTraceBasedExemplarFilter(bool enableTracing) { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var counter = meter.CreateCounter("testCounter"); @@ -721,7 +721,7 @@ public void TestExemplarsFilterTags(bool enableTagFiltering) { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); var histogram = meter.CreateHistogram("testHistogram"); diff --git a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs index f2a9ceb6eab..109c68acebd 100644 --- a/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs +++ b/test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs @@ -1049,7 +1049,7 @@ public void ViewConflict_OneInstrument_DifferentDescription() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1152,7 +1152,7 @@ public void ViewConflict_TwoDistinctInstruments_ThreeStreams() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1216,7 +1216,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_DifferentTags() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1263,7 +1263,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_SameTags() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1311,7 +1311,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_DifferentHistogramBoun { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1388,7 +1388,7 @@ public void ViewConflict_TwoInstruments_OneMatchesView() { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name) @@ -1441,7 +1441,7 @@ public void ViewConflict_TwoInstruments_ConflictAvoidedBecauseSecondInstrumentIs { var exportedItems = new List(); - using var meter = new Meter($"{Utils.GetCurrentMethodName()}"); + using var meter = new Meter(Utils.GetCurrentMethodName()); using var container = this.BuildMeterProvider(out var meterProvider, builder => builder .AddMeter(meter.Name)