From ebc40a0326cdddb07337413eef2a2b4cb00231fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Thu, 7 Sep 2023 20:18:48 +0200 Subject: [PATCH 1/4] Bump OTel SDK/API to 1.6.0 (#1344) --- build/Common.props | 2 +- src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Exporter.Instana/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md | 3 +++ src/OpenTelemetry.Exporter.Stackdriver/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Extensions.AWS/CHANGELOG.md | 3 +++ src/OpenTelemetry.Extensions/CHANGELOG.md | 4 ++-- .../CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Cassandra/CHANGELOG.md | 4 ++-- .../CHANGELOG.md | 4 ++-- .../CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md | 3 +++ src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md | 2 ++ .../OpenTelemetry.Instrumentation.GrpcCore.csproj | 2 +- src/OpenTelemetry.Instrumentation.Hangfire/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md | 3 +++ .../CHANGELOG.md | 4 ++-- src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md | 3 +++ src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md | 3 +++ src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md | 2 ++ src/OpenTelemetry.ResourceDetectors.Container/CHANGELOG.md | 4 ++-- src/OpenTelemetry.Sampler.AWS/CHANGELOG.md | 4 ++-- 25 files changed, 54 insertions(+), 32 deletions(-) diff --git a/build/Common.props b/build/Common.props index 0ad217d7e2..23c26c4c70 100644 --- a/build/Common.props +++ b/build/Common.props @@ -35,7 +35,7 @@ [4.2.2,5.0) [3.3.3] [1.1.1,2.0) - [1.5.1,2.0) + [1.6.0,2.0) [1.6.0-rc.1] [2.1.58,3.0) [3.16.0,4.0) diff --git a/src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md b/src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md index 95c765fdf0..6648363039 100644 --- a/src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.InfluxDB/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Updates to 1.5.1 of OpenTelemetry SDK. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updates to 1.6.0 of OpenTelemetry SDK. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-alpha.2 diff --git a/src/OpenTelemetry.Exporter.Instana/CHANGELOG.md b/src/OpenTelemetry.Exporter.Instana/CHANGELOG.md index 79c46ad70e..fc9fe6fc35 100644 --- a/src/OpenTelemetry.Exporter.Instana/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Instana/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OpenTelemetry SDK version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) * Drop support for .NET Framework 4.6.1. The lowest supported version is .NET Framework 4.6.2. ([#1050](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1050)) diff --git a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md index cad40dcf22..ab3c6dee3c 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.OneCollector/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Update OpenTelemetry to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + * Added support for receiving tranmission failures via the `RegisterPayloadTransmittedCallback` API. ([#1309](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1309)) diff --git a/src/OpenTelemetry.Exporter.Stackdriver/CHANGELOG.md b/src/OpenTelemetry.Exporter.Stackdriver/CHANGELOG.md index 1bc55d3b9c..8625decb38 100644 --- a/src/OpenTelemetry.Exporter.Stackdriver/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Stackdriver/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OpenTelemetry SDK version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.4 diff --git a/src/OpenTelemetry.Extensions.AWS/CHANGELOG.md b/src/OpenTelemetry.Extensions.AWS/CHANGELOG.md index 123106331e..24187e865d 100644 --- a/src/OpenTelemetry.Extensions.AWS/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions.AWS/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Updates to 1.6.0 of OpenTelemetry SDK. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + ## 1.3.0-beta.1 Released 2023-Aug-02 diff --git a/src/OpenTelemetry.Extensions/CHANGELOG.md b/src/OpenTelemetry.Extensions/CHANGELOG.md index d082f2fbd7..e4c18b64f4 100644 --- a/src/OpenTelemetry.Extensions/CHANGELOG.md +++ b/src/OpenTelemetry.Extensions/CHANGELOG.md @@ -5,8 +5,8 @@ * Add LogToActivityEventConversionOptions.Filter callback ([#1059](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1059)) -* Update OpenTelemetry SDK version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.4 diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md index 5ef11fa761..4435c22bc6 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update `OpenTelemetry.Api` to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update `OpenTelemetry.Api` to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-rc9.9 diff --git a/src/OpenTelemetry.Instrumentation.Cassandra/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Cassandra/CHANGELOG.md index 2bbc9b4fb9..36ef3e4e21 100644 --- a/src/OpenTelemetry.Instrumentation.Cassandra/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Cassandra/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Updates to 1.5.1 of OpenTelemetry SDK. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updates to 1.6.0 of OpenTelemetry SDK. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.1 diff --git a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md index 30f981b720..fad5bc76af 100644 --- a/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.ElasticsearchClient/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Updated OpenTelemetry SDK package version to 1.5.1 - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updated OpenTelemetry SDK package version to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.4 diff --git a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md index a19e674118..c6b9ff81d9 100644 --- a/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md @@ -6,8 +6,8 @@ enable filtering of instrumentation. ([#1203](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1203)) -* Updated OpenTelemetry SDK package version to 1.5.1 - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updated OpenTelemetry SDK package version to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.7 diff --git a/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md index 3d916e40a1..0feb5d5842 100644 --- a/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.EventCounters/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Update OpenTelemetry.Api to 1.6.0. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + ## 1.5.1-alpha.1 Released 2023-Jul-11 diff --git a/src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md index 828d6ce0ca..9780b5871e 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.GrpcCore/CHANGELOG.md @@ -4,6 +4,8 @@ * Make the context propagation extraction case insensitive. ([#483](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/483)) +* Update OpenTelemetry.Api to 1.6.0. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.5 diff --git a/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj b/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj index f00e38357f..8111db001c 100644 --- a/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj +++ b/src/OpenTelemetry.Instrumentation.GrpcCore/OpenTelemetry.Instrumentation.GrpcCore.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/OpenTelemetry.Instrumentation.Hangfire/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Hangfire/CHANGELOG.md index 460fcc9780..b27c06cc11 100644 --- a/src/OpenTelemetry.Instrumentation.Hangfire/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Hangfire/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OTel API version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OTel API version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.5.0-beta.1 diff --git a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md index d93af5b3fe..6fcb6bdf0d 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Owin/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Updated OpenTelemetry SDK to 1.5.1 - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updated OpenTelemetry SDK to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) * Removes `AddOwinInstrumentation` method with default configure parameter. ([#929](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/929)) diff --git a/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md index da1fa454c7..fc435aeb3b 100644 --- a/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Process/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OpenTelemetry API to 1.5.1 - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry API to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 0.5.0-beta.3 diff --git a/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md index d4fbd92dba..b31ff113c4 100644 --- a/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Quartz/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OpenTelemetry.Api to 1.5.1. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry.Api to 1.6.0. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-alpha.3 diff --git a/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md index b00428601e..49cae6d79f 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Runtime/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Update OpenTelemetry API to 1.6.0 + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + ## 1.5.1 Released 2023-Sep-06 diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md index bc017b3ad3..46ccedfb32 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Update OTel API version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OTel API version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-rc9.10 diff --git a/src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md b/src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md index 32365feb95..a73132691d 100644 --- a/src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md +++ b/src/OpenTelemetry.Instrumentation.Wcf/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + ## 1.0.0-rc.12 Released 2023-Aug-30 diff --git a/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md index bbc803c488..737f247228 100644 --- a/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.AWS/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) + ## 1.3.0-beta.1 Released 2023-Aug-02 diff --git a/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md index e6d6b70e0e..7b86d73bf1 100644 --- a/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.Azure/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Updates to 1.6.0 of OpenTelemetry SDK. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) * Suppress instrumentation for outgoing http call made to metadata service during `Detect()`. ([#1297](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1297)) diff --git a/src/OpenTelemetry.ResourceDetectors.Container/CHANGELOG.md b/src/OpenTelemetry.ResourceDetectors.Container/CHANGELOG.md index 3e786badce..76f6218b5a 100644 --- a/src/OpenTelemetry.ResourceDetectors.Container/CHANGELOG.md +++ b/src/OpenTelemetry.ResourceDetectors.Container/CHANGELOG.md @@ -2,8 +2,8 @@ ## Unreleased -* Updates to 1.5.1 of OpenTelemetry SDK. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Updates to 1.6.0 of OpenTelemetry SDK. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) ## 1.0.0-beta.4 diff --git a/src/OpenTelemetry.Sampler.AWS/CHANGELOG.md b/src/OpenTelemetry.Sampler.AWS/CHANGELOG.md index 18cbfef88b..36a41a1816 100644 --- a/src/OpenTelemetry.Sampler.AWS/CHANGELOG.md +++ b/src/OpenTelemetry.Sampler.AWS/CHANGELOG.md @@ -8,5 +8,5 @@ Initial release of `OpenTelemetry.Sampler.AWS`. ([#1091](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1091), [#1124](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1124)) -* Update OpenTelemetry SDK version to `1.5.1`. - ([#1255](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1255)) +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1344](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1344)) From a5a584eded58230330f131cd15df453ac1da6e08 Mon Sep 17 00:00:00 2001 From: Mikel Blanchard Date: Thu, 7 Sep 2023 11:41:35 -0700 Subject: [PATCH 2/4] [repo+ci] Use SDK dotnet format in CI (#1339) --- .github/workflows/dotnet-format.yml | 10 +- build/Common.prod.props | 1 - build/Common.props | 4 +- build/Common.targets | 4 - examples/AspNet/App_Start/RouteConfig.cs | 21 ++-- examples/AspNet/Controllers/HomeController.cs | 2 + .../Controllers/WeatherForecastController.cs | 32 +++-- examples/AspNet/Examples.AspNet.csproj | 76 +++--------- examples/AspNet/Global.asax.cs | 12 +- examples/AspNet/Properties/AssemblyInfo.cs | 28 ----- .../AspNet/Properties/launchSettings.json | 18 +++ examples/AspNet/Web.config | 114 +++++++++--------- examples/Directory.Build.props | 1 + opentelemetry-dotnet-contrib.sln | 7 ++ .../OpenTelemetry.Exporter.Geneva.csproj | 1 - .../OpenTelemetry.Exporter.InfluxDB.csproj | 1 - ...OpenTelemetry.Exporter.OneCollector.csproj | 1 - .../OpenTelemetry.Extensions.csproj | 1 - ...metry.Instrumentation.EventCounters.csproj | 1 - .../OpenTelemetry.Instrumentation.Owin.csproj | 1 - ...enTelemetry.Instrumentation.Process.csproj | 1 - ...enTelemetry.Instrumentation.Runtime.csproj | 1 - ....Instrumentation.StackExchangeRedis.csproj | 1 - ...etry.PersistentStorage.Abstractions.csproj | 1 - ...enTelemetry.ResourceDetectors.Azure.csproj | 1 - .../AWSXRaySamplerClient.cs | 4 +- src/Shared/ExceptionExtensions.cs | 12 +- ...enTelemetry.Exporter.InfluxDB.Tests.csproj | 1 - ...ry.Exporter.OneCollector.Benchmarks.csproj | 1 - ...lemetry.Exporter.OneCollector.Tests.csproj | 1 - 30 files changed, 160 insertions(+), 200 deletions(-) create mode 100644 examples/AspNet/Properties/launchSettings.json diff --git a/.github/workflows/dotnet-format.yml b/.github/workflows/dotnet-format.yml index 48876d69ba..f9886e9f5e 100644 --- a/.github/workflows/dotnet-format.yml +++ b/.github/workflows/dotnet-format.yml @@ -23,8 +23,12 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v3 - - name: Install format tool - run: dotnet tool install -g dotnet-format + - name: Install dependencies + run: dotnet restore + + - name: Protobuf compile + run: dotnet build -t:Protobuf_Compile --no-restore + continue-on-error: true # Note: Projects without Grpc.Tools won't have the Protobuf_Compile target which generates an error - name: dotnet format - run: dotnet-format --folder --check + run: dotnet format opentelemetry-dotnet-contrib.sln --no-restore --verify-no-changes diff --git a/build/Common.prod.props b/build/Common.prod.props index f6cf6b8c54..45b492423b 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -13,7 +13,6 @@ $(MSBuildThisFileDirectory)/OpenTelemetryContrib.prod.ruleset $(NoWarn),1573,1712 $(Build_ArtifactStagingDirectory) - true Observability;OpenTelemetry;Monitoring;Telemetry diff --git a/build/Common.props b/build/Common.props index 23c26c4c70..f08449f33b 100644 --- a/build/Common.props +++ b/build/Common.props @@ -1,6 +1,6 @@ - 11.0 + latest true $([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory)).Parent.FullName) $(MSBuildThisFileDirectory)debug.snk @@ -10,7 +10,7 @@ net6.0 netstandard2.0 true - latest-All + latest-all diff --git a/build/Common.targets b/build/Common.targets index 556dd88d22..faf2349bae 100644 --- a/build/Common.targets +++ b/build/Common.targets @@ -1,7 +1,3 @@ - - latest-all - - diff --git a/examples/AspNet/App_Start/RouteConfig.cs b/examples/AspNet/App_Start/RouteConfig.cs index e1c6ae4df1..80575537f6 100644 --- a/examples/AspNet/App_Start/RouteConfig.cs +++ b/examples/AspNet/App_Start/RouteConfig.cs @@ -17,20 +17,19 @@ using System.Web.Mvc; using System.Web.Routing; -namespace Examples.AspNet +namespace Examples.AspNet; + +public class RouteConfig { - public class RouteConfig + public static void RegisterRoutes(RouteCollection routes) { - public static void RegisterRoutes(RouteCollection routes) - { - routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); - routes.MapMvcAttributeRoutes(); + routes.MapMvcAttributeRoutes(); - routes.MapRoute( - name: "Default", - url: "{controller}/{action}/{id}", - defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); - } + routes.MapRoute( + name: "Default", + url: "{controller}/{action}/{id}", + defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }); } } diff --git a/examples/AspNet/Controllers/HomeController.cs b/examples/AspNet/Controllers/HomeController.cs index e8dd81a468..029e323ff0 100644 --- a/examples/AspNet/Controllers/HomeController.cs +++ b/examples/AspNet/Controllers/HomeController.cs @@ -21,11 +21,13 @@ namespace Examples.AspNet.Controllers; public class HomeController : Controller { // For testing traditional routing. Ex: https://localhost:XXXX/ + [HttpGet] public ActionResult Index() { return this.View(); } + [HttpGet] [Route("about_attr_route/{customerId}")] // For testing attribute routing. Ex: https://localhost:XXXX/about_attr_route public ActionResult About(int? customerId) { diff --git a/examples/AspNet/Controllers/WeatherForecastController.cs b/examples/AspNet/Controllers/WeatherForecastController.cs index 107c9e2bdf..1aa7e0870b 100644 --- a/examples/AspNet/Controllers/WeatherForecastController.cs +++ b/examples/AspNet/Controllers/WeatherForecastController.cs @@ -57,7 +57,7 @@ public async Task> Get(int customerId) { if (customerId < 0) { - throw new ArgumentException(); + throw new ArgumentOutOfRangeException(nameof(customerId), "CustomerId should be 0 or greater."); } // Making http calls here to serve as an example of @@ -141,7 +141,7 @@ private static async Task RequestGoogleHomPageViaHttpClient() { using var request = new HttpClient(); - using var response = await request.GetAsync("http://www.google.com").ConfigureAwait(false); + using var response = await request.GetAsync(new Uri("http://www.google.com")).ConfigureAwait(false); response.EnsureSuccessStatusCode(); } @@ -149,7 +149,7 @@ private static async Task RequestGoogleHomPageViaHttpClient() // Test dependency collection via legacy HttpWebRequest sync. private static void RequestGoogleHomPageViaHttpWebRequestLegacySync() { - var request = WebRequest.Create("http://www.google.com/?sync"); + var request = WebRequest.Create(new Uri("http://www.google.com/?sync")); using var response = request.GetResponse(); } @@ -157,7 +157,7 @@ private static void RequestGoogleHomPageViaHttpWebRequestLegacySync() // Test dependency collection via legacy HttpWebRequest async. private static async Task RequestGoogleHomPageViaHttpWebRequestLegacyAsync() { - var request = (HttpWebRequest)WebRequest.Create($"http://www.google.com/?async"); + var request = (HttpWebRequest)WebRequest.Create(new Uri("http://www.google.com/?async")); using var response = await request.GetResponseAsync().ConfigureAwait(false); } @@ -165,7 +165,7 @@ private static async Task RequestGoogleHomPageViaHttpWebRequestLegacyAsync() // Test dependency collection via legacy HttpWebRequest IAsyncResult. private static void RequestGoogleHomPageViaHttpWebRequestLegacyAsyncResult() { - var request = (HttpWebRequest)WebRequest.Create($"http://www.google.com/?async"); + var request = (HttpWebRequest)WebRequest.Create(new Uri("http://www.google.com/?async")); var asyncResult = request.BeginGetResponse(null, null); @@ -181,7 +181,9 @@ private async Task RequestInvalidViaHttpClient() // This request is not available over SSL and will throw a handshake exception. - using var response = await request.GetAsync(this.Url.Content("~/subroute/10").Replace("http", "https")).ConfigureAwait(false); + var requestUri = this.GenerateContentRequestUri("~/subroute/10", uri => uri.Replace("http", "https")); + + using var response = await request.GetAsync(requestUri).ConfigureAwait(false); Debug.Fail("Unreachable"); } @@ -197,7 +199,8 @@ private async Task RequestValidThatReturnsFailedViaHttpClient() // This request will return a 500 error because customerId should be >= 0; - using var response = await request.GetAsync(this.Url.Content("~/subroute/-1")).ConfigureAwait(false); + using var response = await request.GetAsync( + this.GenerateContentRequestUri("~/subroute/-1")).ConfigureAwait(false); Debug.Assert(response.StatusCode == HttpStatusCode.InternalServerError, "response.StatusCode is InternalServerError"); } @@ -209,8 +212,21 @@ private async Task RequestValidThatSpawnsSubSpansViaHttpClient() // This request will return successfully and cause a bunch of sub-spans; - using var response = await request.GetAsync(this.Url.Content("~/subroute/10")).ConfigureAwait(false); + using var response = await request.GetAsync( + this.GenerateContentRequestUri("~/subroute/10")).ConfigureAwait(false); response.EnsureSuccessStatusCode(); } + + private Uri GenerateContentRequestUri(string path, Func transform = null) + { + var rawUri = this.Url.Content(path); + + if (transform != null) + { + rawUri = transform(rawUri); + } + + return new(rawUri); + } } diff --git a/examples/AspNet/Examples.AspNet.csproj b/examples/AspNet/Examples.AspNet.csproj index a8a47cbb92..9443447544 100644 --- a/examples/AspNet/Examples.AspNet.csproj +++ b/examples/AspNet/Examples.AspNet.csproj @@ -1,46 +1,19 @@ - - + + - PackageReference - Debug - AnyCPU - - - 2.0 - {9A4E3A68-904B-4835-A3C8-F664B73098DB} - {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + net48 Library - Properties - OpenTelemetry.Exporter.AspNet - OpenTelemetry.Exporter.AspNet - v4.8 - true - - - - - - - - - - true - full - false - bin\ - DEBUG;TRACE - prompt - 4 - - - true - pdbonly - true bin\ - TRACE - prompt - 4 + false + false + web.config + false + + + + + @@ -87,16 +60,13 @@ - - {582b70b5-0067-4d9a-abf2-623f502be9a9} - OpenTelemetry.Instrumentation.AspNet - + 10.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + @@ -109,22 +79,4 @@ $(BuildDependsOn) SkipBuildWithoutVisualStudio - - - - - True - True - 0 - / - http://localhost:56171/ - False - False - - - False - - - - diff --git a/examples/AspNet/Global.asax.cs b/examples/AspNet/Global.asax.cs index 8250029c0d..3724b36df0 100644 --- a/examples/AspNet/Global.asax.cs +++ b/examples/AspNet/Global.asax.cs @@ -40,15 +40,15 @@ protected void Application_Start() .AddAspNetInstrumentation() .AddHttpClientInstrumentation(); - switch (ConfigurationManager.AppSettings["UseExporter"].ToLowerInvariant()) + switch (ConfigurationManager.AppSettings["UseExporter"].ToUpperInvariant()) { - case "zipkin": + case "ZIPKIN": builder.AddZipkinExporter(zipkinOptions => { zipkinOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["ZipkinEndpoint"]); }); break; - case "otlp": + case "OTLP": builder.AddOtlpExporter(otlpOptions => { otlpOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["OtlpEndpoint"]); @@ -68,15 +68,15 @@ protected void Application_Start() var meterBuilder = Sdk.CreateMeterProviderBuilder() .AddAspNetInstrumentation(); - switch (ConfigurationManager.AppSettings["UseMetricsExporter"].ToLowerInvariant()) + switch (ConfigurationManager.AppSettings["UseMetricsExporter"].ToUpperInvariant()) { - case "otlp": + case "OTLP": meterBuilder.AddOtlpExporter(otlpOptions => { otlpOptions.Endpoint = new Uri(ConfigurationManager.AppSettings["OtlpEndpoint"]); }); break; - case "prometheus": + case "PROMETHEUS": meterBuilder.AddPrometheusHttpListener(); break; default: diff --git a/examples/AspNet/Properties/AssemblyInfo.cs b/examples/AspNet/Properties/AssemblyInfo.cs index 7dd41a41ac..81534e43a0 100644 --- a/examples/AspNet/Properties/AssemblyInfo.cs +++ b/examples/AspNet/Properties/AssemblyInfo.cs @@ -14,37 +14,9 @@ // limitations under the License. // -using System.Reflection; using System.Runtime.InteropServices; -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Examples.AspNet")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Examples.AspNet")] -[assembly: AssemblyCopyright("Copyright @ 2020")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - // Setting ComVisible to false makes the types in this assembly not visible // to COM components. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9a4e3a68-904b-4835-a3c8-f664b73098db")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/examples/AspNet/Properties/launchSettings.json b/examples/AspNet/Properties/launchSettings.json new file mode 100644 index 0000000000..9b068c43bb --- /dev/null +++ b/examples/AspNet/Properties/launchSettings.json @@ -0,0 +1,18 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:23307" + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/examples/AspNet/Web.config b/examples/AspNet/Web.config index 9eebb5c685..936a551d10 100644 --- a/examples/AspNet/Web.config +++ b/examples/AspNet/Web.config @@ -1,58 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/Directory.Build.props b/examples/Directory.Build.props index 1927158094..a55fcdde66 100644 --- a/examples/Directory.Build.props +++ b/examples/Directory.Build.props @@ -1,3 +1,4 @@ + diff --git a/opentelemetry-dotnet-contrib.sln b/opentelemetry-dotnet-contrib.sln index 7afe8b2a4d..888c1a7765 100644 --- a/opentelemetry-dotnet-contrib.sln +++ b/opentelemetry-dotnet-contrib.sln @@ -291,6 +291,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.InfluxDB", "exampl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.AotCompatibility.TestApp", "test\OpenTelemetry.AotCompatibility.TestApp\OpenTelemetry.AotCompatibility.TestApp.csproj", "{31937862-0C88-41C0-AFD6-F97A7BF803A9}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{9B30F5FD-3309-49CB-9CAD-D3372FAFD796}" + ProjectSection(SolutionItems) = preProject + examples\Directory.Build.props = examples\Directory.Build.props + examples\Directory.Build.targets = examples\Directory.Build.targets + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -698,6 +704,7 @@ Global {2D354354-BAFB-490B-A26F-6A16A52A1A45} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA} {B4951583-D432-4E87-85CF-498FDD6A35E6} = {2D354354-BAFB-490B-A26F-6A16A52A1A45} {31937862-0C88-41C0-AFD6-F97A7BF803A9} = {2097345F-4DD3-477D-BC54-A922F9B2B402} + {9B30F5FD-3309-49CB-9CAD-D3372FAFD796} = {824BD1DE-3FA8-4FE0-823A-FD365EAC78AF} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66} diff --git a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj index cc864470ac..2561adb134 100644 --- a/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj +++ b/src/OpenTelemetry.Exporter.Geneva/OpenTelemetry.Exporter.Geneva.csproj @@ -10,7 +10,6 @@ net6.0;netstandard2.0 $(TargetFrameworks);net462 Exporter.Geneva- - true true diff --git a/src/OpenTelemetry.Exporter.InfluxDB/OpenTelemetry.Exporter.InfluxDB.csproj b/src/OpenTelemetry.Exporter.InfluxDB/OpenTelemetry.Exporter.InfluxDB.csproj index c7929025cb..8a19e95c12 100644 --- a/src/OpenTelemetry.Exporter.InfluxDB/OpenTelemetry.Exporter.InfluxDB.csproj +++ b/src/OpenTelemetry.Exporter.InfluxDB/OpenTelemetry.Exporter.InfluxDB.csproj @@ -7,7 +7,6 @@ $(NetMinimumSupportedVersion);$(NetStandardMinimumSupportedVersion) Exporter.InfluxDB- - true true enable diff --git a/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj b/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj index 2990eb9ae4..ec8132aeab 100644 --- a/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj +++ b/src/OpenTelemetry.Exporter.OneCollector/OpenTelemetry.Exporter.OneCollector.csproj @@ -8,7 +8,6 @@ $(TargetFrameworks);net462 Exporter.OneCollector- enable - true true true diff --git a/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj b/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj index a012e9da7f..83d1393c8a 100644 --- a/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj +++ b/src/OpenTelemetry.Extensions/OpenTelemetry.Extensions.csproj @@ -8,7 +8,6 @@ OpenTelemetry .NET SDK preview features and extensions Extensions- enable - true diff --git a/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj b/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj index a92edeb866..8195194ba8 100644 --- a/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj +++ b/src/OpenTelemetry.Instrumentation.EventCounters/OpenTelemetry.Instrumentation.EventCounters.csproj @@ -4,7 +4,6 @@ OpenTelemetry Metrics instrumentation for Dotnet EventCounters $(PackageTags);metrics;eventcounters Instrumentation.EventCounters- - true enable diff --git a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj index 47748d2105..3467fd245a 100644 --- a/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj +++ b/src/OpenTelemetry.Instrumentation.Owin/OpenTelemetry.Instrumentation.Owin.csproj @@ -5,7 +5,6 @@ OpenTelemetry instrumentation for OWIN $(PackageTags);distributed-tracing;OWIN Instrumentation.Owin- - true diff --git a/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj b/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj index 49e32f3588..bf9335784d 100644 --- a/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj +++ b/src/OpenTelemetry.Instrumentation.Process/OpenTelemetry.Instrumentation.Process.csproj @@ -4,7 +4,6 @@ dotnet process instrumentation for OpenTelemetry .NET $(PackageTags);process Instrumentation.Process- - true enable diff --git a/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj b/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj index 06adbebe66..7d61ac0091 100644 --- a/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj +++ b/src/OpenTelemetry.Instrumentation.Runtime/OpenTelemetry.Instrumentation.Runtime.csproj @@ -5,7 +5,6 @@ dotnet runtime instrumentation for OpenTelemetry .NET $(PackageTags);runtime Instrumentation.Runtime- - true enable diff --git a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj index a82272a763..f03d885358 100644 --- a/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj +++ b/src/OpenTelemetry.Instrumentation.StackExchangeRedis/OpenTelemetry.Instrumentation.StackExchangeRedis.csproj @@ -8,7 +8,6 @@ true Instrumentation.StackExchangeRedis- enable - true true diff --git a/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj b/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj index bd71e8127b..e3b9ef0fd6 100644 --- a/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj +++ b/src/OpenTelemetry.PersistentStorage.Abstractions/OpenTelemetry.PersistentStorage.Abstractions.csproj @@ -10,7 +10,6 @@ PersistentStorage.Abstractions- $(NoWarn),1591 enable - true diff --git a/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj b/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj index 885c72ec9c..23795f6b4d 100644 --- a/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj +++ b/src/OpenTelemetry.ResourceDetectors.Azure/OpenTelemetry.ResourceDetectors.Azure.csproj @@ -4,7 +4,6 @@ OpenTelemetry Resource Detectors for Azure cloud environments $(PackageTags);ResourceDetector ResourceDetectors.Azure- - true enable diff --git a/src/OpenTelemetry.Sampler.AWS/AWSXRaySamplerClient.cs b/src/OpenTelemetry.Sampler.AWS/AWSXRaySamplerClient.cs index 64b7649e8f..c89822cf8f 100644 --- a/src/OpenTelemetry.Sampler.AWS/AWSXRaySamplerClient.cs +++ b/src/OpenTelemetry.Sampler.AWS/AWSXRaySamplerClient.cs @@ -69,7 +69,7 @@ public async Task> GetSamplingRules() catch (Exception ex) { AWSSamplerEventSource.Log.FailedToDeserializeResponse( - nameof(AWSXRaySamplerClient.GetSamplingRules), + nameof(this.GetSamplingRules), ex.Message); } } @@ -98,7 +98,7 @@ public async Task> GetSamplingRules() catch (Exception ex) { AWSSamplerEventSource.Log.FailedToDeserializeResponse( - nameof(AWSXRaySamplerClient.GetSamplingTargets), + nameof(this.GetSamplingTargets), ex.Message); } diff --git a/src/Shared/ExceptionExtensions.cs b/src/Shared/ExceptionExtensions.cs index dea6a61c66..722d91aa75 100644 --- a/src/Shared/ExceptionExtensions.cs +++ b/src/Shared/ExceptionExtensions.cs @@ -16,7 +16,11 @@ #nullable enable +#pragma warning disable IDE0005 // Using directive is unnecessary. <- Projects with ImplicitUsings enabled don't need System or System.Threading +using System; using System.Globalization; +using System.Threading; +#pragma warning restore IDE0005 // Using directive is unnecessary. namespace OpenTelemetry.Internal; @@ -28,18 +32,18 @@ internal static class ExceptionExtensions /// /// Exception to convert to string. /// Exception as string with no culture. - public static string ToInvariantString(this System.Exception exception) + public static string ToInvariantString(this Exception exception) { - var originalUICulture = System.Threading.Thread.CurrentThread.CurrentUICulture; + var originalUICulture = Thread.CurrentThread.CurrentUICulture; try { - System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; + Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; return exception.ToString(); } finally { - System.Threading.Thread.CurrentThread.CurrentUICulture = originalUICulture; + Thread.CurrentThread.CurrentUICulture = originalUICulture; } } } diff --git a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj index 2f1e775e66..516a7a1156 100644 --- a/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj +++ b/test/OpenTelemetry.Exporter.InfluxDB.Tests/OpenTelemetry.Exporter.InfluxDB.Tests.csproj @@ -6,7 +6,6 @@ $(NetMinimumSupportedVersion) $(TargetFrameworks);net48;net472;net471;net47;net462 enable - true true diff --git a/test/OpenTelemetry.Exporter.OneCollector.Benchmarks/OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj b/test/OpenTelemetry.Exporter.OneCollector.Benchmarks/OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj index 8e257e1321..c2e9b87580 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Benchmarks/OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj +++ b/test/OpenTelemetry.Exporter.OneCollector.Benchmarks/OpenTelemetry.Exporter.OneCollector.Benchmarks.csproj @@ -7,7 +7,6 @@ net7.0;net6.0 $(TargetFrameworks);net48;net472;net471;net47;net462 enable - true true diff --git a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj index be7e96512f..8247c5e82d 100644 --- a/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj +++ b/test/OpenTelemetry.Exporter.OneCollector.Tests/OpenTelemetry.Exporter.OneCollector.Tests.csproj @@ -6,7 +6,6 @@ net7.0;net6.0 $(TargetFrameworks);net48;net472;net471;net47;net462 enable - true true From 895a9c7626ecad59b84d5886a5b82c547a209d08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kie=C5=82kowicz?= Date: Fri, 8 Sep 2023 06:29:19 +0200 Subject: [PATCH 3/4] Nullable for ASP.NET instrumentation projects (#1336) --- .../.publicApi/net462/PublicAPI.Shipped.txt | 1 + .../.publicApi/net462/PublicAPI.Unshipped.txt | 16 ++++----- .../ActivityHelper.cs | 35 ++++++++----------- .../AspNetTelemetryEventSource.cs | 20 +++++------ ...entation.AspNet.TelemetryHttpModule.csproj | 1 + .../TelemetryHttpModule.cs | 4 +-- .../TelemetryHttpModuleOptions.cs | 6 ++-- .../.publicApi/net462/PublicAPI.Shipped.txt | 2 +- .../.publicApi/net462/PublicAPI.Unshipped.txt | 10 +++--- .../AspNetInstrumentationOptions.cs | 4 +-- .../Implementation/HttpInListener.cs | 4 +-- ...penTelemetry.Instrumentation.AspNet.csproj | 1 + .../TracerProviderBuilderExtensions.cs | 2 +- .../EventSourceTestHelper.cs | 7 ++-- .../InMemoryEventListener.cs | 2 ++ .../TestEventListener.cs | 8 +++-- .../ActivityHelperTest.cs | 34 +++++++++--------- .../HttpContextHelper.cs | 6 ++-- ...on.AspNet.TelemetryHttpModule.Tests.csproj | 1 + .../WebConfigTransformTest.cs | 2 +- .../WebConfigWithLocationTagTransformTest.cs | 2 +- .../BasicTests.cs | 4 +-- .../HttpInListenerTests.cs | 21 +++-------- .../HttpInMetricsListenerTests.cs | 4 +-- ...emetry.Instrumentation.AspNet.Tests.csproj | 1 + 25 files changed, 96 insertions(+), 102 deletions(-) diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Shipped.txt index e69de29bb2..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Shipped.txt @@ -0,0 +1 @@ +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Unshipped.txt index 367f7a1e6e..21ec8b6507 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/.publicApi/net462/PublicAPI.Unshipped.txt @@ -1,16 +1,16 @@ -const OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.AspNetActivityName = "Microsoft.AspNet.HttpReqIn" -> string -const OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.AspNetSourceName = "OpenTelemetry.Instrumentation.AspNet.Telemetry" -> string +const OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.AspNetActivityName = "Microsoft.AspNet.HttpReqIn" -> string! +const OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.AspNetSourceName = "OpenTelemetry.Instrumentation.AspNet.Telemetry" -> string! OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Dispose() -> void -OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Init(System.Web.HttpApplication context) -> void +OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Init(System.Web.HttpApplication! context) -> void OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.TelemetryHttpModule() -> void OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions -OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnExceptionCallback.get -> System.Action +OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnExceptionCallback.get -> System.Action? OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnExceptionCallback.set -> void -OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStartedCallback.get -> System.Action +OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStartedCallback.get -> System.Action? OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStartedCallback.set -> void -OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStoppedCallback.get -> System.Action +OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStoppedCallback.get -> System.Action? OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.OnRequestStoppedCallback.set -> void -OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.TextMapPropagator.get -> OpenTelemetry.Context.Propagation.TextMapPropagator +OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.TextMapPropagator.get -> OpenTelemetry.Context.Propagation.TextMapPropagator! OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions.TextMapPropagator.set -> void -static OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Options.get -> OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions +static OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Options.get -> OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModuleOptions! diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs index 7ef463ec8d..d76929ec0c 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/ActivityHelper.cs @@ -50,10 +50,8 @@ internal static class ActivityHelper /// langword="null"/> if 1) start has not been called or 2) start was /// called but sampling decided not to create an instance. /// if start has been called. - public static bool HasStarted(HttpContext context, out Activity aspNetActivity) + public static bool HasStarted(HttpContext context, out Activity? aspNetActivity) { - Debug.Assert(context != null, "Context is null."); - object itemValue = context.Items[ContextKey]; if (itemValue is ContextHolder contextHolder) { @@ -72,13 +70,11 @@ public static bool HasStarted(HttpContext context, out Activity aspNetActivity) /// . /// Callback action. /// New root activity. - public static Activity StartAspNetActivity(TextMapPropagator textMapPropagator, HttpContext context, Action onRequestStartedCallback) + public static Activity? StartAspNetActivity(TextMapPropagator textMapPropagator, HttpContext context, Action? onRequestStartedCallback) { - Debug.Assert(context != null, "Context is null."); - PropagationContext propagationContext = textMapPropagator.Extract(default, context.Request, HttpRequestHeaderValuesGetter); - Activity activity = AspNetSource.StartActivity(TelemetryHttpModule.AspNetActivityName, ActivityKind.Server, propagationContext.ActivityContext); + Activity? activity = AspNetSource.StartActivity(TelemetryHttpModule.AspNetActivityName, ActivityKind.Server, propagationContext.ActivityContext); if (activity != null) { @@ -86,11 +82,11 @@ public static Activity StartAspNetActivity(TextMapPropagator textMapPropagator, { Baggage.Current = propagationContext.Baggage; - context.Items[ContextKey] = new ContextHolder { Activity = activity, Baggage = RuntimeContext.GetValue(BaggageSlotName) }; + context.Items[ContextKey] = new ContextHolder(activity, RuntimeContext.GetValue(BaggageSlotName)); } else { - context.Items[ContextKey] = new ContextHolder { Activity = activity }; + context.Items[ContextKey] = new ContextHolder(activity); } try @@ -120,10 +116,8 @@ public static Activity StartAspNetActivity(TextMapPropagator textMapPropagator, /// . /// Callback action. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void StopAspNetActivity(TextMapPropagator textMapPropagator, Activity aspNetActivity, HttpContext context, Action onRequestStoppedCallback) + public static void StopAspNetActivity(TextMapPropagator textMapPropagator, Activity? aspNetActivity, HttpContext context, Action? onRequestStoppedCallback) { - Debug.Assert(context != null, "Context is null."); - if (aspNetActivity == null) { Debug.Assert(context.Items[ContextKey] == StartedButNotSampledObj, "Context item is not StartedButNotSampledObj."); @@ -150,7 +144,7 @@ public static void StopAspNetActivity(TextMapPropagator textMapPropagator, Activ AspNetTelemetryEventSource.Log.CallbackException(aspNetActivity, "OnStopped", callbackEx); } - AspNetTelemetryEventSource.Log.ActivityStopped(currentActivity); + AspNetTelemetryEventSource.Log.ActivityStopped(aspNetActivity); if (textMapPropagator is not TraceContextPropagator) { @@ -171,11 +165,8 @@ public static void StopAspNetActivity(TextMapPropagator textMapPropagator, Activ /// . /// Callback action. [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void WriteActivityException(Activity aspNetActivity, HttpContext context, Exception exception, Action onExceptionCallback) + public static void WriteActivityException(Activity? aspNetActivity, HttpContext context, Exception exception, Action? onExceptionCallback) { - Debug.Assert(context != null, "Context is null."); - Debug.Assert(exception != null, "Exception is null."); - if (aspNetActivity != null) { try @@ -201,8 +192,6 @@ public static void WriteActivityException(Activity aspNetActivity, HttpContext c [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void RestoreContextIfNeeded(HttpContext context) { - Debug.Assert(context != null, "Context is null."); - if (context.Items[ContextKey] is ContextHolder contextHolder && Activity.Current != contextHolder.Activity) { Activity.Current = contextHolder.Activity; @@ -218,6 +207,12 @@ internal static void RestoreContextIfNeeded(HttpContext context) internal sealed class ContextHolder { public Activity Activity; - public object Baggage; + public object? Baggage; + + public ContextHolder(Activity activity, object? baggage = null) + { + this.Activity = activity; + this.Baggage = baggage; + } } } diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/AspNetTelemetryEventSource.cs b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/AspNetTelemetryEventSource.cs index 78f6cdb02c..5b82fb5eda 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/AspNetTelemetryEventSource.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/AspNetTelemetryEventSource.cs @@ -37,7 +37,7 @@ public void ActivityStarted(Activity activity) { if (this.IsEnabled(EventLevel.Verbose, EventKeywords.All)) { - this.ActivityStarted(activity?.Id); + this.ActivityStarted(activity.Id); } } @@ -46,7 +46,7 @@ public void ActivityStopped(Activity activity) { if (this.IsEnabled(EventLevel.Verbose, EventKeywords.All)) { - this.ActivityStopped(activity?.Id); + this.ActivityStopped(activity.Id); } } @@ -55,7 +55,7 @@ public void ActivityRestored(Activity activity) { if (this.IsEnabled(EventLevel.Informational, EventKeywords.All)) { - this.ActivityRestored(activity?.Id); + this.ActivityRestored(activity.Id); } } @@ -64,7 +64,7 @@ public void ActivityException(Activity activity, Exception ex) { if (this.IsEnabled(EventLevel.Error, EventKeywords.All)) { - this.ActivityException(activity?.Id, ex.ToInvariantString()); + this.ActivityException(activity.Id, ex.ToInvariantString()); } } @@ -73,7 +73,7 @@ public void CallbackException(Activity activity, string eventName, Exception ex) { if (this.IsEnabled(EventLevel.Error, EventKeywords.All)) { - this.CallbackException(activity?.Id, eventName, ex.ToInvariantString()); + this.CallbackException(activity.Id, eventName, ex.ToInvariantString()); } } @@ -84,19 +84,19 @@ public void TraceCallback(string callback) } [Event(2, Message = "Activity started, Id='{0}'", Level = EventLevel.Verbose)] - public void ActivityStarted(string id) + public void ActivityStarted(string? id) { this.WriteEvent(2, id); } [Event(3, Message = "Activity stopped, Id='{0}'", Level = EventLevel.Verbose)] - public void ActivityStopped(string id) + public void ActivityStopped(string? id) { this.WriteEvent(3, id); } [Event(4, Message = "Activity restored, Id='{0}'", Level = EventLevel.Informational)] - public void ActivityRestored(string id) + public void ActivityRestored(string? id) { this.WriteEvent(4, id); } @@ -108,13 +108,13 @@ public void OnExecuteRequestStepInvocationError(string error) } [Event(6, Message = "Activity exception, Id='{0}': {1}", Level = EventLevel.Error)] - public void ActivityException(string id, string ex) + public void ActivityException(string? id, string ex) { this.WriteEvent(6, id, ex); } [Event(7, Message = "Callback exception, Id='{0}', Name='{1}': {2}", Level = EventLevel.Error)] - public void CallbackException(string id, string eventName, string ex) + public void CallbackException(string? id, string eventName, string ex) { this.WriteEvent(7, id, eventName, ex); } diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj index 395a6adc25..95a86afd97 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.csproj @@ -6,6 +6,7 @@ A module that instruments incoming request with System.Diagnostics.Activity and notifies listeners with DiagnosticsSource. $(PackageTags);distributed-tracing;AspNet;MVC;WebAPI Instrumentation.AspNet.TelemetryHttpModule- + enable diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModule.cs b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModule.cs index 2ad4514574..ed23433fff 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModule.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModule.cs @@ -98,7 +98,7 @@ private void Application_EndRequest(object sender, EventArgs e) var context = ((HttpApplication)sender).Context; - if (!ActivityHelper.HasStarted(context, out Activity aspNetActivity)) + if (!ActivityHelper.HasStarted(context, out Activity? aspNetActivity)) { // Rewrite: In case of rewrite, a new request context is created, called the child request, and it goes through the entire IIS/ASP.NET integrated pipeline. // The child request can be mapped to any of the handlers configured in IIS, and it's execution is no different than it would be if it was received via the HTTP stack. @@ -133,7 +133,7 @@ private void Application_Error(object sender, EventArgs e) var exception = context.Error; if (exception != null) { - if (!ActivityHelper.HasStarted(context, out Activity aspNetActivity)) + if (!ActivityHelper.HasStarted(context, out Activity? aspNetActivity)) { aspNetActivity = ActivityHelper.StartAspNetActivity(Options.TextMapPropagator, context, Options.OnRequestStartedCallback); } diff --git a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModuleOptions.cs b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModuleOptions.cs index 00be9abcae..d71f8d19e2 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModuleOptions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule/TelemetryHttpModuleOptions.cs @@ -51,16 +51,16 @@ public TextMapPropagator TextMapPropagator /// /// Gets or sets a callback action to be fired when a request is started. /// - public Action OnRequestStartedCallback { get; set; } + public Action? OnRequestStartedCallback { get; set; } /// /// Gets or sets a callback action to be fired when a request is stopped. /// - public Action OnRequestStoppedCallback { get; set; } + public Action? OnRequestStoppedCallback { get; set; } /// /// Gets or sets a callback action to be fired when an unhandled /// exception is thrown processing a request. /// - public Action OnExceptionCallback { get; set; } + public Action? OnExceptionCallback { get; set; } } diff --git a/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Shipped.txt b/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Shipped.txt index 5f282702bb..7dc5c58110 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Shipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Shipped.txt @@ -1 +1 @@ - \ No newline at end of file +#nullable enable diff --git a/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Unshipped.txt b/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Unshipped.txt index 9b53ae2ee5..b2fd0825bd 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Unshipped.txt +++ b/src/OpenTelemetry.Instrumentation.AspNet/.publicApi/net462/PublicAPI.Unshipped.txt @@ -1,13 +1,13 @@ OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.AspNetInstrumentationOptions() -> void -OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Enrich.get -> System.Action +OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Enrich.get -> System.Action? OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Enrich.set -> void -OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Filter.get -> System.Func +OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Filter.get -> System.Func? OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.Filter.set -> void OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.RecordException.get -> bool OpenTelemetry.Instrumentation.AspNet.AspNetInstrumentationOptions.RecordException.set -> void OpenTelemetry.Metrics.MeterProviderBuilderExtensions OpenTelemetry.Trace.TracerProviderBuilderExtensions -static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder builder) -> OpenTelemetry.Metrics.MeterProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder) -> OpenTelemetry.Trace.TracerProviderBuilder -static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure) -> OpenTelemetry.Trace.TracerProviderBuilder +static OpenTelemetry.Metrics.MeterProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Metrics.MeterProviderBuilder! builder) -> OpenTelemetry.Metrics.MeterProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder) -> OpenTelemetry.Trace.TracerProviderBuilder! +static OpenTelemetry.Trace.TracerProviderBuilderExtensions.AddAspNetInstrumentation(this OpenTelemetry.Trace.TracerProviderBuilder! builder, System.Action? configure) -> OpenTelemetry.Trace.TracerProviderBuilder! diff --git a/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs index 50ded07c2c..f2c486e2d5 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/AspNetInstrumentationOptions.cs @@ -39,7 +39,7 @@ public class AspNetInstrumentationOptions /// exception the request is filtered out (NOT collected). /// /// - public Func Filter { get; set; } + public Func? Filter { get; set; } /// /// Gets or sets an action to enrich an Activity. @@ -50,7 +50,7 @@ public class AspNetInstrumentationOptions /// object: the raw object from which additional information can be extracted to enrich the activity. /// The type of this object depends on the event, which is given by the above parameter. /// - public Action Enrich { get; set; } + public Action? Enrich { get; set; } /// /// Gets or sets a value indicating whether the exception will be recorded as ActivityEvent or not. diff --git a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs index a8c1ddb9a4..09d1783253 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/Implementation/HttpInListener.cs @@ -135,7 +135,7 @@ private void OnStopActivity(Activity activity, HttpContext context) var routeData = context.Request.RequestContext.RouteData; - string template = null; + string? template = null; if (routeData.Values.TryGetValue("MS_SubRoutes", out object msSubRoutes)) { // WebAPI attribute routing flows here. Use reflection to not take a dependency on microsoft.aspnet.webapi.core\[version]\lib\[framework]\System.Web.Http. @@ -157,7 +157,7 @@ private void OnStopActivity(Activity activity, HttpContext context) if (!string.IsNullOrEmpty(template)) { // Override the name that was previously set to the path part of URL. - activity.DisplayName = template; + activity.DisplayName = template!; activity.SetTag(SemanticConventions.AttributeHttpRoute, template); } diff --git a/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj b/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj index 3072fd37da..ac57a8259f 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj +++ b/src/OpenTelemetry.Instrumentation.AspNet/OpenTelemetry.Instrumentation.AspNet.csproj @@ -7,6 +7,7 @@ $(PackageTags);distributed-tracing;AspNet;MVC;WebAPI true Instrumentation.AspNet- + enable diff --git a/src/OpenTelemetry.Instrumentation.AspNet/TracerProviderBuilderExtensions.cs b/src/OpenTelemetry.Instrumentation.AspNet/TracerProviderBuilderExtensions.cs index eec9f981cf..3394dcc287 100644 --- a/src/OpenTelemetry.Instrumentation.AspNet/TracerProviderBuilderExtensions.cs +++ b/src/OpenTelemetry.Instrumentation.AspNet/TracerProviderBuilderExtensions.cs @@ -41,7 +41,7 @@ public static class TracerProviderBuilderExtensions /// The instance of to chain the calls. public static TracerProviderBuilder AddAspNetInstrumentation( this TracerProviderBuilder builder, - Action configure) + Action? configure) { Guard.ThrowIfNull(builder); diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs b/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs index 2c9f2f9578..3b93d7d67a 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/EventSourceTestHelper.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#nullable enable + using System; using System.Collections.Generic; using System.Diagnostics.Tracing; @@ -42,9 +44,7 @@ private static void VerifyMethodImplementation(EventSource eventSource, MethodIn object[] eventArguments = GenerateEventArguments(eventMethod); eventMethod.Invoke(eventSource, eventArguments); - EventWrittenEventArgs actualEvent = null; - - actualEvent = listener.Messages.First(q => q.EventName == eventMethod.Name); + var actualEvent = listener.Messages.First(q => q.EventName == eventMethod.Name); VerifyEventId(eventMethod, actualEvent); VerifyEventLevel(eventMethod, actualEvent); @@ -115,6 +115,7 @@ private static void VerifyEventMessage(MethodInfo eventMethod, EventWrittenEvent } private static void AssertEqual(string methodName, T expected, T actual) + where T : notnull { if (!expected.Equals(actual)) { diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/InMemoryEventListener.cs b/test/OpenTelemetry.Contrib.Tests.Shared/InMemoryEventListener.cs index 0799387e56..4e4f6683d0 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/InMemoryEventListener.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/InMemoryEventListener.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#nullable enable + using System.Collections.Concurrent; using System.Diagnostics.Tracing; diff --git a/test/OpenTelemetry.Contrib.Tests.Shared/TestEventListener.cs b/test/OpenTelemetry.Contrib.Tests.Shared/TestEventListener.cs index 7bd3d7fc36..a63680a5bb 100644 --- a/test/OpenTelemetry.Contrib.Tests.Shared/TestEventListener.cs +++ b/test/OpenTelemetry.Contrib.Tests.Shared/TestEventListener.cs @@ -14,6 +14,8 @@ // limitations under the License. // +#nullable enable + using System; using System.Collections.Generic; using System.Diagnostics.Tracing; @@ -49,7 +51,7 @@ public TestEventListener() } /// Gets or sets the handler for event source creation. - public Action OnOnEventSourceCreated { get; set; } + public Action? OnOnEventSourceCreated { get; set; } /// Gets or sets the handler for event source writes. public Action OnOnEventWritten { get; set; } @@ -90,8 +92,8 @@ protected override void OnEventWritten(EventWrittenEventArgs eventData) /// The event source that was created. protected override void OnEventSourceCreated(EventSource eventSource) { - // Check for null because this method is called by the base class constror before we can initialize it - Action callback = this.OnOnEventSourceCreated; + // Check for null because this method is called by the base class constructor before we can initialize it + Action? callback = this.OnOnEventSourceCreated; callback?.Invoke(eventSource); } } diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs index f491020cd4..5b229b3fb2 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs @@ -35,7 +35,7 @@ public class ActivityHelperTest : IDisposable private const string BaggageInHeader = "TestKey1=123,TestKey2=456,TestKey1=789"; private const string TestActivityName = "Activity.Test"; private readonly TextMapPropagator noopTextMapPropagator = new NoopTextMapPropagator(); - private ActivityListener activitySourceListener; + private ActivityListener? activitySourceListener; public void Dispose() { @@ -47,7 +47,7 @@ public void Has_Started_Returns_Correctly() { var context = HttpContextHelper.GetFakeHttpContext(); - bool result = ActivityHelper.HasStarted(context, out Activity aspNetActivity); + bool result = ActivityHelper.HasStarted(context, out Activity? aspNetActivity); Assert.False(result); Assert.Null(aspNetActivity); @@ -60,7 +60,7 @@ public void Has_Started_Returns_Correctly() Assert.Null(aspNetActivity); Activity activity = new Activity(TestActivityName); - context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder { Activity = activity }; + context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder(activity); result = ActivityHelper.HasStarted(context, out aspNetActivity); @@ -74,7 +74,7 @@ public async Task Can_Restore_Activity() { this.EnableListener(); var context = HttpContextHelper.GetFakeHttpContext(); - using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); + using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null)!; rootActivity.AddTag("k1", "v1"); rootActivity.AddTag("k2", "v2"); @@ -107,7 +107,7 @@ public async Task Can_Restore_Baggage() }; var context = HttpContextHelper.GetFakeHttpContext(headers: requestHeaders); - using var rootActivity = ActivityHelper.StartAspNetActivity(new CompositeTextMapPropagator(new TextMapPropagator[] { new TraceContextPropagator(), new BaggagePropagator() }), context, null); + using var rootActivity = ActivityHelper.StartAspNetActivity(new CompositeTextMapPropagator(new TextMapPropagator[] { new TraceContextPropagator(), new BaggagePropagator() }), context, null)!; rootActivity.AddTag("k1", "v1"); rootActivity.AddTag("k2", "v2"); @@ -146,7 +146,7 @@ public void Can_Stop_Lost_Activity() Assert.Equal(TelemetryHttpModule.AspNetActivityName, Activity.Current.OperationName); }); var context = HttpContextHelper.GetFakeHttpContext(); - using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); + using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null)!; rootActivity.AddTag("k1", "v1"); rootActivity.AddTag("k2", "v2"); @@ -174,7 +174,7 @@ public void Do_Not_Restore_Activity_When_It_Is_Not_Lost() var root = new Activity("root").Start(); var context = HttpContextHelper.GetFakeHttpContext(); - context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder { Activity = root }; + context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder(root); ActivityHelper.RestoreContextIfNeeded(context); @@ -187,7 +187,7 @@ public void Can_Stop_Activity_Without_AspNetListener_Enabled() var context = HttpContextHelper.GetFakeHttpContext(); var rootActivity = new Activity(TestActivityName); rootActivity.Start(); - context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder { Activity = rootActivity }; + context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder(rootActivity); Thread.Sleep(100); ActivityHelper.StopAspNetActivity(this.noopTextMapPropagator, rootActivity, context, null); @@ -202,7 +202,7 @@ public void Can_Stop_Activity_With_AspNetListener_Enabled() var context = HttpContextHelper.GetFakeHttpContext(); var rootActivity = new Activity(TestActivityName); rootActivity.Start(); - context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder { Activity = rootActivity }; + context.Items[ActivityHelper.ContextKey] = new ActivityHelper.ContextHolder(rootActivity); Thread.Sleep(100); this.EnableListener(); ActivityHelper.StopAspNetActivity(this.noopTextMapPropagator, rootActivity, context, null); @@ -217,7 +217,7 @@ public void Can_Stop_Root_Activity_With_All_Children() { this.EnableListener(); var context = HttpContextHelper.GetFakeHttpContext(); - using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); + using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null)!; var child = new Activity("child").Start(); new Activity("grandchild").Start(); @@ -251,7 +251,7 @@ public async Task Can_Stop_Root_Activity_If_It_Is_Broken() { this.EnableListener(); var context = HttpContextHelper.GetFakeHttpContext(); - using var root = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); + using var root = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null)!; new Activity("child").Start(); for (int i = 0; i < 2; i++) @@ -259,7 +259,7 @@ public async Task Can_Stop_Root_Activity_If_It_Is_Broken() await Task.Run(() => { // when we enter this method, Current is 'child' activity - Activity.Current.Stop(); + Activity.Current!.Stop(); // here Current is 'parent', but only in this execution context }); @@ -281,7 +281,7 @@ public void Stop_Root_Activity_With_129_Nesting_Depth() { this.EnableListener(); var context = HttpContextHelper.GetFakeHttpContext(); - using var root = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); + using var root = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null)!; for (int i = 0; i < 129; i++) { @@ -447,7 +447,7 @@ public void Fire_Exception_Events() Assert.Equal(1, callbacksFired); } - private void EnableListener(Action onStarted = null, Action onStopped = null, Func onSample = null) + private void EnableListener(Action? onStarted = null, Action? onStopped = null, Func? onSample = null) { Debug.Assert(this.activitySourceListener == null, "Cannot attach multiple listeners in tests."); @@ -512,7 +512,7 @@ private class TestHttpContext : HttpContextBase { private readonly Hashtable items; - public TestHttpContext(Exception error = null) + public TestHttpContext(Exception? error = null) { this.Server = new TestHttpServerUtility(this); this.items = new Hashtable(); @@ -524,14 +524,14 @@ public TestHttpContext(Exception error = null) /// public override IDictionary Items => this.items; - public override Exception Error { get; } + public override Exception? Error { get; } public override HttpServerUtilityBase Server { get; } } private class NoopTextMapPropagator : TextMapPropagator { - public override ISet Fields => null; + public override ISet? Fields => null; public override PropagationContext Extract(PropagationContext context, T carrier, Func> getter) { diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/HttpContextHelper.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/HttpContextHelper.cs index b39a654aa9..cfb810f497 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/HttpContextHelper.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/HttpContextHelper.cs @@ -25,7 +25,7 @@ namespace OpenTelemetry.Instrumentation.AspNet.Tests; internal class HttpContextHelper { - public static HttpContext GetFakeHttpContext(string page = "/page", string query = "", IDictionary headers = null) + public static HttpContext GetFakeHttpContext(string page = "/page", string query = "", IDictionary? headers = null) { Thread.GetDomain().SetData(".appPath", string.Empty); Thread.GetDomain().SetData(".appVPath", string.Empty); @@ -36,7 +36,7 @@ public static HttpContext GetFakeHttpContext(string page = "/page", string query return context; } - public static HttpContextBase GetFakeHttpContextBase(string page = "/page", string query = "", IDictionary headers = null) + public static HttpContextBase GetFakeHttpContextBase(string page = "/page", string query = "", IDictionary? headers = null) { var context = GetFakeHttpContext(page, query, headers); return new HttpContextWrapper(context); @@ -46,7 +46,7 @@ private class SimpleWorkerRequestWithHeaders : SimpleWorkerRequest { private readonly IDictionary headers; - public SimpleWorkerRequestWithHeaders(string page, string query, TextWriter output, IDictionary headers) + public SimpleWorkerRequestWithHeaders(string page, string query, TextWriter output, IDictionary? headers) : base(page, query, output) { if (headers != null) diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj index c68c2175a8..343bc3c447 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests.csproj @@ -3,6 +3,7 @@ Unit test project for ASP.NET HttpModule $(NetFrameworkMinimumSupportedVersion) + enable diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigTransformTest.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigTransformTest.cs index e64c93868d..52a4ec2a39 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigTransformTest.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigTransformTest.cs @@ -384,7 +384,7 @@ private void VerifyTransformation(string expectedConfigContent, XDocument transf private XDocument ApplyTransformation(string originalConfiguration, string transformationResourceName) { XDocument result; - Stream stream = null; + Stream? stream = null; try { stream = typeof(WebConfigTransformTest).Assembly.GetManifestResourceStream(transformationResourceName); diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigWithLocationTagTransformTest.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigWithLocationTagTransformTest.cs index 7e39fc8ee4..9d7b28ec39 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigWithLocationTagTransformTest.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/WebConfigWithLocationTagTransformTest.cs @@ -414,7 +414,7 @@ private void VerifyTransformation(string expectedConfigContent, XDocument transf private XDocument ApplyTransformation(string originalConfiguration, string transformationResourceName) { XDocument result; - Stream stream = null; + Stream? stream = null; try { stream = typeof(WebConfigTransformTest).Assembly.GetManifestResourceStream(transformationResourceName); diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/BasicTests.cs index 431f52f995..1a0ba83dc4 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/BasicTests.cs @@ -25,7 +25,7 @@ public class BasicTests [Fact] public void AddAspNetInstrumentation_BadArgs() { - TracerProviderBuilder builder = null; - Assert.Throws(() => builder.AddAspNetInstrumentation()); + TracerProviderBuilder? builder = null; + Assert.Throws(() => builder!.AddAspNetInstrumentation()); } } diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs index 70d477c627..3cb163eed8 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs @@ -55,10 +55,9 @@ public class HttpInListenerTests int routeType, string routeTemplate, bool setStatusToErrorInEnrich = false, - string filter = null, + string? filter = null, bool recordException = false) { - IDisposable tracerProvider = null; RouteData routeData; switch (routeType) { @@ -93,16 +92,6 @@ public class HttpInListenerTests throw new NotSupportedException(); } - var workerRequest = new Mock(); - workerRequest.Setup(wr => wr.GetKnownRequestHeader(It.IsAny())).Returns(i => - { - return i switch - { - 39 => "Test", // User-Agent - _ => null, - }; - }); - HttpContext.Current = new HttpContext( new HttpRequest(string.Empty, url, string.Empty) { @@ -113,17 +102,17 @@ public class HttpInListenerTests }, new HttpResponse(new StringWriter())); - typeof(HttpRequest).GetField("_wr", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(HttpContext.Current.Request, workerRequest.Object); + typeof(HttpRequest).GetField("_wr", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(HttpContext.Current.Request, Mock.Of()); List exportedItems = new List(16); Sdk.SetDefaultTextMapPropagator(new TraceContextPropagator()); - using (tracerProvider = Sdk.CreateTracerProviderBuilder() + using (Sdk.CreateTracerProviderBuilder() .AddAspNetInstrumentation((options) => { options.Filter = httpContext => { - Assert.True(Activity.Current.IsAllDataRequested); + Assert.True(Activity.Current!.IsAllDataRequested); if (string.IsNullOrEmpty(filter)) { return true; @@ -153,7 +142,7 @@ public class HttpInListenerTests Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 2)); } - Assert.Equal(TelemetryHttpModule.AspNetActivityName, Activity.Current.OperationName); + Assert.Equal(TelemetryHttpModule.AspNetActivityName, Activity.Current!.OperationName); if (recordException) { diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs index 8ba1903aa2..cd458aad73 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs @@ -79,9 +79,9 @@ public void HttpDurationMetricIsEmitted() Assert.Equal(duration, sum); Assert.Equal(3, metricPoints[0].Tags.Count); - string httpMethod = null; + string? httpMethod = null; int httpStatusCode = 0; - string httpScheme = null; + string? httpScheme = null; foreach (var tag in metricPoints[0].Tags) { diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj index f59b1e785e..66d205fa8f 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/OpenTelemetry.Instrumentation.AspNet.Tests.csproj @@ -3,6 +3,7 @@ Unit test project for OpenTelemetry ASP.NET instrumentation $(NetFrameworkMinimumSupportedVersion) + enable From c4784de26bc6c061dc87a79189e6bedc90c2cdc6 Mon Sep 17 00:00:00 2001 From: Utkarsh Umesan Pillai <66651184+utpilla@users.noreply.github.com> Date: Fri, 8 Sep 2023 15:56:39 -0700 Subject: [PATCH 4/4] [Exporter.Geneva] Update OTel SDK version and CHANGELOG for 1.6.0 release (#1346) --- src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md | 7 +++++++ .../Common.GenevaExporter.props | 2 +- .../GenevaMetricExporterTests.cs | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md index decb1da578..58df50d08c 100644 --- a/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md +++ b/src/OpenTelemetry.Exporter.Geneva/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +## 1.6.0 + +Released 2023-Sep-09 + +* Update OpenTelemetry SDK version to `1.6.0`. + ([#1346](https://github.com/open-telemetry/opentelemetry-dotnet-contrib/pull/1346)) + ## 1.6.0-rc.1 Released 2023-Aug-28 diff --git a/src/OpenTelemetry.Exporter.Geneva/Common.GenevaExporter.props b/src/OpenTelemetry.Exporter.Geneva/Common.GenevaExporter.props index 78181066e1..5570a7a1fe 100644 --- a/src/OpenTelemetry.Exporter.Geneva/Common.GenevaExporter.props +++ b/src/OpenTelemetry.Exporter.Geneva/Common.GenevaExporter.props @@ -1,6 +1,6 @@ - $(OpenTelemetryCoreLatestPrereleaseVersion) + $(OpenTelemetryCoreLatestVersion) diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs index 74675312fb..cf6b224834 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs @@ -358,7 +358,9 @@ public void SuccessfulSerializationWithTLV(bool testMaxLimits, bool hasExemplars if (hasExemplars) { +#if EXPOSE_EXPERIMENTAL_FEATURES meterProviderBuilder.SetExemplarFilter(new AlwaysOnExemplarFilter()); +#endif } if (hasFilteredTagsForExemplars) @@ -1291,7 +1293,10 @@ private static UserdataV2 GetSerializedData(Metric metric, GenevaMetricExporter metricPointsEnumerator.MoveNext(); var metricPoint = metricPointsEnumerator.Current; +#if EXPOSE_EXPERIMENTAL_FEATURES var exemplars = metricPoint.GetExemplars(); +#endif + UserdataV2 result = null; if (metricType == MetricType.LongSum)