fix analysis issues: CA2007 (part2) (#4018)

* fix analysis issues: CA2007

* remove duplicate

Co-authored-by: Mikel Blanchard <mblanchard@macrosssoftware.com>
This commit is contained in:
Timothy Mothra 2022-12-15 16:31:49 -08:00 committed by GitHub
parent 5b9cba7cbd
commit 64f1d74561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 127 additions and 127 deletions

View File

@ -138,7 +138,7 @@ namespace Examples.Console
activity?.SetTag("http.status_code", (int)response.StatusCode); activity?.SetTag("http.status_code", (int)response.StatusCode);
var responseContent = await response.Content.ReadAsStringAsync(); var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
activity?.SetTag("response.content", responseContent); activity?.SetTag("response.content", responseContent);
activity?.SetTag("response.length", responseContent.Length.ToString(CultureInfo.InvariantCulture)); activity?.SetTag("response.length", responseContent.Length.ToString(CultureInfo.InvariantCulture));

View File

@ -87,7 +87,7 @@ namespace Examples.GrpcService
endpoints.MapGet("/", async context => endpoints.MapGet("/", async context =>
{ {
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909"); await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909").ConfigureAwait(false);
}); });
}); });
} }

View File

@ -37,7 +37,7 @@ namespace WorkerService
public override async Task StopAsync(CancellationToken cancellationToken) public override async Task StopAsync(CancellationToken cancellationToken)
{ {
await base.StopAsync(cancellationToken); await base.StopAsync(cancellationToken).ConfigureAwait(false);
} }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) protected override async Task ExecuteAsync(CancellationToken stoppingToken)
@ -46,7 +46,7 @@ namespace WorkerService
this.messageReceiver.StartConsumer(); this.messageReceiver.StartConsumer();
await Task.CompletedTask; await Task.CompletedTask.ConfigureAwait(false);
} }
} }
} }

View File

@ -76,7 +76,7 @@ namespace Benchmarks.Helper
{ {
app.Run(async (context) => app.Run(async (context) =>
{ {
await context.Response.WriteAsync("Hello World!"); await context.Response.WriteAsync("Hello World!").ConfigureAwait(false);
}); });
} }
} }

View File

@ -71,28 +71,28 @@ namespace Benchmarks.Instrumentation
public async Task GlobalCleanupUninstrumentedAspNetCoreAppAsync() public async Task GlobalCleanupUninstrumentedAspNetCoreAppAsync()
{ {
this.httpClient.Dispose(); this.httpClient.Dispose();
await this.app.DisposeAsync(); await this.app.DisposeAsync().ConfigureAwait(false);
} }
[GlobalCleanup(Target = nameof(InstrumentedAspNetCoreAppWithDefaultOptions))] [GlobalCleanup(Target = nameof(InstrumentedAspNetCoreAppWithDefaultOptions))]
public async Task GlobalCleanupInstrumentedAspNetCoreAppWithDefaultOptionsAsync() public async Task GlobalCleanupInstrumentedAspNetCoreAppWithDefaultOptionsAsync()
{ {
this.httpClient.Dispose(); this.httpClient.Dispose();
await this.app.DisposeAsync(); await this.app.DisposeAsync().ConfigureAwait(false);
this.tracerProvider.Dispose(); this.tracerProvider.Dispose();
} }
[Benchmark] [Benchmark]
public async Task UninstrumentedAspNetCoreApp() public async Task UninstrumentedAspNetCoreApp()
{ {
var httpResponse = await this.httpClient.GetAsync("http://localhost:5000/api/values"); var httpResponse = await this.httpClient.GetAsync("http://localhost:5000/api/values").ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
[Benchmark] [Benchmark]
public async Task InstrumentedAspNetCoreAppWithDefaultOptions() public async Task InstrumentedAspNetCoreAppWithDefaultOptions()
{ {
var httpResponse = await this.httpClient.GetAsync("http://localhost:5000/api/values"); var httpResponse = await this.httpClient.GetAsync("http://localhost:5000/api/values").ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }

View File

@ -47,7 +47,7 @@ namespace Benchmarks.Instrumentation
[Benchmark] [Benchmark]
public async Task InstrumentedAspNetCoreGetPage() public async Task InstrumentedAspNetCoreGetPage()
{ {
var httpResponse = await this.client.GetAsync(LocalhostUrl); var httpResponse = await this.client.GetAsync(LocalhostUrl).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
} }

View File

@ -73,7 +73,7 @@ namespace Benchmarks.Instrumentation
[Benchmark] [Benchmark]
public async Task InstrumentedHttpClient() public async Task InstrumentedHttpClient()
{ {
var httpResponse = await this.httpClient.GetAsync(this.url); var httpResponse = await this.httpClient.GetAsync(this.url).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
@ -81,7 +81,7 @@ namespace Benchmarks.Instrumentation
public async Task InstrumentedHttpClientWithParentActivity() public async Task InstrumentedHttpClientWithParentActivity()
{ {
using var parent = this.source.StartActivity(ActivityName, ActivityKind.Server); using var parent = this.source.StartActivity(ActivityName, ActivityKind.Server);
var httpResponse = await this.httpClient.GetAsync(this.url); var httpResponse = await this.httpClient.GetAsync(this.url).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
} }

View File

@ -47,7 +47,7 @@ namespace Benchmarks.Instrumentation
[Benchmark] [Benchmark]
public async Task SimpleAspNetCoreGetPage() public async Task SimpleAspNetCoreGetPage()
{ {
var httpResponse = await this.client.GetAsync(LocalhostUrl); var httpResponse = await this.client.GetAsync(LocalhostUrl).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
} }

View File

@ -54,7 +54,7 @@ namespace Benchmarks.Instrumentation
[Benchmark] [Benchmark]
public async Task SimpleHttpClient() public async Task SimpleHttpClient()
{ {
var httpResponse = await this.httpClient.GetAsync(this.url); var httpResponse = await this.httpClient.GetAsync(this.url).ConfigureAwait(false);
httpResponse.EnsureSuccessStatusCode(); httpResponse.EnsureSuccessStatusCode();
} }
} }

View File

@ -124,7 +124,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
httpRequest = r; httpRequest = r;
// We have to capture content as it can't be accessed after request is disposed inside of SendExportRequest method // We have to capture content as it can't be accessed after request is disposed inside of SendExportRequest method
httpRequestContent = await r.Content.ReadAsByteArrayAsync(); httpRequestContent = await r.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
}) })
#endif #endif
.Verifiable(); .Verifiable();

