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