diff --git a/build/Common.nonprod.props b/build/Common.nonprod.props index 7e5700a3f8..17782e9532 100644 --- a/build/Common.nonprod.props +++ b/build/Common.nonprod.props @@ -27,9 +27,9 @@ $(OpenTelemetryCoreLatestVersion) $(OpenTelemetryCoreLatestPrereleaseVersion) net8.0;net7.0;net6.0 - [2.5.0,3.0) - [2.5.0,3.0) - [1.5.48,2.0) + [2.8.1,3.0) + [2.8.1,3.0) + [1.5.58,2.0) diff --git a/src/OpenTelemetry.Instrumentation.Hangfire/HangfireInstrumentationOptions.cs b/src/OpenTelemetry.Instrumentation.Hangfire/HangfireInstrumentationOptions.cs index baec4e1dba..562ee11878 100644 --- a/src/OpenTelemetry.Instrumentation.Hangfire/HangfireInstrumentationOptions.cs +++ b/src/OpenTelemetry.Instrumentation.Hangfire/HangfireInstrumentationOptions.cs @@ -30,7 +30,7 @@ public class HangfireInstrumentationOptions /// /// Gets or sets a filter function that determines whether or not to - /// collect telemetry about the the being executed. + /// collect telemetry about the being executed. /// /// /// Notes: diff --git a/test/OpenTelemetry.Contrib.Shared.Tests/ActivityInstrumentationHelperTest.cs b/test/OpenTelemetry.Contrib.Shared.Tests/ActivityInstrumentationHelperTest.cs index e5841f53e6..fd99bee0d2 100644 --- a/test/OpenTelemetry.Contrib.Shared.Tests/ActivityInstrumentationHelperTest.cs +++ b/test/OpenTelemetry.Contrib.Shared.Tests/ActivityInstrumentationHelperTest.cs @@ -11,7 +11,7 @@ public class ActivityInstrumentationHelperTest [Theory] [InlineData("TestActivitySource", null)] [InlineData("TestActivitySource", "1.0.0")] - public void SetActivitySource(string name, string version) + public void SetActivitySource(string name, string? version) { using var activity = new Activity("Test"); using var activitySource = new ActivitySource(name, version); diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs index 321eaae6c6..fb9ed3168e 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaLogExporterTests.cs @@ -1520,8 +1520,8 @@ private void AssertFluentdForwardModeForLogRecord(GenevaExporterOptions exporter } else { - _ = mapping.TryGetValue("env_properties", out object envProprties); - var envPropertiesMapping = envProprties as IDictionary; + _ = mapping.TryGetValue("env_properties", out object envProperties); + var envPropertiesMapping = envProperties as IDictionary; foreach (var item in stateKeyValuePairList) { diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs index 039651efa1..a552dc590a 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaMetricExporterTests.cs @@ -114,7 +114,7 @@ public void CannotUseReservedDimensionsInPrepopulatedFields() } [Fact] - public void SuccessfulExportOnLinux() + public async Task SuccessfulExportOnLinux() { if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { @@ -198,7 +198,7 @@ public void SuccessfulExportOnLinux() out _); // Wait a little more than the ExportInterval for the exporter to export the data. - Task.Delay(5500).Wait(); + await Task.Delay(5500); // Read the data sent via socket. var receivedData = new byte[1024]; diff --git a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs index 5b2cd4a528..1f22dc0122 100644 --- a/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs +++ b/test/OpenTelemetry.Exporter.Geneva.Tests/GenevaTraceExporterTests.cs @@ -686,8 +686,8 @@ private void AssertFluentdForwardModeForActivity(GenevaExporterOptions exporterO #endregion #region Assert Activity Tags - _ = mapping.TryGetValue("env_properties", out object envProprties); - var envPropertiesMapping = envProprties as IDictionary; + _ = mapping.TryGetValue("env_properties", out object envProperties); + var envPropertiesMapping = envProperties as IDictionary; foreach (var tag in activity.TagObjects) { if (CS40_PART_B_MAPPING.TryGetValue(tag.Key, out string replacementKey)) diff --git a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetryEnrichmentServiceCollectionExtensionsTests.cs b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetryEnrichmentServiceCollectionExtensionsTests.cs index 61701c1ddb..dbad6bf253 100644 --- a/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetryEnrichmentServiceCollectionExtensionsTests.cs +++ b/test/OpenTelemetry.Extensions.Enrichment.Tests/OpenTelemetryEnrichmentServiceCollectionExtensionsTests.cs @@ -32,7 +32,7 @@ public async Task AddTraceEnricherOfTRegistersEnricher() .AddTraceEnricher()) .Build(); - await host.StartAsync().ConfigureAwait(false); + await host.StartAsync(); var enrichers = host.Services.GetServices().ToArray(); Assert.NotNull(enrichers); @@ -61,7 +61,7 @@ public async Task AddTraceEnricherOfTRegistersEnricher() Assert.Equal(1, tagObject2.Single().Value); } - await host.StopAsync().ConfigureAwait(false); + await host.StopAsync(); } [Fact] @@ -80,7 +80,7 @@ public async Task AddTraceEnricherRegistersEnricher() .AddTraceEnricher(new MyTraceEnricher2())) .Build(); - await host.StartAsync().ConfigureAwait(false); + await host.StartAsync(); var enrichers = host.Services.GetServices().ToArray(); Assert.NotNull(enrichers); @@ -102,7 +102,7 @@ public async Task AddTraceEnricherRegistersEnricher() Assert.Equal(1, tagObject2.Single().Value); } - await host.StopAsync().ConfigureAwait(false); + await host.StopAsync(); } [Fact] @@ -126,7 +126,7 @@ public async Task AddTraceEnricherActionRegistersEnricher() .AddTraceEnricher(bag => bag.Add(testKey2, testValue2))) .Build(); - await host.StartAsync().ConfigureAwait(false); + await host.StartAsync(); using var source1 = new ActivitySource(SourceName); @@ -162,7 +162,7 @@ public async Task AddTraceEnricherFactoryRegistersEnricher() .AddTraceEnricher(sp => new MyTraceEnricher2())) .Build(); - await host.StartAsync().ConfigureAwait(false); + await host.StartAsync(); var enrichers = host.Services.GetServices().ToArray(); Assert.NotNull(enrichers); @@ -184,6 +184,6 @@ public async Task AddTraceEnricherFactoryRegistersEnricher() Assert.Equal(1, tagObject2.Single().Value); } - await host.StopAsync().ConfigureAwait(false); + await host.StopAsync(); } } diff --git a/test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientInstrumentation.cs b/test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientInstrumentation.cs index 81340c5764..4caa6339ad 100644 --- a/test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientInstrumentation.cs +++ b/test/OpenTelemetry.Instrumentation.AWS.Tests/TestAWSClientInstrumentation.cs @@ -22,7 +22,11 @@ namespace OpenTelemetry.Instrumentation.AWS.Tests; public class TestAWSClientInstrumentation { [Fact] +#if NETFRAMEWORK public void TestDDBScanSuccessful() +#else + public async Task TestDDBScanSuccessful() +#endif { var exportedItems = new List(); @@ -46,7 +50,7 @@ public void TestDDBScanSuccessful() #if NETFRAMEWORK ddb.Scan(scan_request); #else - ddb.ScanAsync(scan_request).Wait(); + await ddb.ScanAsync(scan_request); #endif Assert.Single(exportedItems); @@ -61,7 +65,11 @@ public void TestDDBScanSuccessful() } [Fact] +#if NETFRAMEWORK public void TestDDBSubtypeScanSuccessful() +#else + public async Task TestDDBSubtypeScanSuccessful() +#endif { var exportedItems = new List(); @@ -85,7 +93,7 @@ public void TestDDBSubtypeScanSuccessful() #if NETFRAMEWORK ddb.Scan(scan_request); #else - ddb.ScanAsync(scan_request).Wait(); + await ddb.ScanAsync(scan_request); #endif Assert.Single(exportedItems); @@ -154,7 +162,11 @@ public async Task TestDDBScanUnsuccessful() } [Fact] +#if NETFRAMEWORK public void TestSQSSendMessageSuccessful() +#else + public async Task TestSQSSendMessageSuccessful() +#endif { var exportedItems = new List(); @@ -178,7 +190,7 @@ public void TestSQSSendMessageSuccessful() #if NETFRAMEWORK sqs.SendMessage(send_msg_req); #else - sqs.SendMessageAsync(send_msg_req).Wait(); + await sqs.SendMessageAsync(send_msg_req); #endif Assert.Single(exportedItems); Activity awssdk_activity = exportedItems[0]; diff --git a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs index ec2ff58713..6c69a93a0f 100644 --- a/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs +++ b/test/OpenTelemetry.Instrumentation.AWSLambda.Tests/Implementation/AWSLambdaHttpUtilsTests.cs @@ -227,7 +227,7 @@ public void SetHttpTagsFromResult_APIGatewayHttpApiV2ProxyResponse_SetsCorrectTa [InlineData(null, "localhost", "localhost", null)] [InlineData("http", "localhost", "localhost", 80)] [InlineData("https", "localhost", "localhost", 443)] - public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string httpSchema, string hostHeader, string expectedHost, int? expectedPort) + public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string? httpSchema, string? hostHeader, string? expectedHost, int? expectedPort) { (var host, var port) = AWSLambdaHttpUtils.GetHostAndPort(httpSchema, hostHeader); @@ -244,7 +244,7 @@ public void GetHostAndPort_HostHeader_ReturnsCorrectHostAndPort(string httpSchem [InlineData(new[] { "value 1" }, "?name=value+1")] [InlineData(new[] { "value1", "value2" }, "?name=value1&name=value2")] #pragma warning restore CA1861 // Avoid constant arrays as arguments - public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList values, string expectedQueryString) + public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList? values, string expectedQueryString) { var request = new APIGatewayProxyRequest(); if (values != null) @@ -265,7 +265,7 @@ public void GetQueryString_APIGatewayProxyRequest_CorrectQueryString(IList>(); diff --git a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs index 3a60303dba..5f8f18b3a4 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.TelemetryHttpModule.Tests/ActivityHelperTest.cs @@ -80,7 +80,7 @@ public async Task Can_Restore_Activity() }); } - await testTask.ConfigureAwait(false); + await testTask; } [Fact(Skip = "Temporarily disable until stable.")] @@ -120,7 +120,7 @@ public async Task Can_Restore_Baggage() }); } - await testTask.ConfigureAwait(false); + await testTask; } [Fact] @@ -401,7 +401,7 @@ public void Can_Create_RootActivity_And_Start_Activity() using var rootActivity = ActivityHelper.StartAspNetActivity(this.noopTextMapPropagator, context, null); Assert.NotNull(rootActivity); - Assert.True(!string.IsNullOrEmpty(rootActivity.Id)); + Assert.False(string.IsNullOrEmpty(rootActivity.Id)); } [Fact] diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs index e5b84675ad..e83249529c 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInListenerTests.cs @@ -41,7 +41,7 @@ public void AspNetRequestsAreCollectedSuccessfully( string url, string expectedUrlScheme, string expectedUrlPath, - string expectedUrlQuery, + string? expectedUrlQuery, bool disableQueryRedaction, string expectedHost, int expectedPort, diff --git a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs index 7cb3b0520e..5aeb4a2e8d 100644 --- a/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNet.Tests/HttpInMetricsListenerTests.cs @@ -34,11 +34,11 @@ public class HttpInMetricsListenerTests public void AspNetMetricTagsAreCollectedSuccessfully( string url, int routeType, - string routeTemplate, - string enrichMode, + string? routeTemplate, + string? enrichMode, string expectedScheme, string? expectedHost, - string expectedRoute, + string? expectedRoute, int? expectedPort, int expectedStatus, bool enableServerAttributesForRequestDuration = true) diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs index 37ba8b44bc..8cc9c62eb5 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs @@ -646,7 +646,7 @@ void ConfigureTestServices(IServiceCollection services) [InlineData("POST", "POST", null, "POST")] [InlineData("TRACE", "TRACE", null, "TRACE")] [InlineData("CUSTOM", "_OTHER", "CUSTOM", "HTTP")] - public async Task HttpRequestMethodAndActivityDisplayIsSetAsPerSpec(string originalMethod, string expectedMethod, string expectedOriginalMethod, string expectedDisplayName) + public async Task HttpRequestMethodAndActivityDisplayIsSetAsPerSpec(string originalMethod, string expectedMethod, string? expectedOriginalMethod, string expectedDisplayName) { var exportedItems = new List(); diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs index a877d060a3..b5c6db209c 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/DependencyInjectionConfigTests.cs @@ -24,7 +24,7 @@ public DependencyInjectionConfigTests(WebApplicationFactory factory) [Theory] [InlineData(null)] [InlineData("CustomName")] - public void TestTracingOptionsDIConfig(string name) + public void TestTracingOptionsDIConfig(string? name) { name ??= Options.DefaultName; diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs index 62b8f5abbc..5873415469 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs @@ -32,8 +32,8 @@ public IncomingRequestsCollectionsIsAccordingToTheSpecTests(WebApplicationFactor [InlineData("/api/exception", null, null, 503, true)] public async Task SuccessfulTemplateControllerCallGeneratesASpan_New( string urlPath, - string query, - string userAgent, + string? query, + string? userAgent, int statusCode, bool recordException = false) { @@ -130,7 +130,7 @@ public async Task SuccessfulTemplateControllerCallGeneratesASpan_New( activity.Dispose(); } - private static void ValidateTagValue(Activity activity, string attribute, string expectedValue) + private static void ValidateTagValue(Activity activity, string attribute, string? expectedValue) { if (string.IsNullOrEmpty(expectedValue)) { diff --git a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs index 4711bd272b..413c335194 100644 --- a/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs +++ b/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs @@ -180,7 +180,7 @@ void ConfigureTestServices(IServiceCollection services) [Theory] [InlineData("/api/values/2", "api/Values/{id}", null, 200)] [InlineData("/api/Error", "api/Error", "System.Exception", 500)] - public async Task RequestMetricIsCaptured(string api, string expectedRoute, string expectedErrorType, int expectedStatusCode) + public async Task RequestMetricIsCaptured(string api, string expectedRoute, string? expectedErrorType, int expectedStatusCode) { var metricItems = new List(); @@ -312,7 +312,7 @@ public void Dispose() private static List GetMetricPoints(Metric metric) { Assert.NotNull(metric); - Assert.True(metric.MetricType == MetricType.Histogram); + Assert.Equal(MetricType.Histogram, metric.MetricType); var metricPoints = new List(); foreach (var p in metric.GetMetricPoints()) { @@ -325,7 +325,7 @@ private static List GetMetricPoints(Metric metric) private static void AssertMetricPoints( List metricPoints, List expectedRoutes, - string expectedErrorType, + string? expectedErrorType, int expectedStatusCode, int expectedTagsCount) { @@ -360,7 +360,7 @@ private static void AssertMetricPoint( MetricPoint metricPoint, int expectedStatusCode, string expectedRoute, - string expectedErrorType, + string? expectedErrorType, int expectedTagsCount) { var count = metricPoint.GetHistogramCount(); diff --git a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/DependencyInjectionConfigTests.cs b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/DependencyInjectionConfigTests.cs index ba4b859459..5592f45806 100644 --- a/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/DependencyInjectionConfigTests.cs +++ b/test/OpenTelemetry.Instrumentation.EntityFrameworkCore.Tests/DependencyInjectionConfigTests.cs @@ -16,7 +16,7 @@ public class DependencyInjectionConfigTests [Theory] [InlineData(null)] [InlineData("CustomName")] - public async Task TestTracingOptionsDiConfig(string name) + public async Task TestTracingOptionsDiConfig(string? name) { bool optionsPickedFromDi = false; diff --git a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs index 7e6b379d71..dc5226af7e 100644 --- a/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs +++ b/test/OpenTelemetry.Instrumentation.EventCounters.Tests/EventCountersMetricsTests.cs @@ -169,7 +169,7 @@ public void EventSourceNameShortening(string sourceName, string eventName, strin } [Fact(Skip = "This test should properly validate no metrics are exported from event counters with invalid names (too long)")] - public void InstrumentNameTooLong() + public async Task InstrumentNameTooLong() { // Arrange List metricItems = new(); @@ -190,7 +190,7 @@ public void InstrumentNameTooLong() // Act connections.Increment(1); - Task.Delay(1800).Wait(); + await Task.Delay(1800); meterProvider.ForceFlush(); // Assert diff --git a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreClientInterceptorTests.cs b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreClientInterceptorTests.cs index a8fd94ac87..e1ec20a73a 100644 --- a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreClientInterceptorTests.cs +++ b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreClientInterceptorTests.cs @@ -36,7 +36,7 @@ public class GrpcCoreClientInterceptorTests [Fact] public async Task AsyncUnarySuccess() { - await TestHandlerSuccess(FoobarService.MakeUnaryAsyncRequest, DefaultMetadataFunc()).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeUnaryAsyncRequest, DefaultMetadataFunc()); } /// @@ -50,7 +50,7 @@ await TestHandlerFailure( FoobarService.MakeUnaryAsyncRequest, StatusCode.Unavailable, validateErrorDescription: false, - BogusServerUri).ConfigureAwait(false); + BogusServerUri); } /// @@ -60,7 +60,7 @@ await TestHandlerFailure( [Fact] public async Task AsyncUnaryFail() { - await TestHandlerFailure(FoobarService.MakeUnaryAsyncRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeUnaryAsyncRequest); } /// @@ -84,7 +84,7 @@ static void MakeRequest(Foobar.FoobarClient client) [Fact] public async Task ClientStreamingSuccess() { - await TestHandlerSuccess(FoobarService.MakeClientStreamingRequest, DefaultMetadataFunc()).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeClientStreamingRequest, DefaultMetadataFunc()); } /// @@ -98,7 +98,7 @@ await TestHandlerFailure( FoobarService.MakeClientStreamingRequest, StatusCode.Unavailable, validateErrorDescription: false, - BogusServerUri).ConfigureAwait(false); + BogusServerUri); } /// @@ -108,7 +108,7 @@ await TestHandlerFailure( [Fact] public async Task ClientStreamingFail() { - await TestHandlerFailure(FoobarService.MakeClientStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeClientStreamingRequest); } /// @@ -132,7 +132,7 @@ static void MakeRequest(Foobar.FoobarClient client) [Fact] public async Task ServerStreamingSuccess() { - await TestHandlerSuccess(FoobarService.MakeServerStreamingRequest, DefaultMetadataFunc()).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeServerStreamingRequest, DefaultMetadataFunc()); } /// @@ -142,7 +142,7 @@ public async Task ServerStreamingSuccess() [Fact] public async Task ServerStreamingFail() { - await TestHandlerFailure(FoobarService.MakeServerStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeServerStreamingRequest); } /// @@ -166,7 +166,7 @@ static void MakeRequest(Foobar.FoobarClient client) [Fact] public async Task DuplexStreamingSuccess() { - await TestHandlerSuccess(FoobarService.MakeDuplexStreamingRequest, DefaultMetadataFunc()).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeDuplexStreamingRequest, DefaultMetadataFunc()); } /// @@ -180,7 +180,7 @@ await TestHandlerFailure( FoobarService.MakeDuplexStreamingRequest, StatusCode.Unavailable, validateErrorDescription: false, - BogusServerUri).ConfigureAwait(false); + BogusServerUri); } /// @@ -190,7 +190,7 @@ await TestHandlerFailure( [Fact] public async Task DuplexStreamingFail() { - await TestHandlerFailure(FoobarService.MakeDuplexStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeDuplexStreamingRequest); } /// @@ -266,7 +266,7 @@ static void ValidateNewTagOnActivity(InterceptorActivityListener listener) Assert.Equal(parentActivity, Activity.Current); - _ = await call.ResponseAsync.ConfigureAwait(false); + _ = await call.ResponseAsync; Assert.Equal(parentActivity, Activity.Current); @@ -281,15 +281,15 @@ static void ValidateNewTagOnActivity(InterceptorActivityListener listener) Assert.Equal(parentActivity, Activity.Current); - await call.RequestStream.WriteAsync(FoobarService.DefaultRequestMessage).ConfigureAwait(false); + await call.RequestStream.WriteAsync(FoobarService.DefaultRequestMessage); Assert.Equal(parentActivity, Activity.Current); - await call.RequestStream.CompleteAsync().ConfigureAwait(false); + await call.RequestStream.CompleteAsync(); Assert.Equal(parentActivity, Activity.Current); - while (await call.ResponseStream.MoveNext().ConfigureAwait(false)) + while (await call.ResponseStream.MoveNext()) { Assert.Equal(parentActivity, Activity.Current); } diff --git a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreServerInterceptorTests.cs b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreServerInterceptorTests.cs index 54837ad547..4357262e9e 100644 --- a/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreServerInterceptorTests.cs +++ b/test/OpenTelemetry.Instrumentation.GrpcCore.Tests/GrpcCoreServerInterceptorTests.cs @@ -22,7 +22,7 @@ public class GrpcCoreServerInterceptorTests [Fact] public async Task UnaryServerHandlerSuccess() { - await TestHandlerSuccess(FoobarService.MakeUnaryAsyncRequest).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeUnaryAsyncRequest); } /// @@ -32,7 +32,7 @@ public async Task UnaryServerHandlerSuccess() [Fact] public async Task UnaryServerHandlerFail() { - await TestHandlerFailure(FoobarService.MakeUnaryAsyncRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeUnaryAsyncRequest); } /// @@ -42,7 +42,7 @@ public async Task UnaryServerHandlerFail() [Fact] public async Task ClientStreamingServerHandlerSuccess() { - await TestHandlerSuccess(FoobarService.MakeClientStreamingRequest).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeClientStreamingRequest); } /// @@ -52,7 +52,7 @@ public async Task ClientStreamingServerHandlerSuccess() [Fact] public async Task ClientStreamingServerHandlerFail() { - await TestHandlerFailure(FoobarService.MakeClientStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeClientStreamingRequest); } /// @@ -62,7 +62,7 @@ public async Task ClientStreamingServerHandlerFail() [Fact] public async Task ServerStreamingServerHandlerSuccess() { - await TestHandlerSuccess(FoobarService.MakeServerStreamingRequest).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeServerStreamingRequest); } /// @@ -72,7 +72,7 @@ public async Task ServerStreamingServerHandlerSuccess() [Fact] public async Task ServerStreamingServerHandlerFail() { - await TestHandlerFailure(FoobarService.MakeServerStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeServerStreamingRequest); } /// @@ -82,7 +82,7 @@ public async Task ServerStreamingServerHandlerFail() [Fact] public async Task DuplexStreamingServerHandlerSuccess() { - await TestHandlerSuccess(FoobarService.MakeDuplexStreamingRequest).ConfigureAwait(false); + await TestHandlerSuccess(FoobarService.MakeDuplexStreamingRequest); } /// @@ -92,7 +92,7 @@ public async Task DuplexStreamingServerHandlerSuccess() [Fact] public async Task DuplexStreamingServerHandlerFail() { - await TestHandlerFailure(FoobarService.MakeDuplexStreamingRequest).ConfigureAwait(false); + await TestHandlerFailure(FoobarService.MakeDuplexStreamingRequest); } /// @@ -111,7 +111,7 @@ private static async Task TestHandlerSuccess(Func @@ -103,7 +103,7 @@ public void GrpcAspNetCoreInstrumentationAddsCorrectAttributes(string enableGrpc [InlineData("false")] [InlineData("True")] [InlineData("False")] - public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewActivity(string enableGrpcAspNetCoreSupport) + public void GrpcAspNetCoreInstrumentationAddsCorrectAttributesWhenItCreatesNewActivity(string? enableGrpcAspNetCoreSupport) { try { diff --git a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/DependencyInjectionConfigTests.cs b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/DependencyInjectionConfigTests.cs index fdfd9488b4..e850dcebf6 100644 --- a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/DependencyInjectionConfigTests.cs +++ b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/DependencyInjectionConfigTests.cs @@ -11,12 +11,13 @@ namespace OpenTelemetry.Instrumentation.Hangfire.Tests; +[Collection("Hangfire")] public class DependencyInjectionConfigTests { [Theory] [InlineData(null)] [InlineData("CustomName")] - public async Task TestTracingOptionsDiConfig(string name) + public async Task TestTracingOptionsDiConfig(string? name) { bool optionsPickedFromDi = false; diff --git a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/HangfireInstrumentationJobFilterAttributeTests.cs b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/HangfireInstrumentationJobFilterAttributeTests.cs index 08e7d3cc6c..badd9b8cc6 100644 --- a/test/OpenTelemetry.Instrumentation.Hangfire.Tests/HangfireInstrumentationJobFilterAttributeTests.cs +++ b/test/OpenTelemetry.Instrumentation.Hangfire.Tests/HangfireInstrumentationJobFilterAttributeTests.cs @@ -13,9 +13,10 @@ namespace OpenTelemetry.Instrumentation.Hangfire.Tests; +[Collection("Hangfire")] public class HangfireInstrumentationJobFilterAttributeTests : IClassFixture { - private HangfireFixture hangfireFixture; + private readonly HangfireFixture hangfireFixture; public HangfireInstrumentationJobFilterAttributeTests(HangfireFixture hangfireFixture) { @@ -123,6 +124,7 @@ public async Task Should_Create_Activity_With_Custom_DisplayName() using var tel = Sdk.CreateTracerProviderBuilder() .AddHangfireInstrumentation(options => options.DisplayNameFunc = backgroundJob => $"JOB {backgroundJob.Id}") .AddInMemoryExporter(exportedItems) + .SetSampler() .Build(); // Act diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs index f3610c23e4..f9923b869a 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.Basic.cs @@ -522,7 +522,7 @@ public async Task RedirectTest() } [Fact] - public async void RequestNotCollectedWhenInstrumentationFilterApplied() + public async Task RequestNotCollectedWhenInstrumentationFilterApplied() { var exportedItems = new List(); @@ -563,7 +563,7 @@ public async void RequestNotCollectedWhenInstrumentationFilterApplied() } [Fact] - public async void RequestNotCollectedWhenInstrumentationFilterThrowsException() + public async Task RequestNotCollectedWhenInstrumentationFilterThrowsException() { var exportedItems = new List(); diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs index 97d15fd75c..bbd3908cc5 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpClientTests.cs @@ -349,7 +349,7 @@ private static async Task HttpOutCallsAreCollectedSuccessfullyBodyAsync( var metric = requestMetrics.FirstOrDefault(m => m.Name == "http.client.request.duration"); Assert.NotNull(metric); Assert.Equal("s", metric.Unit); - Assert.True(metric.MetricType == MetricType.Histogram); + Assert.Equal(MetricType.Histogram, metric.MetricType); var metricPoints = new List(); foreach (var p in metric.GetMetricPoints()) diff --git a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs index bc86339834..ce30769a4a 100644 --- a/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Http.Tests/HttpWebRequestActivitySourceTests.netfx.cs @@ -524,7 +524,7 @@ public async Task TestRequestWithException(string method) // check that request failed because of the wrong domain name and not because of reflection var webException = (WebException)ex.InnerException; Assert.NotNull(webException); - Assert.True(webException.Status == WebExceptionStatus.NameResolutionFailure); + Assert.Equal(WebExceptionStatus.NameResolutionFailure, webException.Status); // We should have one Start event and one Stop event with an exception. Assert.Equal(2, eventRecords.Records.Count); @@ -538,7 +538,7 @@ public async Task TestRequestWithException(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Assert.True(activity.Status != ActivityStatusCode.Unset); + Assert.NotEqual(ActivityStatusCode.Unset, activity.Status); Assert.Null(activity.StatusDescription); } @@ -577,8 +577,8 @@ public async Task TestCanceledRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Assert.True(exceptionEvent.Value.Status != ActivityStatusCode.Unset); - Assert.True(exceptionEvent.Value.StatusDescription == null); + Assert.NotEqual(ActivityStatusCode.Unset, exceptionEvent.Value.Status); + Assert.Null(exceptionEvent.Value.StatusDescription); } /// @@ -616,7 +616,7 @@ public async Task TestSecureTransportFailureRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Assert.True(exceptionEvent.Value.Status != ActivityStatusCode.Unset); + Assert.NotEqual(ActivityStatusCode.Unset, exceptionEvent.Value.Status); Assert.Null(exceptionEvent.Value.StatusDescription); } @@ -658,7 +658,7 @@ public async Task TestSecureTransportRetryFailureRequest(string method) Assert.True(eventRecords.Records.TryDequeue(out KeyValuePair exceptionEvent)); Assert.Equal("Stop", exceptionEvent.Key); - Assert.True(exceptionEvent.Value.Status != ActivityStatusCode.Unset); + Assert.NotEqual(ActivityStatusCode.Unset, exceptionEvent.Value.Status); Assert.Null(exceptionEvent.Value.StatusDescription); } @@ -782,34 +782,6 @@ private static void VerifyActivityStopTags(int statusCode, Activity activity) Assert.Equal(statusCode, activity.GetTagValue(SemanticConventions.AttributeHttpResponseStatusCode)); } - private static void ActivityEnrichment(Activity activity, string method, object obj) - { - switch (method) - { - case "OnStartActivity": - Assert.True(obj is HttpWebRequest); - VerifyHeaders(obj as HttpWebRequest); - - if (validateBaggage) - { - ValidateBaggage(obj as HttpWebRequest); - } - - break; - - case "OnStopActivity": - Assert.True(obj is HttpWebResponse); - break; - - case "OnException": - Assert.True(obj is Exception); - break; - - default: - break; - } - } - private static void ValidateBaggage(HttpWebRequest request) { string[] baggage = request.Headers["baggage"].Split(','); diff --git a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs index 71e57081a1..240b8a5ee3 100644 --- a/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs +++ b/test/OpenTelemetry.Instrumentation.Owin.Tests/DiagnosticsMiddlewareTests.cs @@ -180,7 +180,7 @@ public async Task OutgoingRequestInstrumentationTest( this.requestCompleteHandle.Reset(); - using var response = await client.GetAsync(requestUri).ConfigureAwait(false); + using var response = await client.GetAsync(requestUri); /* Note: This code will continue executing as soon as the response is available but Owin could still be working. We need to wait until @@ -309,7 +309,7 @@ public async Task QueryParametersAreRedacted(string actualPath, string expectedP try { - using var response = await client.GetAsync(requestUri).ConfigureAwait(false); + using var response = await client.GetAsync(requestUri); } catch { diff --git a/test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs b/test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs index c766a13ec2..065ad01c33 100644 --- a/test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs +++ b/test/OpenTelemetry.Instrumentation.Process.Tests/ProcessMetricsTests.cs @@ -25,7 +25,7 @@ public void ProcessMetricsAreCaptured() meterProviderA.ForceFlush(MaxTimeToAllowForFlush); - Assert.True(exportedItemsA.Count == 5); + Assert.Equal(5, exportedItemsA.Count); var physicalMemoryMetric = exportedItemsA.FirstOrDefault(i => i.Name == "process.memory.usage"); Assert.NotNull(physicalMemoryMetric); var virtualMemoryMetric = exportedItemsA.FirstOrDefault(i => i.Name == "process.memory.virtual"); @@ -55,8 +55,8 @@ public void ProcessMetricsAreCaptured() meterProviderB.ForceFlush(MaxTimeToAllowForFlush); - Assert.True(exportedItemsA.Count == 5); - Assert.True(exportedItemsB.Count == 5); + Assert.Equal(5, exportedItemsA.Count); + Assert.Equal(5, exportedItemsB.Count); } [Fact] @@ -99,7 +99,7 @@ public void CpuTimeMetricsAreCaptured() } [Fact] - public void ProcessMetricsAreCapturedWhenTasksOverlap() + public async Task ProcessMetricsAreCapturedWhenTasksOverlap() { var exportedItemsA = new List(); var exportedItemsB = new List(); @@ -131,7 +131,7 @@ public void ProcessMetricsAreCapturedWhenTasksOverlap() }), }; - Task.WaitAll(tasks.ToArray()); + await Task.WhenAll(tasks); Assert.Equal(5, exportedItemsA.Count); var physicalMemoryMetricA = exportedItemsA.FirstOrDefault(i => i.Name == "process.memory.usage"); diff --git a/test/OpenTelemetry.Instrumentation.Runtime.Tests/RuntimeMetricsTests.cs b/test/OpenTelemetry.Instrumentation.Runtime.Tests/RuntimeMetricsTests.cs index 25d8c9278e..f0b23686e7 100644 --- a/test/OpenTelemetry.Instrumentation.Runtime.Tests/RuntimeMetricsTests.cs +++ b/test/OpenTelemetry.Instrumentation.Runtime.Tests/RuntimeMetricsTests.cs @@ -111,7 +111,7 @@ public void JitRelatedMetricsTest() } [Fact] - public void ThreadingRelatedMetricsTest() + public async Task ThreadingRelatedMetricsTest() { var exportedItems = new List(); using var meterProvider = Sdk.CreateMeterProviderBuilder() @@ -127,7 +127,7 @@ public void ThreadingRelatedMetricsTest() tasks.Add(Task.Run(() => { })); } - Task.WaitAll(tasks.ToArray()); + await Task.WhenAll(tasks); meterProvider.ForceFlush(MaxTimeToAllowForFlush); diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj index 5b515f5da9..0036dbd152 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/OpenTelemetry.Instrumentation.SqlClient.Tests.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs index 25d0252557..22dea15a54 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlClientTests.cs @@ -14,6 +14,7 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Tests; +[Collection("SqlClient")] public class SqlClientTests : IDisposable { #if !NETFRAMEWORK diff --git a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs index 60e20b880a..fe89800745 100644 --- a/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.SqlClient.Tests/SqlEventSourceTests.netfx.cs @@ -13,6 +13,7 @@ namespace OpenTelemetry.Instrumentation.SqlClient.Tests; +[Collection("SqlClient")] public class SqlEventSourceTests { /* @@ -176,7 +177,7 @@ public void DefaultCaptureTextFalse(Type eventSourceType) using IFakeBehavingSqlEventSource fakeSqlEventSource = (IFakeBehavingSqlEventSource)Activator.CreateInstance(eventSourceType); var exportedItems = new List(); - using var shutdownSignal = Sdk.CreateTracerProviderBuilder() + var shutdownSignal = Sdk.CreateTracerProviderBuilder() .AddInMemoryExporter(exportedItems) .AddSqlClientInstrumentation() .Build(); diff --git a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs index 0055b8be5d..0ee6e264bc 100644 --- a/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs +++ b/test/OpenTelemetry.Instrumentation.StackExchangeRedis.Tests/StackExchangeRedisCallsInstrumentationTests.cs @@ -134,7 +134,7 @@ public void SuccessfulCommandTest(string value) } [Fact] - public async void ProfilerSessionUsesTheSameDefault() + public async Task ProfilerSessionUsesTheSameDefault() { var connectionOptions = new ConfigurationOptions { @@ -287,7 +287,7 @@ public async Task ProfilerSessionsHandleMultipleSpans() using (Activity.Current = new Activity("Child-Span-2").SetParentId(rootActivity.Id).Start()) { // lose async context on purpose - await Task.Delay(100).ConfigureAwait(false); + await Task.Delay(100); ProfilingSession? profiler2 = profilerFactory(); Assert.NotSame(profiler0, profiler2); diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/AspNetParentSpanCorrectorTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Wcf.Tests/AspNetParentSpanCorrectorTests.netfx.cs index d1f22c38b8..63113a4f8d 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/AspNetParentSpanCorrectorTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/AspNetParentSpanCorrectorTests.netfx.cs @@ -37,6 +37,8 @@ public void IncomingRequestHeadersAreOverwrittenWithAspNetParent() Assert.Contains(aspNetActivity.TraceId.ToString(), headerVal); Assert.Contains(aspNetActivity.SpanId.ToString(), headerVal); } + + WcfInstrumentationActivitySource.Options = null; } private class FakeHttpContext diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs index c5f48d326c..b52bf865ca 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForHttpTests.cs @@ -199,15 +199,13 @@ public async Task OutgoingRequestInstrumentationTest( { await client.ExecuteWithEmptyActionNameAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } else { await client.ExecuteAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } } finally @@ -295,7 +293,7 @@ await client.ExecuteAsync( } [Fact] - public async void ActivitiesHaveCorrectParentTest() + public async Task ActivitiesHaveCorrectParentTest() { var testSource = new ActivitySource("TestSource"); @@ -348,7 +346,7 @@ public async void ActivitiesHaveCorrectParentTest() } [Fact] - public async void ErrorsAreHandledProperlyTest() + public async Task ErrorsAreHandledProperlyTest() { var testSource = new ActivitySource("TestSource"); diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForTcpTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForTcpTests.netfx.cs index f2b2a2612c..f48f622724 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForTcpTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryBindingElementForTcpTests.netfx.cs @@ -112,15 +112,13 @@ public async Task OutgoingRequestInstrumentationTest( { await client.ExecuteWithEmptyActionNameAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } else { await client.ExecuteAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } } finally @@ -209,7 +207,7 @@ await client.ExecuteAsync( } [Fact] - public async void ActivitiesHaveCorrectParentTest() + public async Task ActivitiesHaveCorrectParentTest() { var testSource = new ActivitySource("TestSource"); @@ -262,7 +260,7 @@ public async void ActivitiesHaveCorrectParentTest() } [Fact] - public async void ErrorsAreHandledProperlyTest() + public async Task ErrorsAreHandledProperlyTest() { var testSource = new ActivitySource("TestSource"); @@ -329,7 +327,7 @@ public async void ErrorsAreHandledProperlyTest() } [Fact] - public async void OrphanedTelemetryTimesOut() + public async Task OrphanedTelemetryTimesOut() { var stoppedActivities = new List(); var tracerProvider = Sdk.CreateTracerProviderBuilder() @@ -377,7 +375,7 @@ public async void OrphanedTelemetryTimesOut() } [Fact] - public async void DynamicTimeoutValuesAreRespected() + public async Task DynamicTimeoutValuesAreRespected() { var stoppedActivities = new List(); var tracerProvider = Sdk.CreateTracerProviderBuilder() diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorTests.netfx.cs index 6d11e9eb35..0dcd95ad22 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryDispatchMessageInspectorTests.netfx.cs @@ -153,15 +153,13 @@ public async Task IncomingRequestInstrumentationTest( { await client.ExecuteWithEmptyActionNameAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } else { await client.ExecuteAsync( new ServiceRequest( - payload: "Hello Open Telemetry!")) - .ConfigureAwait(false); + payload: "Hello Open Telemetry!")); } } finally diff --git a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs index 57df14f307..429c1d59fe 100644 --- a/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs +++ b/test/OpenTelemetry.Instrumentation.Wcf.Tests/TelemetryPropagationTests.netfx.cs @@ -82,7 +82,7 @@ public void Dispose() [InlineData("rest", false, false)] public async Task TelemetryContextPropagatesTest( string endpoint, - bool suppressDownstreamInstrumenation = true, + bool suppressDownstreamInstrumentation = true, bool shouldPropagate = true) { var stoppedActivities = new List(); @@ -94,7 +94,7 @@ public async Task TelemetryContextPropagatesTest( ActivitySource.AddActivityListener(activityListener); var tracerProvider = Sdk.CreateTracerProviderBuilder() - .AddWcfInstrumentation(options => options.SuppressDownstreamInstrumentation = suppressDownstreamInstrumenation) + .AddWcfInstrumentation(options => options.SuppressDownstreamInstrumentation = suppressDownstreamInstrumentation) .Build(); var serviceBase = endpoint == "tcp" ? this.serviceBaseUriTcp : this.serviceBaseUriHttp; diff --git a/test/OpenTelemetry.Resources.AWS.Tests/AWSECSDetectorTests.cs b/test/OpenTelemetry.Resources.AWS.Tests/AWSECSDetectorTests.cs index adf8ff8437..b585a32250 100644 --- a/test/OpenTelemetry.Resources.AWS.Tests/AWSECSDetectorTests.cs +++ b/test/OpenTelemetry.Resources.AWS.Tests/AWSECSDetectorTests.cs @@ -61,7 +61,7 @@ public void TestEcsMetadataV3() } [Fact] - public async void TestEcsMetadataV4Ec2() + public async Task TestEcsMetadataV4Ec2() { var source = new CancellationTokenSource(); var token = source.Token; @@ -92,7 +92,7 @@ public async void TestEcsMetadataV4Ec2() } [Fact] - public async void TestEcsMetadataV4Fargate() + public async Task TestEcsMetadataV4Fargate() { var source = new CancellationTokenSource(); var token = source.Token; diff --git a/test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRaySamplerClient.cs b/test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRaySamplerClient.cs index bbec7fefec..e688d30539 100644 --- a/test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRaySamplerClient.cs +++ b/test/OpenTelemetry.Sampler.AWS.Tests/TestAWSXRaySamplerClient.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading.Tasks; using WireMock.RequestBuilders; using WireMock.ResponseBuilders; using WireMock.Server; @@ -30,14 +31,11 @@ public void Dispose() } [Fact] - public void TestGetSamplingRules() + public async Task TestGetSamplingRules() { this.CreateResponse("/GetSamplingRules", "Data/GetSamplingRulesResponse.json"); - var responseTask = this.client.GetSamplingRules(); - responseTask.Wait(); - - List rules = responseTask.Result; + var rules = await this.client.GetSamplingRules(); Assert.Equal(3, rules.Count); @@ -81,23 +79,20 @@ public void TestGetSamplingRules() } [Fact] - public void TestGetSamplingRulesMalformed() + public async Task TestGetSamplingRulesMalformed() { this.mockServer .Given(Request.Create().WithPath("/GetSamplingRules").UsingPost()) .RespondWith( Response.Create().WithStatusCode(200).WithHeader("Content-Type", "application/json").WithBody("notJson")); - var responseTask = this.client.GetSamplingRules(); - responseTask.Wait(); - - List rules = responseTask.Result; + List rules = await this.client.GetSamplingRules(); Assert.Empty(rules); } [Fact] - public void TestGetSamplingTargets() + public async Task TestGetSamplingTargets() { TestClock clock = new TestClock(); @@ -128,10 +123,8 @@ public void TestGetSamplingTargets() clock.ToDouble(clock.Now())), }); - var responseTask = this.client.GetSamplingTargets(request); - responseTask.Wait(); - - GetSamplingTargetsResponse targetsResponse = responseTask.Result!; + var targetsResponse = await this.client.GetSamplingTargets(request); + Assert.NotNull(targetsResponse); Assert.Equal(2, targetsResponse.SamplingTargetDocuments.Count); Assert.Single(targetsResponse.UnprocessedStatistics); @@ -154,7 +147,7 @@ public void TestGetSamplingTargets() } [Fact] - public void TestGetSamplingTargetsWithMalformed() + public async Task TestGetSamplingTargetsWithMalformed() { TestClock clock = new TestClock(); this.mockServer @@ -173,10 +166,7 @@ public void TestGetSamplingTargetsWithMalformed() clock.ToDouble(clock.Now())), }); - var responseTask = this.client.GetSamplingTargets(request); - responseTask.Wait(); - - GetSamplingTargetsResponse? targetsResponse = responseTask.Result; + var targetsResponse = await this.client.GetSamplingTargets(request); Assert.Null(targetsResponse); } diff --git a/test/OpenTelemetry.Sampler.AWS.Tests/TestMatcher.cs b/test/OpenTelemetry.Sampler.AWS.Tests/TestMatcher.cs index 9c70983e7c..7ce3628e4f 100644 --- a/test/OpenTelemetry.Sampler.AWS.Tests/TestMatcher.cs +++ b/test/OpenTelemetry.Sampler.AWS.Tests/TestMatcher.cs @@ -19,7 +19,7 @@ public class TestMatcher [InlineData("HelloWorld", "Hell?W*d")] [InlineData("Hello.World", "*.World")] [InlineData("Bye.World", "*.World")] - public void TestWildcardMatch(string input, string pattern) + public void TestWildcardMatch(string? input, string pattern) { Assert.True(Matcher.WildcardMatch(input, pattern)); } @@ -27,7 +27,7 @@ public void TestWildcardMatch(string input, string pattern) [Theory] [InlineData(null, "Hello*")] [InlineData("HelloWorld", null)] - public void TestWildcardDoesNotMatch(string input, string pattern) + public void TestWildcardDoesNotMatch(string? input, string? pattern) { Assert.False(Matcher.WildcardMatch(input, pattern)); }