View File

@ -67,12 +67,12 @@ public sealed class MockCollectorIntegrationTests
endpoints.MapGrpcService<MockTraceService>(); endpoints.MapGrpcService<MockTraceService>();
}); });
})) }))
.StartAsync(); .StartAsync().ConfigureAwait(false);
var httpClient = new HttpClient() { BaseAddress = new System.Uri("http://localhost:5050") }; var httpClient = new HttpClient() { BaseAddress = new System.Uri("http://localhost:5050") };
var codes = new[] { Grpc.Core.StatusCode.Unimplemented, Grpc.Core.StatusCode.OK }; var codes = new[] { Grpc.Core.StatusCode.Unimplemented, Grpc.Core.StatusCode.OK };
await httpClient.GetAsync($"/MockCollector/SetResponseCodes/{string.Join(",", codes.Select(x => (int)x))}"); await httpClient.GetAsync($"/MockCollector/SetResponseCodes/{string.Join(",", codes.Select(x => (int)x))}").ConfigureAwait(false);
var exportResults = new List<ExportResult>(); var exportResults = new List<ExportResult>();
var otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new System.Uri("http://localhost:4317") }); var otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new System.Uri("http://localhost:4317") });

View File

@ -269,7 +269,7 @@ namespace OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests
configureServices?.Invoke(services); configureServices?.Invoke(services);
}) })
.Configure(configure)) .Configure(configure))
.StartAsync(); .StartAsync().ConfigureAwait(false);
var tags = new KeyValuePair<string, object>[] var tags = new KeyValuePair<string, object>[]
{ {

View File

@ -82,13 +82,13 @@ namespace OpenTelemetry.Exporter.Prometheus.Tests
[Fact] [Fact]
public async Task PrometheusExporterHttpServerIntegration() public async Task PrometheusExporterHttpServerIntegration()
{ {
await this.RunPrometheusExporterHttpServerIntegrationTest(); await this.RunPrometheusExporterHttpServerIntegrationTest().ConfigureAwait(false);
} }
[Fact] [Fact]
public async Task PrometheusExporterHttpServerIntegration_NoMetrics() public async Task PrometheusExporterHttpServerIntegration_NoMetrics()
{ {
await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true); await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true).ConfigureAwait(false);
} }
private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetrics = false) private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetrics = false)

View File

@ -164,10 +164,10 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
var zpagesServer = new ZPagesExporterStatsHttpServer(exporter); var zpagesServer = new ZPagesExporterStatsHttpServer(exporter);
zpagesServer.Start(); zpagesServer.Start();
using var httpResponseMessage = await HttpClient.GetAsync("http://localhost:7284/rpcz/"); using var httpResponseMessage = await HttpClient.GetAsync("http://localhost:7284/rpcz/").ConfigureAwait(false);
Assert.True(httpResponseMessage.IsSuccessStatusCode); Assert.True(httpResponseMessage.IsSuccessStatusCode);
var content = await httpResponseMessage.Content.ReadAsStringAsync(); var content = await httpResponseMessage.Content.ReadAsStringAsync().ConfigureAwait(false);
Assert.Contains($"<td>Test Zipkin Activity 1</td>", content); Assert.Contains($"<td>Test Zipkin Activity 1</td>", content);
Assert.Contains($"<td>Test Zipkin Activity 2</td>", content); Assert.Contains($"<td>Test Zipkin Activity 2</td>", content);

View File

@ -47,11 +47,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
Assert.False(callbackRun); Assert.False(callbackRun);
await host.StartAsync(); await host.StartAsync().ConfigureAwait(false);
Assert.True(callbackRun); Assert.True(callbackRun);
await host.StopAsync(); await host.StopAsync().ConfigureAwait(false);
Assert.True(callbackRun); Assert.True(callbackRun);
@ -94,11 +94,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
Assert.False(configureBuilderCalled); Assert.False(configureBuilderCalled);
await host.StartAsync(); await host.StartAsync().ConfigureAwait(false);
Assert.True(configureBuilderCalled); Assert.True(configureBuilderCalled);
await host.StopAsync(); await host.StopAsync().ConfigureAwait(false);
host.Dispose(); host.Dispose();
} }

View File

