Skip to content

Commit

Permalink
Merge branch 'main' into consoleexporter-loggerproviderbuilder-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored Jun 2, 2023
2 parents a96fb32 + e67d44e commit 3ce59d7
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.Console/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Remove support for exporting `Exemplars`. This would be added back in the
`1.6.*` prerelease versions right after `1.5.0` stable version is released.
([#4533](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4533))

## 1.5.0-rc.1

Released 2023-May-25
Expand Down
4 changes: 4 additions & 0 deletions src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

* Remove support for exporting `Exemplars`. This would be added back in the
`1.6.*` prerelease versions right after `1.5.0` stable version is released.
([#4533](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4533))

## 1.5.0-rc.1

Released 2023-May-25
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
// </copyright>

using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Tracing;
using OpenTelemetry.Internal;

Expand Down Expand Up @@ -57,12 +58,14 @@ public void RequestIsFilteredOut(string handlerName, string eventName, string op
this.WriteEvent(2, handlerName, eventName, operationName);
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe.")]
[Event(3, Message = "Filter threw exception, request will not be collected. HandlerName: '{0}', EventName: '{1}', OperationName: '{2}', Exception: {3}.", Level = EventLevel.Error)]
public void RequestFilterException(string handlerName, string eventName, string operationName, string exception)
{
this.WriteEvent(3, handlerName, eventName, operationName, exception);
}

[UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "Parameters to this method are primitive and are trimmer safe.")]
[Event(4, Message = "Enrich threw exception. HandlerName: '{0}', EventName: '{1}', OperationName: '{2}', Exception: {3}.", Level = EventLevel.Warning)]
public void EnrichmentException(string handlerName, string eventName, string operationName, string exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Instrumentation.GrpcNetClient\StatusCanonicalCode.cs" Link="Includes\StatusCanonicalCode.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\Guard.cs" Link="Includes\Guard.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry.Api\Internal\HttpSemanticConventionHelper.cs" Link="Includes\HttpSemanticConventionHelper.cs" />
<Compile Include="$(RepoRoot)\src\OpenTelemetry\Internal\Shims\UnconditionalSuppressMessageAttribute.cs" Link="Includes\UnconditionalSuppressMessageAttribute.cs" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/OpenTelemetry/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
chained/fluent calls.
([#4529](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4529))

* Marked `Exemplars` and related APIs `internal` as the spec for `Exemplars` is
not stable yet. This would be added back in the `1.6.*` prerelease versions
right after `1.5.0` stable version is released.
([#4533](https://github.com/open-telemetry/opentelemetry-dotnet/pull/4533))

## 1.5.0-rc.1

Released 2023-May-25
Expand Down
6 changes: 3 additions & 3 deletions src/OpenTelemetry/Internal/Options/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static bool TryGetStringValue(
#endif
out string? value)
{
value = configuration.GetValue<string?>(key, null);
value = configuration[key] is string configValue ? configValue : null;

return !string.IsNullOrWhiteSpace(value);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ public static IServiceCollection RegisterOptionsFactory<T>(
Debug.Assert(services != null, "services was null");
Debug.Assert(optionsFactoryFunc != null, "optionsFactoryFunc was null");

services!.TryAddSingleton<IOptionsFactory<T>>(sp =>
services.TryAddSingleton<IOptionsFactory<T>>(sp =>
{
return new DelegatingOptionsFactory<T>(
(c, n) => optionsFactoryFunc!(c),
Expand All @@ -146,7 +146,7 @@ public static IServiceCollection RegisterOptionsFactory<T>(
Debug.Assert(services != null, "services was null");
Debug.Assert(optionsFactoryFunc != null, "optionsFactoryFunc was null");

services!.TryAddSingleton<IOptionsFactory<T>>(sp =>
services.TryAddSingleton<IOptionsFactory<T>>(sp =>
{
return new DelegatingOptionsFactory<T>(
(c, n) => optionsFactoryFunc!(sp, c, n),
Expand Down
128 changes: 128 additions & 0 deletions test/Benchmarks/Metrics/Base2ExponentialHistogramBenchmarks.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// <copyright file="Base2ExponentialHistogramBenchmarks.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System.Diagnostics;
using System.Diagnostics.Metrics;
using BenchmarkDotNet.Attributes;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Tests;

/*
BenchmarkDotNet=v0.13.5, OS=Windows 11 (10.0.23424.1000)
Intel Core i7-9700 CPU 3.00GHz, 1 CPU, 8 logical and 8 physical cores
.NET SDK=7.0.203
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
DefaultJob : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
| Method | Mean | Error | StdDev | Allocated |
|---------------------------- |----------:|---------:|---------:|----------:|
| HistogramHotPath | 54.78 ns | 0.907 ns | 0.848 ns | - |
| HistogramWith1LabelHotPath | 115.37 ns | 0.388 ns | 0.363 ns | - |
| HistogramWith3LabelsHotPath | 228.03 ns | 3.767 ns | 3.146 ns | - |
| HistogramWith5LabelsHotPath | 316.60 ns | 5.980 ns | 9.311 ns | - |
| HistogramWith7LabelsHotPath | 366.86 ns | 2.694 ns | 3.596 ns | - |
*/

namespace Benchmarks.Metrics;

public class Base2ExponentialHistogramBenchmarks
{
private const int MaxValue = 10000;
private readonly Random random = new();
private readonly string[] dimensionValues = new string[] { "DimVal1", "DimVal2", "DimVal3", "DimVal4", "DimVal5", "DimVal6", "DimVal7", "DimVal8", "DimVal9", "DimVal10" };
private Histogram<long> histogram;
private MeterProvider provider;
private Meter meter;

[GlobalSetup]
public void Setup()
{
this.meter = new Meter(Utils.GetCurrentMethodName());
this.histogram = this.meter.CreateHistogram<long>("histogram");

var exportedItems = new List<Metric>();

this.provider = Sdk.CreateMeterProviderBuilder()
.AddMeter(this.meter.Name)
.AddInMemoryExporter(exportedItems, metricReaderOptions =>
{
metricReaderOptions.PeriodicExportingMetricReaderOptions.ExportIntervalMilliseconds = 1000;
})
.AddView("histogram", new Base2ExponentialBucketHistogramConfiguration())
.Build();
}

[GlobalCleanup]
public void Cleanup()
{
this.meter?.Dispose();
this.provider?.Dispose();
}

[Benchmark]
public void HistogramHotPath()
{
this.histogram.Record(this.random.Next(MaxValue));
}

[Benchmark]
public void HistogramWith1LabelHotPath()
{
var tag1 = new KeyValuePair<string, object>("DimName1", this.dimensionValues[this.random.Next(0, 2)]);
this.histogram.Record(this.random.Next(MaxValue), tag1);
}

[Benchmark]
public void HistogramWith3LabelsHotPath()
{
var tag1 = new KeyValuePair<string, object>("DimName1", this.dimensionValues[this.random.Next(0, 10)]);
var tag2 = new KeyValuePair<string, object>("DimName2", this.dimensionValues[this.random.Next(0, 10)]);
var tag3 = new KeyValuePair<string, object>("DimName3", this.dimensionValues[this.random.Next(0, 10)]);
this.histogram.Record(this.random.Next(MaxValue), tag1, tag2, tag3);
}

[Benchmark]
public void HistogramWith5LabelsHotPath()
{
var tags = new TagList
{
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
{ "DimName2", this.dimensionValues[this.random.Next(0, 2)] },
{ "DimName3", this.dimensionValues[this.random.Next(0, 5)] },
{ "DimName4", this.dimensionValues[this.random.Next(0, 5)] },
{ "DimName5", this.dimensionValues[this.random.Next(0, 10)] },
};
this.histogram.Record(this.random.Next(MaxValue), tags);
}

[Benchmark]
public void HistogramWith7LabelsHotPath()
{
var tags = new TagList
{
{ "DimName1", this.dimensionValues[this.random.Next(0, 2)] },
{ "DimName2", this.dimensionValues[this.random.Next(0, 2)] },
{ "DimName3", this.dimensionValues[this.random.Next(0, 5)] },
{ "DimName4", this.dimensionValues[this.random.Next(0, 5)] },
{ "DimName5", this.dimensionValues[this.random.Next(0, 5)] },
{ "DimName6", this.dimensionValues[this.random.Next(0, 2)] },
{ "DimName7", this.dimensionValues[this.random.Next(0, 1)] },
};
this.histogram.Record(this.random.Next(MaxValue), tags);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="ExponentialHistogramMapToIndexBenchmarks.cs" company="OpenTelemetry Authors">
// <copyright file="Base2ExponentialHistogramMapToIndexBenchmarks.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -34,7 +34,7 @@

namespace Benchmarks.Metrics;

public class ExponentialHistogramMapToIndexBenchmarks
public class Base2ExponentialHistogramMapToIndexBenchmarks
{
private const int MaxValue = 10000;
private readonly Random random = new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="ExponentialHistogramBenchmarks.cs" company="OpenTelemetry Authors">
// <copyright file="Base2ExponentialHistogramScaleBenchmarks.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -37,7 +37,7 @@

namespace Benchmarks.Metrics;

public class ExponentialHistogramBenchmarks
public class Base2ExponentialHistogramScaleBenchmarks
{
private const int MaxValue = 10000;
private readonly Random random = new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ public void EnsureAotCompatibility()
process.Start();
process.BeginOutputReadLine();

Assert.True(process.WaitForExit(milliseconds: 180_000), "dotnet publish command timed out after 180 seconds.");
Assert.True(process.WaitForExit(milliseconds: 240_000), "dotnet publish command timed out after 240 seconds.");
Assert.True(process.ExitCode == 0, "Publishing the AotCompatibility app failed. See test output for more details.");

var warnings = expectedOutput.ToString().Split('\n', '\r').Where(line => line.Contains("warning IL"));
Assert.Equal(48, warnings.Count());
Assert.Equal(43, warnings.Count());
}
}
}

0 comments on commit 3ce59d7

Please sign in to comment.