Skip to content

Commit 8bd3d50

Browse files
Merge branch 'main' into main
2 parents e10c404 + 71e6cb4 commit 8bd3d50

File tree

45 files changed

+190
-139
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+190
-139
lines changed

.github/workflows/fossa.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: FOSSA scanning
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
fossa:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
16+
17+
- uses: fossas/fossa-action@93a52ecf7c3ac7eb40f5de77fd69b1a19524de94 # v1.5.0
18+
with:
19+
api-key: ${{secrets.FOSSA_API_KEY}}
20+
team: OpenTelemetry

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ you're more than welcome to participate!
235235
([@open-telemetry/dotnet-maintainers](https://github.com/orgs/open-telemetry/teams/dotnet-maintainers)):
236236

237237
* [Alan West](https://github.com/alanwest), New Relic
238-
* [Mikel Blanchard](https://github.com/CodeBlanch), Microsoft
239238
* [Rajkumar Rangaraj](https://github.com/rajkumar-rangaraj), Microsoft
240239

241240
[Emeritus Maintainers](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#emeritus-maintainerapprovertriager):
@@ -248,6 +247,7 @@ you're more than welcome to participate!
248247
([@open-telemetry/dotnet-approvers](https://github.com/orgs/open-telemetry/teams/dotnet-approvers)):
249248

250249
* [Cijo Thomas](https://github.com/cijothomas), Microsoft
250+
* [Mikel Blanchard](https://github.com/CodeBlanch), Microsoft
251251
* [Piotr Kiełkowicz](https://github.com/Kielek), Splunk
252252

253253
[Emeritus Approvers](https://github.com/open-telemetry/community/blob/main/guides/contributor/membership.md#emeritus-maintainerapprovertriager):

docs/metrics/customizing-the-sdk/Program.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ public static void Main()
2929
.AddView(instrumentName: "MyCounter", name: "MyCounterRenamed")
3030

3131
// Change Histogram boundaries using the Explicit Bucket Histogram aggregation.
32-
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 } })
32+
.AddView(instrumentName: "MyHistogram", new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0] })
3333

3434
// Change Histogram to use the Base2 Exponential Bucket Histogram aggregation.
3535
.AddView(instrumentName: "MyExponentialBucketHistogram", new Base2ExponentialBucketHistogramConfiguration())
3636

3737
// For the instrument "MyCounterCustomTags", aggregate with only the keys "tag1", "tag2".
38-
.AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = new string[] { "tag1", "tag2" } })
38+
.AddView(instrumentName: "MyCounterCustomTags", new MetricStreamConfiguration() { TagKeys = ["tag1", "tag2"] })
3939

4040
// Drop the instrument "MyCounterDrop".
4141
.AddView(instrumentName: "MyCounterDrop", MetricStreamConfiguration.Drop)
4242

4343
// Configure the Explicit Bucket Histogram aggregation with custom boundaries and new name.
44-
.AddView(instrumentName: "histogramWithMultipleAggregations", new ExplicitBucketHistogramConfiguration() { Boundaries = new double[] { 10, 20 }, Name = "MyHistogramWithExplicitHistogram" })
44+
.AddView(instrumentName: "histogramWithMultipleAggregations", new ExplicitBucketHistogramConfiguration() { Boundaries = [10.0, 20.0], Name = "MyHistogramWithExplicitHistogram" })
4545

4646
// Use Base2 Exponential Bucket Histogram aggregation and new name.
4747
.AddView(instrumentName: "histogramWithMultipleAggregations", new Base2ExponentialBucketHistogramConfiguration() { Name = "MyHistogramWithBase2ExponentialBucketHistogram" })

examples/AspNetCore/Controllers/WeatherForecastController.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ namespace Examples.AspNetCore.Controllers;
1212
[Route("[controller]")]
1313
public class WeatherForecastController : ControllerBase
1414
{
15-
private static readonly string[] Summaries = new[]
16-
{
17-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching",
18-
};
15+
private static readonly string[] Summaries =
16+
[
17+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
18+
];
1919

2020
private static readonly HttpClient HttpClient = new();
2121

examples/Console/TestPrometheusExporter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ internal static int Run(PrometheusOptions options)
3535
.AddMeter(MyMeter.Name)
3636
.AddMeter(MyMeter2.Name)
3737
.AddPrometheusHttpListener(
38-
o => o.UriPrefixes = new string[] { $"http://localhost:{options.Port}/" })
38+
o => o.UriPrefixes = [$"http://localhost:{options.Port}/"])
3939
.Build();
4040

4141
var process = Process.GetCurrentProcess();

src/OpenTelemetry.Api/Context/Propagation/B3Propagator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public sealed class B3Propagator : TextMapPropagator
3535
// "Debug" sampled value.
3636
internal const string FlagsValue = "1";
3737

38-
private static readonly HashSet<string> AllFields = new() { XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags };
38+
private static readonly HashSet<string> AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags];
3939

4040
private static readonly HashSet<string> SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue };
4141

src/OpenTelemetry.Api/Context/Propagation/BaggagePropagator.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public class BaggagePropagator : TextMapPropagator
2020
private const int MaxBaggageLength = 8192;
2121
private const int MaxBaggageItems = 180;
2222

23-
private static readonly char[] EqualSignSeparator = new[] { '=' };
24-
private static readonly char[] CommaSignSeparator = new[] { ',' };
23+
private static readonly char[] EqualSignSeparator = ['='];
24+
private static readonly char[] CommaSignSeparator = [','];
2525

2626
/// <inheritdoc/>
2727
public override ISet<string> Fields => new HashSet<string> { BaggageHeaderName };

src/OpenTelemetry.Api/Logs/LogRecordSeverityExtensions.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static class LogRecordSeverityExtensions
5757
internal const string Fatal3ShortName = FatalShortName + "3";
5858
internal const string Fatal4ShortName = FatalShortName + "4";
5959

60-
private static readonly string[] LogRecordSeverityShortNames = new string[]
61-
{
60+
private static readonly string[] LogRecordSeverityShortNames =
61+
[
6262
UnspecifiedShortName,
6363

6464
TraceShortName,
@@ -89,8 +89,8 @@ static class LogRecordSeverityExtensions
8989
FatalShortName,
9090
Fatal2ShortName,
9191
Fatal3ShortName,
92-
Fatal4ShortName,
93-
};
92+
Fatal4ShortName
93+
];
9494

9595
/// <summary>
9696
/// Returns the OpenTelemetry Specification short name for the <see

src/OpenTelemetry.Exporter.Console/Implementation/ConsoleTagWriter.cs

+7
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ protected override void OnUnsupportedTagDropped(
7373
this.onUnsupportedTagDropped(tagKey, tagValueTypeFullName);
7474
}
7575

76+
protected override bool TryWriteEmptyTag(ref ConsoleTag consoleTag, string key, object? value)
77+
{
78+
consoleTag.Key = key;
79+
consoleTag.Value = null;
80+
return true;
81+
}
82+
7683
internal struct ConsoleTag
7784
{
7885
public string? Key;

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Notes](../../RELEASENOTES.md).
1616
`Activity.StatusDescription` exceeds 127 bytes.
1717
([#6119](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6119))
1818

19+
* Fixed incorrect log serialization of attributes with null values, causing
20+
some backends to reject logs.
21+
([#6149](https://github.com/open-telemetry/opentelemetry-dotnet/pull/6149))
22+
1923
## 1.11.1
2024

2125
Released 2025-Jan-22

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/Implementation/Serializer/ProtobufOtlpTagWriter.cs

+7
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ protected override void OnUnsupportedTagDropped(
8181
tagValueTypeFullName,
8282
tagKey);
8383

84+
protected override bool TryWriteEmptyTag(ref OtlpTagWriterState state, string key, object? value)
85+
{
86+
state.WritePosition = ProtobufSerializer.WriteStringWithTag(state.Buffer, state.WritePosition, ProtobufOtlpCommonFieldNumberConstants.KeyValue_Key, key);
87+
state.WritePosition = ProtobufSerializer.WriteTagAndLength(state.Buffer, state.WritePosition, 0, ProtobufOtlpCommonFieldNumberConstants.KeyValue_Value, ProtobufWireType.LEN);
88+
return true;
89+
}
90+
8491
internal struct OtlpTagWriterState
8592
{
8693
public byte[] Buffer;

src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OtlpExporterOptionsExtensions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static THeaders GetHeaders<THeaders>(this OtlpExporterOptions options, Ac
6565
{
6666
// Specify the maximum number of substrings to return to 2
6767
// This treats everything that follows the first `=` in the string as the value to be added for the metadata key
68-
var keyValueData = pair.Split(new char[] { '=' }, 2);
68+
var keyValueData = pair.Split(['='], 2);
6969
if (keyValueData.Length != 2)
7070
{
7171
throw new ArgumentException("Headers provided in an invalid format.");
@@ -174,11 +174,11 @@ public static void TryEnableIHttpClientFactoryIntegration(this OtlpExporterOptio
174174
"CreateClient",
175175
BindingFlags.Public | BindingFlags.Instance,
176176
binder: null,
177-
new Type[] { typeof(string) },
177+
[typeof(string)],
178178
modifiers: null);
179179
if (createClientMethod != null)
180180
{
181-
HttpClient? client = (HttpClient?)createClientMethod.Invoke(httpClientFactory, new object[] { httpClientName });
181+
HttpClient? client = (HttpClient?)createClientMethod.Invoke(httpClientFactory, [httpClientName]);
182182

183183
if (client != null)
184184
{

src/OpenTelemetry.Exporter.Prometheus.HttpListener/PrometheusHttpListenerOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class PrometheusHttpListenerOptions
1212
{
1313
internal const string DefaultScrapeEndpointPath = "/metrics";
1414

15-
private IReadOnlyCollection<string> uriPrefixes = new[] { "http://localhost:9464/" };
15+
private IReadOnlyCollection<string> uriPrefixes = ["http://localhost:9464/"];
1616

1717
/// <summary>
1818
/// Gets or sets the path to use for the scraping endpoint. Default value: "/metrics".

src/OpenTelemetry.Exporter.Zipkin/Implementation/ZipkinTagWriter.cs

+2
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,6 @@ protected override void OnUnsupportedTagDropped(
6464
tagValueTypeFullName,
6565
tagKey);
6666
}
67+
68+
protected override bool TryWriteEmptyTag(ref Utf8JsonWriter state, string key, object? value) => false;
6769
}

src/OpenTelemetry.Exporter.Zipkin/ZipkinExporterHelperExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private static BaseProcessor<Activity> BuildZipkinExporterProcessor(
9191
"CreateClient",
9292
BindingFlags.Public | BindingFlags.Instance,
9393
binder: null,
94-
new Type[] { typeof(string) },
94+
[typeof(string)],
9595
modifiers: null);
9696
if (createClientMethod != null)
9797
{

src/OpenTelemetry.Extensions.Propagators/B3Propagator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public sealed class B3Propagator : TextMapPropagator
3535
// "Debug" sampled value.
3636
internal const string FlagsValue = "1";
3737

38-
private static readonly HashSet<string> AllFields = new() { XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags };
38+
private static readonly HashSet<string> AllFields = [XB3TraceId, XB3SpanId, XB3ParentSpanId, XB3Sampled, XB3Flags];
3939

4040
private static readonly HashSet<string> SampledValues = new(StringComparer.Ordinal) { SampledValue, LegacySampledValue };
4141

src/OpenTelemetry.Extensions.Propagators/JaegerPropagator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class JaegerPropagator : TextMapPropagator
1717
internal const string JaegerDelimiterEncoded = "%3A"; // while the spec defines the delimiter as a ':', some clients will url encode headers.
1818
internal const string SampledValue = "1";
1919

20-
internal static readonly string[] JaegerDelimiters = { JaegerDelimiter, JaegerDelimiterEncoded };
20+
internal static readonly string[] JaegerDelimiters = [JaegerDelimiter, JaegerDelimiterEncoded];
2121

2222
private static readonly int TraceId128BitLength = "0af7651916cd43dd8448eb211c80319c".Length;
2323
private static readonly int SpanIdLength = "00f067aa0ba902b7".Length;

src/OpenTelemetry.Shims.OpenTracing/TracerShim.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private TextMapPropagator Propagator
7676

7777
foreach (var entry in textMapCarrier)
7878
{
79-
carrierMap.Add(entry.Key, new[] { entry.Value });
79+
carrierMap.Add(entry.Key, [entry.Value]);
8080
}
8181

8282
static IEnumerable<string>? GetCarrierKeyValue(Dictionary<string, IEnumerable<string>> source, string key)

src/Shared/MathHelper.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ namespace OpenTelemetry.Internal;
1212
internal static class MathHelper
1313
{
1414
// https://en.wikipedia.org/wiki/Leading_zero
15-
private static readonly byte[] LeadingZeroLookupTable = new byte[]
16-
{
15+
private static readonly byte[] LeadingZeroLookupTable =
16+
[
1717
8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
1818
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
1919
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
@@ -29,8 +29,8 @@ internal static class MathHelper
2929
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3030
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3131
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
32-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33-
};
32+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
33+
];
3434

3535
[MethodImpl(MethodImplOptions.AggressiveInlining)]
3636
public static int LeadingZero8(byte value)

src/Shared/Shims/NullableAttributes.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal sealed class MemberNotNullWhenAttribute : Attribute
5151
public MemberNotNullWhenAttribute(bool returnValue, string member)
5252
{
5353
ReturnValue = returnValue;
54-
Members = new[] { member };
54+
Members = [member];
5555
}
5656

5757
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)

src/Shared/TagWriter/TagWriter.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public bool TryWriteTag(
3636
{
3737
if (value == null)
3838
{
39-
return false;
39+
return this.TryWriteEmptyTag(ref state, key, value);
4040
}
4141

4242
switch (value)
@@ -117,6 +117,8 @@ public bool TryWriteTag(
117117
return true;
118118
}
119119

120+
protected abstract bool TryWriteEmptyTag(ref TTagState state, string key, object? value);
121+
120122
protected abstract void WriteIntegralTag(ref TTagState state, string key, long value);
121123

122124
protected abstract void WriteFloatingPointTag(ref TTagState state, string key, double value);

test/Benchmarks/Metrics/ExemplarBenchmarks.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace Benchmarks.Metrics;
4141
public class ExemplarBenchmarks
4242
{
4343
private static readonly ThreadLocal<Random> ThreadLocalRandom = new(() => new Random());
44-
private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
44+
private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"];
4545
private Histogram<double>? histogramWithoutTagReduction;
4646
private Histogram<double>? histogramWithTagReduction;
4747
private Counter<long>? counterWithoutTagReduction;
@@ -86,7 +86,7 @@ public void Setup()
8686
{
8787
return new MetricStreamConfiguration()
8888
{
89-
TagKeys = new string[] { "DimName1", "DimName2", "DimName3" },
89+
TagKeys = ["DimName1", "DimName2", "DimName3"],
9090
ExemplarReservoirFactory = CreateExemplarReservoir,
9191
};
9292
}

test/Benchmarks/Metrics/HistogramBenchmarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class HistogramBenchmarks
4646
{
4747
private const int MaxValue = 10000;
4848
private readonly Random random = new();
49-
private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
49+
private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"];
5050
private Histogram<long>? histogram;
5151
private MeterProvider? meterProvider;
5252
private Meter? meter;

test/Benchmarks/Metrics/MetricCollectBenchmarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Benchmarks.Metrics;
2525

2626
public class MetricCollectBenchmarks
2727
{
28-
private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
28+
private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"];
2929

3030
// TODO: Confirm if this needs to be thread-safe
3131
private readonly Random random = new();

test/Benchmarks/Metrics/MetricsBenchmarks.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace Benchmarks.Metrics;
5959
public class MetricsBenchmarks
6060
{
6161
private readonly Random random = new();
62-
private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
62+
private readonly string[] dimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"];
6363
private Counter<long>? counter;
6464
private MeterProvider? meterProvider;
6565
private Meter? meter;

test/Benchmarks/Metrics/MetricsViewBenchmarks.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace Benchmarks.Metrics;
3030
public class MetricsViewBenchmarks
3131
{
3232
private static readonly ThreadLocal<Random> ThreadLocalRandom = new(() => new Random());
33-
private static readonly string[] DimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
33+
private static readonly string[] DimensionValues = ["DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10"];
3434
private static readonly int DimensionsValuesLength = DimensionValues.Length;
3535
private List<Metric>? metrics;
3636
private Counter<long>? counter;
@@ -96,15 +96,15 @@ public void Setup()
9696
{
9797
this.meterProvider = Sdk.CreateMeterProviderBuilder()
9898
.AddMeter(this.meter.Name)
99-
.AddView("nomatch", new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } })
99+
.AddView("nomatch", new MetricStreamConfiguration() { TagKeys = ["DimName1", "DimName2", "DimName3"] })
100100
.AddInMemoryExporter(this.metrics)
101101
.Build();
102102
}
103103
else if (this.ViewConfig == ViewConfiguration.ViewApplied)
104104
{
105105
this.meterProvider = Sdk.CreateMeterProviderBuilder()
106106
.AddMeter(this.meter.Name)
107-
.AddView(this.counter.Name, new MetricStreamConfiguration() { TagKeys = new string[] { "DimName1", "DimName2", "DimName3" } })
107+
.AddView(this.counter.Name, new MetricStreamConfiguration() { TagKeys = ["DimName1", "DimName2", "DimName3"] })
108108
.AddInMemoryExporter(this.metrics)
109109
.Build();
110110
}

test/OpenTelemetry.Api.Tests/Context/Propagation/CompositePropagatorTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class CompositePropagatorTest
1414
count++;
1515
if (headers.TryGetValue(name, out var value))
1616
{
17-
return new[] { value };
17+
return [value];
1818
}
1919

2020
return Empty;

test/OpenTelemetry.Api.Tests/Trace/SpanAttributesTest.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ public void ValidateAddMethods()
1919
{
2020
var spanAttribute = new SpanAttributes();
2121
spanAttribute.Add("key_string", "string");
22-
spanAttribute.Add("key_a_string", new string[] { "string" });
22+
spanAttribute.Add("key_a_string", ["string"]);
2323

2424
spanAttribute.Add("key_double", 1.01);
25-
spanAttribute.Add("key_a_double", new double[] { 1.01 });
25+
spanAttribute.Add("key_a_double", [1.01]);
2626

2727
spanAttribute.Add("key_bool", true);
28-
spanAttribute.Add("key_a_bool", new bool[] { true });
28+
spanAttribute.Add("key_a_bool", [true]);
2929

3030
spanAttribute.Add("key_long", 1);
31-
spanAttribute.Add("key_a_long", new long[] { 1 });
31+
spanAttribute.Add("key_a_long", [1L]);
3232

3333
Assert.Equal(8, spanAttribute.Attributes.Count);
3434
}

test/OpenTelemetry.Exporter.Console.Tests/ConsoleActivityExporterTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public void VerifyConsoleActivityExporterDoesntFailWithoutActivityLinkTags()
4343

4444
// Test that the ConsoleExporter correctly handles an Activity without Tags.
4545
using var consoleExporter = new ConsoleActivityExporter(new ConsoleExporterOptions());
46-
Assert.Equal(ExportResult.Success, consoleExporter.Export(new Batch<Activity>(new[] { activity }, 1)));
46+
Assert.Equal(ExportResult.Success, consoleExporter.Export(new Batch<Activity>([activity], 1)));
4747
}
4848
}

0 commit comments

Comments
 (0)