@ -47,11 +47,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
Assert.False(callbackRun); Assert.False(callbackRun);
await host.StartAsync(); await host.StartAsync().ConfigureAwait(false);
Assert.True(callbackRun); Assert.True(callbackRun);
await host.StopAsync(); await host.StopAsync().ConfigureAwait(false);
Assert.True(callbackRun); Assert.True(callbackRun);
@ -94,11 +94,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
Assert.False(configureBuilderCalled); Assert.False(configureBuilderCalled);
await host.StartAsync(); await host.StartAsync().ConfigureAwait(false);
Assert.True(configureBuilderCalled); Assert.True(configureBuilderCalled);
await host.StopAsync(); await host.StopAsync().ConfigureAwait(false);
host.Dispose(); host.Dispose();
} }

View File

@ -55,7 +55,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
using var meter = new Meter(meterName); using var meter = new Meter(meterName);
var counter = meter.CreateCounter<long>("meter"); var counter = meter.CreateCounter<long>("meter");
counter.Add(10); counter.Add(10);
}); }).ConfigureAwait(false);
Assert.Single(exportedItems); Assert.Single(exportedItems);
var metricPointsEnumerator = exportedItems[0].GetMetricPoints().GetEnumerator(); var metricPointsEnumerator = exportedItems[0].GetMetricPoints().GetEnumerator();
@ -78,7 +78,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
using var meter = new Meter(meterName); using var meter = new Meter(meterName);
var counter = meter.CreateCounter<long>("meter"); var counter = meter.CreateCounter<long>("meter");
counter.Add(10); counter.Add(10);
}); }).ConfigureAwait(false);
Assert.Single(exportedItems); Assert.Single(exportedItems);
Assert.Equal(10, exportedItems[0].MetricPoints[0].GetSumLong()); Assert.Equal(10, exportedItems[0].MetricPoints[0].GetSumLong());
@ -99,7 +99,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
return Task.CompletedTask; return Task.CompletedTask;
}))) })))
.StartAsync(); .StartAsync().ConfigureAwait(false);
using var response = await host.GetTestClient().GetAsync($"/{nameof(RunMetricsTest)}").ConfigureAwait(false); using var response = await host.GetTestClient().GetAsync($"/{nameof(RunMetricsTest)}").ConfigureAwait(false);

View File

