Skip to content

Commit

Permalink
[repo] remove redundant interpolation (#6098)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
  • Loading branch information
SimonCropp and CodeBlanch authored Jan 24, 2025
1 parent 8fa00cb commit 275a446
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/metrics/extending-the-sdk/MyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public override ExportResult Export(in Batch<Metric> batch)
sb.Append(", ");
}

sb.Append($"{metric.Name}");
sb.Append(metric.Name);

foreach (ref readonly var metricPoint in metric.GetMetricPoints())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 13 additions & 13 deletions test/OpenTelemetry.Tests/Metrics/MetricApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void MetricUnitIsExportedCorrectly(string? unit)
{
var exportedItems = new List<Metric>();

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)
Expand All @@ -147,7 +147,7 @@ public void MetricDescriptionIsExportedCorrectly(string? description)
{
var exportedItems = new List<Metric>();

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)
Expand All @@ -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));
Expand Down Expand Up @@ -264,7 +264,7 @@ public void DuplicateInstrumentRegistration_NoViews_IdenticalInstruments()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -297,7 +297,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -343,7 +343,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -389,7 +389,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -433,7 +433,7 @@ public void DuplicateInstrumentRegistration_NoViews_DuplicateInstruments_Differe
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -478,8 +478,8 @@ public void DuplicateInstrumentNamesFromDifferentMetersWithSameNameDifferentVers
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -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<Metric>();

using var container = this.BuildMeterProvider(out var meterProvider, builder => builder
Expand Down Expand Up @@ -1627,7 +1627,7 @@ public void GaugeIsExportedCorrectly()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1656,7 +1656,7 @@ public void GaugeHandlesNoNewMeasurementsCorrectlyWithTemporality(MetricReaderTe
{
var exportedMetrics = new List<Metric>();

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 =>
Expand Down
14 changes: 7 additions & 7 deletions test/OpenTelemetry.Tests/Metrics/MetricExemplarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void TestExemplarsCounter(MetricReaderTemporalityPreference temporality)
DateTime testStartTime = DateTime.UtcNow;
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());
var counterDouble = meter.CreateCounter<double>("testCounterDouble");
var counterLong = meter.CreateCounter<long>("testCounterLong");

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -275,7 +275,7 @@ public void TestExemplarsHistogramWithBuckets(MetricReaderTemporalityPreference
DateTime testStartTime = DateTime.UtcNow;
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());
var histogramWithBucketsAndMinMaxDouble = meter.CreateHistogram<double>("histogramWithBucketsAndMinMaxDouble");
var histogramWithBucketsDouble = meter.CreateHistogram<double>("histogramWithBucketsDouble");
var histogramWithBucketsAndMinMaxLong = meter.CreateHistogram<long>("histogramWithBucketsAndMinMaxLong");
Expand Down Expand Up @@ -425,7 +425,7 @@ public void TestExemplarsHistogramWithoutBuckets(MetricReaderTemporalityPreferen
DateTime testStartTime = DateTime.UtcNow;
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());
var histogramWithoutBucketsAndMinMaxDouble = meter.CreateHistogram<double>("histogramWithoutBucketsAndMinMaxDouble");
var histogramWithoutBucketsDouble = meter.CreateHistogram<double>("histogramWithoutBucketsDouble");
var histogramWithoutBucketsAndMinMaxLong = meter.CreateHistogram<long>("histogramWithoutBucketsAndMinMaxLong");
Expand Down Expand Up @@ -553,7 +553,7 @@ public void TestExemplarsExponentialHistogram(MetricReaderTemporalityPreference
DateTime testStartTime = DateTime.UtcNow;
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());
var exponentialHistogramWithMinMaxDouble = meter.CreateHistogram<double>("exponentialHistogramWithMinMaxDouble");
var exponentialHistogramDouble = meter.CreateHistogram<double>("exponentialHistogramDouble");
var exponentialHistogramWithMinMaxLong = meter.CreateHistogram<long>("exponentialHistogramWithMinMaxLong");
Expand Down Expand Up @@ -674,7 +674,7 @@ public void TestTraceBasedExemplarFilter(bool enableTracing)
{
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());

var counter = meter.CreateCounter<long>("testCounter");

Expand Down Expand Up @@ -721,7 +721,7 @@ public void TestExemplarsFilterTags(bool enableTagFiltering)
{
var exportedItems = new List<Metric>();

using var meter = new Meter($"{Utils.GetCurrentMethodName()}");
using var meter = new Meter(Utils.GetCurrentMethodName());

var histogram = meter.CreateHistogram<double>("testHistogram");

Expand Down
14 changes: 7 additions & 7 deletions test/OpenTelemetry.Tests/Metrics/MetricViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1049,7 +1049,7 @@ public void ViewConflict_OneInstrument_DifferentDescription()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1152,7 +1152,7 @@ public void ViewConflict_TwoDistinctInstruments_ThreeStreams()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1216,7 +1216,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_DifferentTags()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1263,7 +1263,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_SameTags()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1311,7 +1311,7 @@ public void ViewConflict_TwoIdenticalInstruments_TwoViews_DifferentHistogramBoun
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1388,7 +1388,7 @@ public void ViewConflict_TwoInstruments_OneMatchesView()
{
var exportedItems = new List<Metric>();

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)
Expand Down Expand Up @@ -1441,7 +1441,7 @@ public void ViewConflict_TwoInstruments_ConflictAvoidedBecauseSecondInstrumentIs
{
var exportedItems = new List<Metric>();

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)
Expand Down

0 comments on commit 275a446

Please sign in to comment.