@ -86,7 +86,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
.CreateClient()) .CreateClient())
{ {
// Act // Act
var response = await client.GetAsync("/api/values"); var response = await client.GetAsync("/api/values").ConfigureAwait(false);
// Assert // Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299 response.EnsureSuccessStatusCode(); // Status Code 200-299
@ -133,7 +133,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
.CreateClient()) .CreateClient())
{ {
// Act // Act
var response = await client.GetAsync("/api/values"); var response = await client.GetAsync("/api/values").ConfigureAwait(false);
// Assert // Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299 response.EnsureSuccessStatusCode(); // Status Code 200-299
@ -180,7 +180,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
request.Headers.Add("traceparent", $"00-{expectedTraceId}-{expectedSpanId}-01"); request.Headers.Add("traceparent", $"00-{expectedTraceId}-{expectedSpanId}-01");
// Act // Act
var response = await client.SendAsync(request); var response = await client.SendAsync(request).ConfigureAwait(false);
// Assert // Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299 response.EnsureSuccessStatusCode(); // Status Code 200-299
@ -231,7 +231,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
})) }))
{ {
using var client = testFactory.CreateClient(); using var client = testFactory.CreateClient();
var response = await client.GetAsync("/api/values/2"); var response = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response.EnsureSuccessStatusCode(); // Status Code 200-299 response.EnsureSuccessStatusCode(); // Status Code 200-299
WaitForActivityExport(exportedItems, 1); WaitForActivityExport(exportedItems, 1);
@ -282,8 +282,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
using var client = testFactory.CreateClient(); using var client = testFactory.CreateClient();
// Act // Act
var response1 = await client.GetAsync("/api/values"); var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
var response2 = await client.GetAsync("/api/values/2"); var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
// Assert // Assert
response1.EnsureSuccessStatusCode(); // Status Code 200-299 response1.EnsureSuccessStatusCode(); // Status Code 200-299
@ -334,8 +334,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// Act // Act
using (var inMemoryEventListener = new InMemoryEventListener(AspNetCoreInstrumentationEventSource.Log)) using (var inMemoryEventListener = new InMemoryEventListener(AspNetCoreInstrumentationEventSource.Log))
{ {
var response1 = await client.GetAsync("/api/values"); var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
var response2 = await client.GetAsync("/api/values/2"); var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response1.EnsureSuccessStatusCode(); // Status Code 200-299 response1.EnsureSuccessStatusCode(); // Status Code 200-299
response2.EnsureSuccessStatusCode(); // Status Code 200-299 response2.EnsureSuccessStatusCode(); // Status Code 200-299
@ -379,7 +379,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// Test TraceContext Propagation // Test TraceContext Propagation
var request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityTraceContext"); var request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityTraceContext");
var response = await client.SendAsync(request); var response = await client.SendAsync(request).ConfigureAwait(false);
var childActivityTraceContext = JsonSerializer.Deserialize<Dictionary<string, string>>(response.Content.ReadAsStringAsync().Result); var childActivityTraceContext = JsonSerializer.Deserialize<Dictionary<string, string>>(response.Content.ReadAsStringAsync().Result);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -391,7 +391,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// Test Baggage Context Propagation // Test Baggage Context Propagation
request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityBaggageContext"); request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityBaggageContext");
response = await client.SendAsync(request); response = await client.SendAsync(request).ConfigureAwait(false);
var childActivityBaggageContext = JsonSerializer.Deserialize<IReadOnlyDictionary<string, string>>(response.Content.ReadAsStringAsync().Result); var childActivityBaggageContext = JsonSerializer.Deserialize<IReadOnlyDictionary<string, string>>(response.Content.ReadAsStringAsync().Result);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -445,7 +445,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// Test TraceContext Propagation // Test TraceContext Propagation
var request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityTraceContext"); var request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityTraceContext");
var response = await client.SendAsync(request); var response = await client.SendAsync(request).ConfigureAwait(false);
// Ensure that filter was called // Ensure that filter was called
Assert.True(isFilterCalled); Assert.True(isFilterCalled);
@ -461,7 +461,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// Test Baggage Context Propagation // Test Baggage Context Propagation
request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityBaggageContext"); request = new HttpRequestMessage(HttpMethod.Get, "/api/GetChildActivityBaggageContext");
response = await client.SendAsync(request); response = await client.SendAsync(request).ConfigureAwait(false);
var childActivityBaggageContext = JsonSerializer.Deserialize<IReadOnlyDictionary<string, string>>(response.Content.ReadAsStringAsync().Result); var childActivityBaggageContext = JsonSerializer.Deserialize<IReadOnlyDictionary<string, string>>(response.Content.ReadAsStringAsync().Result);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
@ -529,7 +529,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
request.Headers.TryAddWithoutValidation("baggage", "TestKey1=123,TestKey2=456"); request.Headers.TryAddWithoutValidation("baggage", "TestKey1=123,TestKey2=456");
// Act // Act
using var response = await client.SendAsync(request); using var response = await client.SendAsync(request).ConfigureAwait(false);
} }
stopSignal.WaitOne(5000); stopSignal.WaitOne(5000);
@ -583,7 +583,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
.CreateClient(); .CreateClient();
// Act // Act
var response = await client.GetAsync("/api/values"); var response = await client.GetAsync("/api/values").ConfigureAwait(false);
// Assert // Assert
Assert.Equal(shouldFilterBeCalled, filterCalled); Assert.Equal(shouldFilterBeCalled, filterCalled);
@ -618,7 +618,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}) })
.CreateClient()) .CreateClient())
{ {
var response = await client.GetAsync("/api/values/2"); var response = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
WaitForActivityExport(exportedItems, 2); WaitForActivityExport(exportedItems, 2);
} }
@ -666,7 +666,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}) })
.CreateClient()) .CreateClient())
{ {
var response = await client.GetAsync("/api/values/2"); var response = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
WaitForActivityExport(exportedItems, 2); WaitForActivityExport(exportedItems, 2);
} }
@ -717,7 +717,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
.CreateClient()) .CreateClient())
{ {
// Act // Act
var response = await client.GetAsync("/api/values"); var response = await client.GetAsync("/api/values").ConfigureAwait(false);
// Assert // Assert
response.EnsureSuccessStatusCode(); // Status Code 200-299 response.EnsureSuccessStatusCode(); // Status Code 200-299
@ -750,7 +750,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
.CreateClient()) .CreateClient())
{ {
// Act // Act
var response = await client.GetAsync("/api/error"); var response = await client.GetAsync("/api/error").ConfigureAwait(false);
WaitForActivityExport(exportedItems, 1); WaitForActivityExport(exportedItems, 1);
} }
@ -816,7 +816,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
using var request = new HttpRequestMessage(HttpMethod.Get, "/api/values"); using var request = new HttpRequestMessage(HttpMethod.Get, "/api/values");
// Act // Act
using var response = await client.SendAsync(request); using var response = await client.SendAsync(request).ConfigureAwait(false);
} }
Assert.Equal(0, numberOfUnSubscribedEvents); Assert.Equal(0, numberOfUnSubscribedEvents);
@ -894,7 +894,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
using var request = new HttpRequestMessage(HttpMethod.Get, "/api/error"); using var request = new HttpRequestMessage(HttpMethod.Get, "/api/error");
// Act // Act
using var response = await client.SendAsync(request); using var response = await client.SendAsync(request).ConfigureAwait(false);
} }
catch catch
{ {
@ -965,7 +965,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
{ {
handler.Run(async (ctx) => handler.Run(async (ctx) =>
{ {
await ctx.Response.WriteAsync("handled"); await ctx.Response.WriteAsync("handled").ConfigureAwait(false);
}); });
}); });
@ -984,7 +984,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
using var client = new HttpClient(); using var client = new HttpClient();
try try
{ {
await client.GetStringAsync("http://localhost:5000/error"); await client.GetStringAsync("http://localhost:5000/error").ConfigureAwait(false);
} }
catch catch
{ {
@ -995,7 +995,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
Assert.Equal(0, numberOfUnSubscribedEvents); Assert.Equal(0, numberOfUnSubscribedEvents);
Assert.Equal(2, numberofSubscribedEvents); Assert.Equal(2, numberofSubscribedEvents);
await app.DisposeAsync(); await app.DisposeAsync().ConfigureAwait(false);
} }
public void Dispose() public void Dispose()

View File

@ -54,7 +54,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
[Fact] [Fact]
public async void ExampleTest() public async void ExampleTest()
{ {
var res = await this.client.GetStringAsync("http://localhost:5000"); var res = await this.client.GetStringAsync("http://localhost:5000").ConfigureAwait(false);
Assert.NotNull(res); Assert.NotNull(res);
this.tracerProvider.ForceFlush(); this.tracerProvider.ForceFlush();
@ -68,7 +68,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// We need to let End callback execute as it is executed AFTER response was returned. // We need to let End callback execute as it is executed AFTER response was returned.
// In unit tests environment there may be a lot of parallel unit tests executed, so // In unit tests environment there may be a lot of parallel unit tests executed, so
// giving some breezing room for the End callback to complete // giving some breezing room for the End callback to complete
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
} }
var activity = this.exportedItems[0]; var activity = this.exportedItems[0];
@ -86,7 +86,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
{ {
this.tracerProvider.Dispose(); this.tracerProvider.Dispose();
this.client.Dispose(); this.client.Dispose();
await this.app.DisposeAsync(); await this.app.DisposeAsync().ConfigureAwait(false);
} }
} }
} }

View File

@ -88,7 +88,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
path += query; path += query;
} }
var response = await client.GetAsync(path); var response = await client.GetAsync(path).ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {
@ -105,7 +105,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// We need to let End callback execute as it is executed AFTER response was returned. // We need to let End callback execute as it is executed AFTER response was returned.
// In unit tests environment there may be a lot of parallel unit tests executed, so // In unit tests environment there may be a lot of parallel unit tests executed, so
// giving some breezing room for the End callback to complete // giving some breezing room for the End callback to complete
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
} }
} }
@ -179,7 +179,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
{ {
context.Response.StatusCode = this.statusCode; context.Response.StatusCode = this.statusCode;
context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = this.reasonPhrase; context.Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = this.reasonPhrase;
await context.Response.WriteAsync("empty"); await context.Response.WriteAsync("empty").ConfigureAwait(false);
if (context.Request.Path.Value.EndsWith("exception")) if (context.Request.Path.Value.EndsWith("exception"))
{ {

View File

@ -64,8 +64,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}) })
.CreateClient()) .CreateClient())
{ {
var response1 = await client.GetAsync("/api/values"); var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
var response2 = await client.GetAsync("/api/values/2"); var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response1.EnsureSuccessStatusCode(); response1.EnsureSuccessStatusCode();
response2.EnsureSuccessStatusCode(); response2.EnsureSuccessStatusCode();
@ -74,7 +74,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// We need to let End callback execute as it is executed AFTER response was returned. // We need to let End callback execute as it is executed AFTER response was returned.
// In unit tests environment there may be a lot of parallel unit tests executed, so // In unit tests environment there may be a lot of parallel unit tests executed, so
// giving some breezing room for the End callback to complete // giving some breezing room for the End callback to complete
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
this.meterProvider.Dispose(); this.meterProvider.Dispose();
@ -111,8 +111,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}) })
.CreateClient()) .CreateClient())
{ {
var response1 = await client.GetAsync("/api/values"); var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
var response2 = await client.GetAsync("/api/values/2"); var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
response1.EnsureSuccessStatusCode(); response1.EnsureSuccessStatusCode();
response2.EnsureSuccessStatusCode(); response2.EnsureSuccessStatusCode();
@ -121,7 +121,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
// We need to let End callback execute as it is executed AFTER response was returned. // We need to let End callback execute as it is executed AFTER response was returned.
// In unit tests environment there may be a lot of parallel unit tests executed, so // In unit tests environment there may be a lot of parallel unit tests executed, so
// giving some breezing room for the End callback to complete // giving some breezing room for the End callback to complete
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
this.meterProvider.Dispose(); this.meterProvider.Dispose();
@ -169,14 +169,14 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
}) })
.CreateClient()) .CreateClient())
{ {
var response = await client.GetAsync("/api/values"); var response = await client.GetAsync("/api/values").ConfigureAwait(false);
response.EnsureSuccessStatusCode(); response.EnsureSuccessStatusCode();
} }
// We need to let End callback execute as it is executed AFTER response was returned. // We need to let End callback execute as it is executed AFTER response was returned.
// In unit tests environment there may be a lot of parallel unit tests executed, so // In unit tests environment there may be a lot of parallel unit tests executed, so
// giving some breezing room for the End callback to complete // giving some breezing room for the End callback to complete
await Task.Delay(TimeSpan.FromSeconds(1)); await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
this.meterProvider.Dispose(); this.meterProvider.Dispose();

View File

@ -66,11 +66,11 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
data = response.ToByteArray(); data = response.ToByteArray();
} }
await ResponseUtils.WriteHeaderAsync(ms, data.Length, compress, CancellationToken.None); await ResponseUtils.WriteHeaderAsync(ms, data.Length, compress, CancellationToken.None).ConfigureAwait(false);
#if NET5_0_OR_GREATER #if NET5_0_OR_GREATER
await ms.WriteAsync(data); await ms.WriteAsync(data).ConfigureAwait(false);
#else #else
await ms.WriteAsync(data, 0, data.Length); await ms.WriteAsync(data, 0, data.Length).ConfigureAwait(false);
#endif #endif
} }
@ -80,7 +80,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
var ms = new MemoryStream(); var ms = new MemoryStream();
foreach (var response in responses) foreach (var response in responses)
{ {
await WriteResponseAsync(ms, response, compressionProvider); await WriteResponseAsync(ms, response, compressionProvider).ConfigureAwait(false);
} }
ms.Seek(0, SeekOrigin.Begin); ms.Seek(0, SeekOrigin.Begin);

View File

@ -38,8 +38,8 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
{ {
using var registration = cancellationToken.Register(() => tcs.TrySetCanceled()); using var registration = cancellationToken.Register(() => tcs.TrySetCanceled());
var result = await Task.WhenAny(sendAsync(request), tcs.Task); var result = await Task.WhenAny(sendAsync(request), tcs.Task).ConfigureAwait(false);
return await result; return await result.ConfigureAwait(false);
}); });
} }

View File

@ -54,7 +54,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
var httpClient = ClientTestHelpers.CreateTestClient(async request => var httpClient = ClientTestHelpers.CreateTestClient(async request =>
{ {
var streamContent = await ClientTestHelpers.CreateResponseContent(new HelloReply()); var streamContent = await ClientTestHelpers.CreateResponseContent(new HelloReply()).ConfigureAwait(false);
var response = ResponseUtils.CreateResponse(HttpStatusCode.OK, streamContent, grpcStatusCode: global::Grpc.Core.StatusCode.OK); var response = ResponseUtils.CreateResponse(HttpStatusCode.OK, streamContent, grpcStatusCode: global::Grpc.Core.StatusCode.OK);
response.TrailingHeaders().Add("grpc-message", "value"); response.TrailingHeaders().Add("grpc-message", "value");
return response; return response;

View File

@ -43,10 +43,10 @@ namespace OpenTelemetry.Instrumentation.Grpc.Services.Tests
var message = $"How are you {request.Name}? {++i}"; var message = $"How are you {request.Name}? {++i}";
this.logger.LogInformation("Sending greeting {Message}.", message); this.logger.LogInformation("Sending greeting {Message}.", message);
await responseStream.WriteAsync(new HelloReply { Message = message }); await responseStream.WriteAsync(new HelloReply { Message = message }).ConfigureAwait(false);
// Gotta look busy // Gotta look busy
await Task.Delay(1000); await Task.Delay(1000).ConfigureAwait(false);
} }
} }
} }

View File

@ -157,7 +157,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
.Build()) .Build())
{ {
using var c = new HttpClient(); using var c = new HttpClient();
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
} }
Assert.Equal(5, processor.Invocations.Count); // SetParentProvider/OnStart/OnEnd/OnShutdown/Dispose called. Assert.Equal(5, processor.Invocations.Count); // SetParentProvider/OnStart/OnEnd/OnShutdown/Dispose called.
@ -231,7 +231,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
.Build()) .Build())
{ {
using var c = new HttpClient(); using var c = new HttpClient();
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
} }
Assert.Equal(5, processor.Invocations.Count); // SetParentProvider/OnStart/OnEnd/OnShutdown/Dispose called. Assert.Equal(5, processor.Invocations.Count); // SetParentProvider/OnStart/OnEnd/OnShutdown/Dispose called.
@ -301,7 +301,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using var c = new HttpClient(); using var c = new HttpClient();
using (SuppressInstrumentationScope.Begin()) using (SuppressInstrumentationScope.Begin())
{ {
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
} }
} }
@ -338,7 +338,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
int maxRetries = 3; int maxRetries = 3;
using var c = new HttpClient(new RetryHandler(new HttpClientHandler(), maxRetries)); using var c = new HttpClient(new RetryHandler(new HttpClientHandler(), maxRetries));
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
// number of exported spans should be 3(maxRetries) // number of exported spans should be 3(maxRetries)
Assert.Equal(maxRetries, exportedItems.Count()); Assert.Equal(maxRetries, exportedItems.Count());
@ -363,7 +363,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
.Build()) .Build())
{ {
using var c = new HttpClient(); using var c = new HttpClient();
await c.GetAsync($"{this.url}redirect"); await c.GetAsync($"{this.url}redirect").ConfigureAwait(false);
} }
#if NETFRAMEWORK #if NETFRAMEWORK
@ -414,7 +414,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
.Build()) .Build())
{ {
using var c = new HttpClient(); using var c = new HttpClient();
await c.GetAsync(this.url); await c.GetAsync(this.url).ConfigureAwait(false);
} }
#if NETFRAMEWORK #if NETFRAMEWORK
@ -445,7 +445,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
{ {
using var c = new HttpClient(); using var c = new HttpClient();
using var inMemoryEventListener = new InMemoryEventListener(HttpInstrumentationEventSource.Log); using var inMemoryEventListener = new InMemoryEventListener(HttpInstrumentationEventSource.Log);
await c.GetAsync(this.url); await c.GetAsync(this.url).ConfigureAwait(false);
Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 4)); Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 4));
} }
@ -466,7 +466,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using var c = new HttpClient(); using var c = new HttpClient();
try try
{ {
await c.GetAsync("https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/"); await c.GetAsync("https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/").ConfigureAwait(false);
} }
catch catch
{ {
@ -492,7 +492,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using var c = new HttpClient(); using var c = new HttpClient();
try try
{ {
await c.GetAsync($"{this.url}500"); await c.GetAsync($"{this.url}500").ConfigureAwait(false);
} }
catch catch
{ {
@ -523,7 +523,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using var c = new HttpClient(); using var c = new HttpClient();
try try
{ {
await c.GetStringAsync($"{this.url}500"); await c.GetStringAsync($"{this.url}500").ConfigureAwait(false);
} }
catch catch
{ {
@ -598,7 +598,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
}; };
using var c = new HttpClient(); using var c = new HttpClient();
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
parent?.Stop(); parent?.Stop();

View File

@ -100,7 +100,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
} }
} }
await c.SendAsync(request); await c.SendAsync(request).ConfigureAwait(false);
} }
catch (Exception) catch (Exception)
{ {
@ -247,7 +247,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }); new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
var t = (Task)this.GetType().InvokeMember(nameof(this.HttpOutCallsAreCollectedSuccessfullyAsync), BindingFlags.InvokeMethod, null, this, HttpTestData.GetArgumentsFromTestCaseObject(input).First()); var t = (Task)this.GetType().InvokeMember(nameof(this.HttpOutCallsAreCollectedSuccessfullyAsync), BindingFlags.InvokeMethod, null, this, HttpTestData.GetArgumentsFromTestCaseObject(input).First());
await t; await t.ConfigureAwait(false);
} }
[Fact] [Fact]

View File

@ -165,7 +165,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
// Send a random Http request to generate some events // Send a random Http request to generate some events
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
(await client.GetAsync(this.BuildRequestUrl())).Dispose(); (await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)).Dispose();
} }
// Just make sure some events are written, to confirm we successfully subscribed to it. // Just make sure some events are written, to confirm we successfully subscribed to it.
@ -190,8 +190,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
(method == "GET" (method == "GET"
? await client.GetAsync(url) ? await client.GetAsync(url).ConfigureAwait(false)
: await client.PostAsync(url, new StringContent("hello world"))).Dispose(); : await client.PostAsync(url, new StringContent("hello world")).ConfigureAwait(false)).Dispose();
} }
// We should have exactly one Start and one Stop event // We should have exactly one Start and one Stop event
@ -221,8 +221,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
(method == "GET" (method == "GET"
? await client.GetAsync(this.BuildRequestUrl()) ? await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)
: await client.PostAsync(this.BuildRequestUrl(), new StringContent("hello world"))).Dispose(); : await client.PostAsync(this.BuildRequestUrl(), new StringContent("hello world")).ConfigureAwait(false)).Dispose();
} }
// There should be no events because we turned off sampling. // There should be no events because we turned off sampling.
@ -258,7 +258,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
stream = webRequest.GetRequestStream(); stream = webRequest.GetRequestStream();
break; break;
case 1: case 1:
stream = await webRequest.GetRequestStreamAsync(); stream = await webRequest.GetRequestStreamAsync().ConfigureAwait(false);
break; break;
case 2: case 2:
{ {
@ -320,7 +320,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
webResponse = webRequest.GetResponse(); webResponse = webRequest.GetResponse();
break; break;
case 1: case 1:
webResponse = await webRequest.GetResponseAsync(); webResponse = await webRequest.GetResponseAsync().ConfigureAwait(false);
break; break;
case 2: case 2:
{ {
@ -407,7 +407,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
// Send a random Http request to generate some events // Send a random Http request to generate some events
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
(await client.GetAsync(this.BuildRequestUrl())).Dispose(); (await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)).Dispose();
} }
parent.Stop(); parent.Stop();
@ -448,7 +448,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Content = new StringContent("hello world"); request.Content = new StringContent("hello world");
} }
(await client.SendAsync(request)).Dispose(); (await client.SendAsync(request).ConfigureAwait(false)).Dispose();
} }
// No events are sent. // No events are sent.
@ -476,8 +476,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
using HttpResponseMessage response = method == "GET" using HttpResponseMessage response = method == "GET"
? await client.GetAsync(url) ? await client.GetAsync(url).ConfigureAwait(false)
: await client.PostAsync(url, new StringContent("hello world")); : await client.PostAsync(url, new StringContent("hello world")).ConfigureAwait(false);
} }
// We should have exactly one Start and one Stop event // We should have exactly one Start and one Stop event
@ -509,8 +509,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
using HttpResponseMessage response = method == "GET" using HttpResponseMessage response = method == "GET"
? await client.GetAsync(this.BuildRequestUrl(queryString: "redirects=10")) ? await client.GetAsync(this.BuildRequestUrl(queryString: "redirects=10")).ConfigureAwait(false)
: await client.PostAsync(this.BuildRequestUrl(queryString: "redirects=10"), new StringContent("hello world")); : await client.PostAsync(this.BuildRequestUrl(queryString: "redirects=10"), new StringContent("hello world")).ConfigureAwait(false);
} }
// We should have exactly one Start and one Stop event // We should have exactly one Start and one Stop event
@ -539,7 +539,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
return method == "GET" return method == "GET"
? new HttpClient().GetAsync(url) ? new HttpClient().GetAsync(url)
: new HttpClient().PostAsync(url, new StringContent("hello world")); : new HttpClient().PostAsync(url, new StringContent("hello world"));
}); }).ConfigureAwait(false);
// check that request failed because of the wrong domain name and not because of reflection // check that request failed because of the wrong domain name and not because of reflection
var webException = (WebException)ex.InnerException; var webException = (WebException)ex.InnerException;
@ -582,7 +582,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
return method == "GET" return method == "GET"
? client.GetAsync(url, cts.Token) ? client.GetAsync(url, cts.Token)
: client.PostAsync(url, new StringContent("hello world"), cts.Token); : client.PostAsync(url, new StringContent("hello world"), cts.Token);
}); }).ConfigureAwait(false);
Assert.True(ex is TaskCanceledException || ex is WebException); Assert.True(ex is TaskCanceledException || ex is WebException);
} }
@ -621,7 +621,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
return method == "GET" return method == "GET"
? client.GetAsync(url) ? client.GetAsync(url)
: client.PostAsync(url, new StringContent("hello world")); : client.PostAsync(url, new StringContent("hello world"));
}); }).ConfigureAwait(false);
Assert.True(ex is HttpRequestException); Assert.True(ex is HttpRequestException);
} }
@ -663,7 +663,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
return method == "GET" return method == "GET"
? client.GetAsync(url) ? client.GetAsync(url)
: client.PostAsync(url, new StringContent("hello world")); : client.PostAsync(url, new StringContent("hello world"));
}); }).ConfigureAwait(false);
Assert.True(ex is HttpRequestException); Assert.True(ex is HttpRequestException);
} }
@ -695,7 +695,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
using (var client = new HttpClient()) using (var client = new HttpClient())
{ {
(await client.GetAsync(this.BuildRequestUrl())).Dispose(); (await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)).Dispose();
} }
Assert.Equal(2, eventRecords.Records.Count()); Assert.Equal(2, eventRecords.Records.Count());

View File

@ -94,7 +94,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Headers.Add("traceparent", "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01"); request.Headers.Add("traceparent", "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01");
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
#if NETFRAMEWORK #if NETFRAMEWORK
// Note: Back-off is part of the .NET Framework reflection only and // Note: Back-off is part of the .NET Framework reflection only and
@ -136,7 +136,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Method = "GET"; request.Method = "GET";
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
#if NETFRAMEWORK #if NETFRAMEWORK
Assert.True(httpWebRequestFilterApplied); Assert.True(httpWebRequestFilterApplied);
@ -170,7 +170,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Method = "GET"; request.Method = "GET";
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 4)); Assert.Single(inMemoryEventListener.Events.Where((e) => e.EventId == 4));
} }
@ -197,7 +197,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
parent.TraceStateString = "k1=v1,k2=v2"; parent.TraceStateString = "k1=v1,k2=v2";
parent.ActivityTraceFlags = ActivityTraceFlags.Recorded; parent.ActivityTraceFlags = ActivityTraceFlags.Recorded;
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
Assert.Equal(3, activityProcessor.Invocations.Count); // SetParentProvider/Begin/End called Assert.Equal(3, activityProcessor.Invocations.Count); // SetParentProvider/Begin/End called
var activity = (Activity)activityProcessor.Invocations[2].Arguments[0]; var activity = (Activity)activityProcessor.Invocations[2].Arguments[0];
@ -281,7 +281,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Method = "GET"; request.Method = "GET";
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
parent?.Stop(); parent?.Stop();
@ -354,7 +354,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Method = "GET"; request.Method = "GET";
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
} }
catch catch
{ {
@ -383,7 +383,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
request.Method = "GET"; request.Method = "GET";
using var response = await request.GetResponseAsync(); using var response = await request.GetResponseAsync().ConfigureAwait(false);
} }
catch catch
{ {

View File

@ -41,7 +41,7 @@ namespace OpenTelemetry.Tests
try try
{ {
response = await base.SendAsync(request, cancellationToken); response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
} }
catch catch
{ {

View File

@ -74,7 +74,7 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
Encoding.UTF8, Encoding.UTF8,
"application/json"), "application/json"),
}; };
await this.httpClient.SendAsync(request); await this.httpClient.SendAsync(request).ConfigureAwait(false);
} }
} }
else else

View File

@ -75,7 +75,7 @@ namespace OpenTelemetry.Tests
Assert.False(Sdk.SuppressInstrumentation); Assert.False(Sdk.SuppressInstrumentation);
SuppressInstrumentationScope.Enter(); SuppressInstrumentationScope.Enter();
Assert.True(Sdk.SuppressInstrumentation); Assert.True(Sdk.SuppressInstrumentation);
}); }).ConfigureAwait(false);
Assert.False(Sdk.SuppressInstrumentation); // Changes made by SuppressInstrumentationScope.Enter in the task above are not reflected here as it's not part of the same async flow Assert.False(Sdk.SuppressInstrumentation); // Changes made by SuppressInstrumentationScope.Enter in the task above are not reflected here as it's not part of the same async flow
} }

View File

@ -86,16 +86,16 @@ namespace OpenTelemetry.Trace.Tests
async Task DoSomeAsyncWork() async Task DoSomeAsyncWork()
{ {
await Task.Delay(10); await Task.Delay(10).ConfigureAwait(false);
using (tracer.GetTracer("tracername").StartRootSpan("RootSpan2")) using (tracer.GetTracer("tracername").StartRootSpan("RootSpan2"))
{ {
await Task.Delay(10); await Task.Delay(10).ConfigureAwait(false);
} }
} }
using (tracer.GetTracer("tracername").StartActiveSpan("RootSpan1")) using (tracer.GetTracer("tracername").StartActiveSpan("RootSpan1"))
{ {
await DoSomeAsyncWork(); await DoSomeAsyncWork().ConfigureAwait(false);
} }
Assert.Equal(2, exportedItems.Count); Assert.Equal(2, exportedItems.Count);

View File

@ -34,7 +34,7 @@ namespace TestApp.AspNetCore
this.impl.PreProcess(context); this.impl.PreProcess(context);
} }
await this.next(context); await this.next(context).ConfigureAwait(false);
if (this.impl != null) if (this.impl != null)
{ {

View File

@ -29,9 +29,9 @@ namespace TestApp.AspNetCore
public async Task InvokeAsync(HttpContext context) public async Task InvokeAsync(HttpContext context)
{ {
if (this.impl == null || await this.impl.ProcessAsync(context)) if (this.impl == null || await this.impl.ProcessAsync(context).ConfigureAwait(false))
{ {
await this.next(context); await this.next(context).ConfigureAwait(false);
} }
} }
@ -39,7 +39,7 @@ namespace TestApp.AspNetCore
{ {
public virtual async Task<bool> ProcessAsync(HttpContext context) public virtual async Task<bool> ProcessAsync(HttpContext context)
{ {
return await Task.FromResult(true); return await Task.FromResult(true).ConfigureAwait(false);
} }
} }
} }