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:
parent
5b9cba7cbd
commit
64f1d74561
|
|
@ -138,7 +138,7 @@ namespace Examples.Console
|
|||
|
||||
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.length", responseContent.Length.ToString(CultureInfo.InvariantCulture));
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ namespace Examples.GrpcService
|
|||
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace WorkerService
|
|||
|
||||
public override async Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await base.StopAsync(cancellationToken);
|
||||
await base.StopAsync(cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
|
|
@ -46,7 +46,7 @@ namespace WorkerService
|
|||
|
||||
this.messageReceiver.StartConsumer();
|
||||
|
||||
await Task.CompletedTask;
|
||||
await Task.CompletedTask.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ namespace Benchmarks.Helper
|
|||
{
|
||||
app.Run(async (context) =>
|
||||
{
|
||||
await context.Response.WriteAsync("Hello World!");
|
||||
await context.Response.WriteAsync("Hello World!").ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,28 +71,28 @@ namespace Benchmarks.Instrumentation
|
|||
public async Task GlobalCleanupUninstrumentedAspNetCoreAppAsync()
|
||||
{
|
||||
this.httpClient.Dispose();
|
||||
await this.app.DisposeAsync();
|
||||
await this.app.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[GlobalCleanup(Target = nameof(InstrumentedAspNetCoreAppWithDefaultOptions))]
|
||||
public async Task GlobalCleanupInstrumentedAspNetCoreAppWithDefaultOptionsAsync()
|
||||
{
|
||||
this.httpClient.Dispose();
|
||||
await this.app.DisposeAsync();
|
||||
await this.app.DisposeAsync().ConfigureAwait(false);
|
||||
this.tracerProvider.Dispose();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
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();
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Benchmarks.Instrumentation
|
|||
[Benchmark]
|
||||
public async Task InstrumentedAspNetCoreGetPage()
|
||||
{
|
||||
var httpResponse = await this.client.GetAsync(LocalhostUrl);
|
||||
var httpResponse = await this.client.GetAsync(LocalhostUrl).ConfigureAwait(false);
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace Benchmarks.Instrumentation
|
|||
[Benchmark]
|
||||
public async Task InstrumentedHttpClient()
|
||||
{
|
||||
var httpResponse = await this.httpClient.GetAsync(this.url);
|
||||
var httpResponse = await this.httpClient.GetAsync(this.url).ConfigureAwait(false);
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ namespace Benchmarks.Instrumentation
|
|||
public async Task InstrumentedHttpClientWithParentActivity()
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Benchmarks.Instrumentation
|
|||
[Benchmark]
|
||||
public async Task SimpleAspNetCoreGetPage()
|
||||
{
|
||||
var httpResponse = await this.client.GetAsync(LocalhostUrl);
|
||||
var httpResponse = await this.client.GetAsync(LocalhostUrl).ConfigureAwait(false);
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace Benchmarks.Instrumentation
|
|||
[Benchmark]
|
||||
public async Task SimpleHttpClient()
|
||||
{
|
||||
var httpResponse = await this.httpClient.GetAsync(this.url);
|
||||
var httpResponse = await this.httpClient.GetAsync(this.url).ConfigureAwait(false);
|
||||
httpResponse.EnsureSuccessStatusCode();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests
|
|||
httpRequest = r;
|
||||
|
||||
// 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
|
||||
.Verifiable();
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@ public sealed class MockCollectorIntegrationTests
|
|||
endpoints.MapGrpcService<MockTraceService>();
|
||||
});
|
||||
}))
|
||||
.StartAsync();
|
||||
.StartAsync().ConfigureAwait(false);
|
||||
|
||||
var httpClient = new HttpClient() { BaseAddress = new System.Uri("http://localhost:5050") };
|
||||
|
||||
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 otlpExporter = new OtlpTraceExporter(new OtlpExporterOptions() { Endpoint = new System.Uri("http://localhost:4317") });
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ namespace OpenTelemetry.Exporter.Prometheus.AspNetCore.Tests
|
|||
configureServices?.Invoke(services);
|
||||
})
|
||||
.Configure(configure))
|
||||
.StartAsync();
|
||||
.StartAsync().ConfigureAwait(false);
|
||||
|
||||
var tags = new KeyValuePair<string, object>[]
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,13 +82,13 @@ namespace OpenTelemetry.Exporter.Prometheus.Tests
|
|||
[Fact]
|
||||
public async Task PrometheusExporterHttpServerIntegration()
|
||||
{
|
||||
await this.RunPrometheusExporterHttpServerIntegrationTest();
|
||||
await this.RunPrometheusExporterHttpServerIntegrationTest().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PrometheusExporterHttpServerIntegration_NoMetrics()
|
||||
{
|
||||
await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true);
|
||||
await this.RunPrometheusExporterHttpServerIntegrationTest(skipMetrics: true).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task RunPrometheusExporterHttpServerIntegrationTest(bool skipMetrics = false)
|
||||
|
|
|
|||
|
|
@ -164,10 +164,10 @@ namespace OpenTelemetry.Exporter.ZPages.Tests
|
|||
var zpagesServer = new ZPagesExporterStatsHttpServer(exporter);
|
||||
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);
|
||||
|
||||
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 2</td>", content);
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
|
||||
Assert.False(callbackRun);
|
||||
|
||||
await host.StartAsync();
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(callbackRun);
|
||||
|
||||
await host.StopAsync();
|
||||
await host.StopAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(callbackRun);
|
||||
|
||||
|
|
@ -94,11 +94,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
|
||||
Assert.False(configureBuilderCalled);
|
||||
|
||||
await host.StartAsync();
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(configureBuilderCalled);
|
||||
|
||||
await host.StopAsync();
|
||||
await host.StopAsync().ConfigureAwait(false);
|
||||
|
||||
host.Dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,11 +47,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
|
||||
Assert.False(callbackRun);
|
||||
|
||||
await host.StartAsync();
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(callbackRun);
|
||||
|
||||
await host.StopAsync();
|
||||
await host.StopAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(callbackRun);
|
||||
|
||||
|
|
@ -94,11 +94,11 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
|
||||
Assert.False(configureBuilderCalled);
|
||||
|
||||
await host.StartAsync();
|
||||
await host.StartAsync().ConfigureAwait(false);
|
||||
|
||||
Assert.True(configureBuilderCalled);
|
||||
|
||||
await host.StopAsync();
|
||||
await host.StopAsync().ConfigureAwait(false);
|
||||
|
||||
host.Dispose();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
using var meter = new Meter(meterName);
|
||||
var counter = meter.CreateCounter<long>("meter");
|
||||
counter.Add(10);
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
Assert.Single(exportedItems);
|
||||
var metricPointsEnumerator = exportedItems[0].GetMetricPoints().GetEnumerator();
|
||||
|
|
@ -78,7 +78,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
using var meter = new Meter(meterName);
|
||||
var counter = meter.CreateCounter<long>("meter");
|
||||
counter.Add(10);
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
Assert.Single(exportedItems);
|
||||
Assert.Equal(10, exportedItems[0].MetricPoints[0].GetSumLong());
|
||||
|
|
@ -99,7 +99,7 @@ namespace OpenTelemetry.Extensions.Hosting.Tests
|
|||
|
||||
return Task.CompletedTask;
|
||||
})))
|
||||
.StartAsync();
|
||||
.StartAsync().ConfigureAwait(false);
|
||||
|
||||
using var response = await host.GetTestClient().GetAsync($"/{nameof(RunMetricsTest)}").ConfigureAwait(false);
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
.CreateClient())
|
||||
{
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values");
|
||||
var response = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -133,7 +133,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
.CreateClient())
|
||||
{
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values");
|
||||
var response = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -180,7 +180,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
request.Headers.Add("traceparent", $"00-{expectedTraceId}-{expectedSpanId}-01");
|
||||
|
||||
// Act
|
||||
var response = await client.SendAsync(request);
|
||||
var response = await client.SendAsync(request).ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -231,7 +231,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
}))
|
||||
{
|
||||
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
|
||||
|
||||
WaitForActivityExport(exportedItems, 1);
|
||||
|
|
@ -282,8 +282,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
using var client = testFactory.CreateClient();
|
||||
|
||||
// Act
|
||||
var response1 = await client.GetAsync("/api/values");
|
||||
var response2 = await client.GetAsync("/api/values/2");
|
||||
var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response1.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -334,8 +334,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
// Act
|
||||
using (var inMemoryEventListener = new InMemoryEventListener(AspNetCoreInstrumentationEventSource.Log))
|
||||
{
|
||||
var response1 = await client.GetAsync("/api/values");
|
||||
var response2 = await client.GetAsync("/api/values/2");
|
||||
var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
|
||||
response1.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
response2.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -379,7 +379,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
|
||||
// Test TraceContext Propagation
|
||||
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);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
|
@ -391,7 +391,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
// Test Baggage Context Propagation
|
||||
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);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
|
@ -445,7 +445,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
|
||||
// Test TraceContext Propagation
|
||||
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
|
||||
Assert.True(isFilterCalled);
|
||||
|
|
@ -461,7 +461,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
// Test Baggage Context Propagation
|
||||
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);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
|
@ -529,7 +529,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
request.Headers.TryAddWithoutValidation("baggage", "TestKey1=123,TestKey2=456");
|
||||
|
||||
// Act
|
||||
using var response = await client.SendAsync(request);
|
||||
using var response = await client.SendAsync(request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
stopSignal.WaitOne(5000);
|
||||
|
|
@ -583,7 +583,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values");
|
||||
var response = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(shouldFilterBeCalled, filterCalled);
|
||||
|
|
@ -618,7 +618,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
})
|
||||
.CreateClient())
|
||||
{
|
||||
var response = await client.GetAsync("/api/values/2");
|
||||
var response = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
WaitForActivityExport(exportedItems, 2);
|
||||
}
|
||||
|
|
@ -666,7 +666,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
})
|
||||
.CreateClient())
|
||||
{
|
||||
var response = await client.GetAsync("/api/values/2");
|
||||
var response = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
WaitForActivityExport(exportedItems, 2);
|
||||
}
|
||||
|
|
@ -717,7 +717,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
.CreateClient())
|
||||
{
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/values");
|
||||
var response = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
|
||||
// Assert
|
||||
response.EnsureSuccessStatusCode(); // Status Code 200-299
|
||||
|
|
@ -750,7 +750,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
.CreateClient())
|
||||
{
|
||||
// Act
|
||||
var response = await client.GetAsync("/api/error");
|
||||
var response = await client.GetAsync("/api/error").ConfigureAwait(false);
|
||||
|
||||
WaitForActivityExport(exportedItems, 1);
|
||||
}
|
||||
|
|
@ -816,7 +816,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
using var request = new HttpRequestMessage(HttpMethod.Get, "/api/values");
|
||||
|
||||
// Act
|
||||
using var response = await client.SendAsync(request);
|
||||
using var response = await client.SendAsync(request).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Assert.Equal(0, numberOfUnSubscribedEvents);
|
||||
|
|
@ -894,7 +894,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
using var request = new HttpRequestMessage(HttpMethod.Get, "/api/error");
|
||||
|
||||
// Act
|
||||
using var response = await client.SendAsync(request);
|
||||
using var response = await client.SendAsync(request).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -965,7 +965,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
{
|
||||
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();
|
||||
try
|
||||
{
|
||||
await client.GetStringAsync("http://localhost:5000/error");
|
||||
await client.GetStringAsync("http://localhost:5000/error").ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -995,7 +995,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
Assert.Equal(0, numberOfUnSubscribedEvents);
|
||||
Assert.Equal(2, numberofSubscribedEvents);
|
||||
|
||||
await app.DisposeAsync();
|
||||
await app.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
[Fact]
|
||||
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);
|
||||
|
||||
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.
|
||||
// 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
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
var activity = this.exportedItems[0];
|
||||
|
|
@ -86,7 +86,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
{
|
||||
this.tracerProvider.Dispose();
|
||||
this.client.Dispose();
|
||||
await this.app.DisposeAsync();
|
||||
await this.app.DisposeAsync().ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
path += query;
|
||||
}
|
||||
|
||||
var response = await client.GetAsync(path);
|
||||
var response = await client.GetAsync(path).ConfigureAwait(false);
|
||||
}
|
||||
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.
|
||||
// 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
|
||||
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.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"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
})
|
||||
.CreateClient())
|
||||
{
|
||||
var response1 = await client.GetAsync("/api/values");
|
||||
var response2 = await client.GetAsync("/api/values/2");
|
||||
var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
|
||||
response1.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.
|
||||
// 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
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
|
||||
this.meterProvider.Dispose();
|
||||
|
||||
|
|
@ -111,8 +111,8 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
})
|
||||
.CreateClient())
|
||||
{
|
||||
var response1 = await client.GetAsync("/api/values");
|
||||
var response2 = await client.GetAsync("/api/values/2");
|
||||
var response1 = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
var response2 = await client.GetAsync("/api/values/2").ConfigureAwait(false);
|
||||
|
||||
response1.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.
|
||||
// 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
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
|
||||
|
||||
this.meterProvider.Dispose();
|
||||
|
||||
|
|
@ -169,14 +169,14 @@ namespace OpenTelemetry.Instrumentation.AspNetCore.Tests
|
|||
})
|
||||
.CreateClient())
|
||||
{
|
||||
var response = await client.GetAsync("/api/values");
|
||||
var response = await client.GetAsync("/api/values").ConfigureAwait(false);
|
||||
response.EnsureSuccessStatusCode();
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
|
|||
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
|
||||
await ms.WriteAsync(data);
|
||||
await ms.WriteAsync(data).ConfigureAwait(false);
|
||||
#else
|
||||
await ms.WriteAsync(data, 0, data.Length);
|
||||
await ms.WriteAsync(data, 0, data.Length).ConfigureAwait(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
|
|||
var ms = new MemoryStream();
|
||||
foreach (var response in responses)
|
||||
{
|
||||
await WriteResponseAsync(ms, response, compressionProvider);
|
||||
await WriteResponseAsync(ms, response, compressionProvider).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
ms.Seek(0, SeekOrigin.Begin);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests.GrpcTestHelpers
|
|||
{
|
||||
using var registration = cancellationToken.Register(() => tcs.TrySetCanceled());
|
||||
|
||||
var result = await Task.WhenAny(sendAsync(request), tcs.Task);
|
||||
return await result;
|
||||
var result = await Task.WhenAny(sendAsync(request), tcs.Task).ConfigureAwait(false);
|
||||
return await result.ConfigureAwait(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace OpenTelemetry.Instrumentation.Grpc.Tests
|
|||
|
||||
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);
|
||||
response.TrailingHeaders().Add("grpc-message", "value");
|
||||
return response;
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ namespace OpenTelemetry.Instrumentation.Grpc.Services.Tests
|
|||
var message = $"How are you {request.Name}? {++i}";
|
||||
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
|
||||
await Task.Delay(1000);
|
||||
await Task.Delay(1000).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
.Build())
|
||||
{
|
||||
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.
|
||||
|
|
@ -231,7 +231,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
.Build())
|
||||
{
|
||||
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.
|
||||
|
|
@ -301,7 +301,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using var c = new HttpClient();
|
||||
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;
|
||||
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)
|
||||
Assert.Equal(maxRetries, exportedItems.Count());
|
||||
|
|
@ -363,7 +363,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
.Build())
|
||||
{
|
||||
using var c = new HttpClient();
|
||||
await c.GetAsync($"{this.url}redirect");
|
||||
await c.GetAsync($"{this.url}redirect").ConfigureAwait(false);
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
|
|
@ -414,7 +414,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
.Build())
|
||||
{
|
||||
using var c = new HttpClient();
|
||||
await c.GetAsync(this.url);
|
||||
await c.GetAsync(this.url).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
#if NETFRAMEWORK
|
||||
|
|
@ -445,7 +445,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
{
|
||||
using var c = new HttpClient();
|
||||
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));
|
||||
}
|
||||
|
||||
|
|
@ -466,7 +466,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using var c = new HttpClient();
|
||||
try
|
||||
{
|
||||
await c.GetAsync("https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/");
|
||||
await c.GetAsync("https://sdlfaldfjalkdfjlkajdflkajlsdjf.sdlkjafsdjfalfadslkf.com/").ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -492,7 +492,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using var c = new HttpClient();
|
||||
try
|
||||
{
|
||||
await c.GetAsync($"{this.url}500");
|
||||
await c.GetAsync($"{this.url}500").ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -523,7 +523,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using var c = new HttpClient();
|
||||
try
|
||||
{
|
||||
await c.GetStringAsync($"{this.url}500");
|
||||
await c.GetStringAsync($"{this.url}500").ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -598,7 +598,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
};
|
||||
|
||||
using var c = new HttpClient();
|
||||
await c.SendAsync(request);
|
||||
await c.SendAsync(request).ConfigureAwait(false);
|
||||
|
||||
parent?.Stop();
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
}
|
||||
}
|
||||
|
||||
await c.SendAsync(request);
|
||||
await c.SendAsync(request).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -247,7 +247,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
|
||||
|
||||
var t = (Task)this.GetType().InvokeMember(nameof(this.HttpOutCallsAreCollectedSuccessfullyAsync), BindingFlags.InvokeMethod, null, this, HttpTestData.GetArgumentsFromTestCaseObject(input).First());
|
||||
await t;
|
||||
await t.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
// Send a random Http request to generate some events
|
||||
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.
|
||||
|
|
@ -190,8 +190,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
(method == "GET"
|
||||
? await client.GetAsync(url)
|
||||
: await client.PostAsync(url, new StringContent("hello world"))).Dispose();
|
||||
? await client.GetAsync(url).ConfigureAwait(false)
|
||||
: await client.PostAsync(url, new StringContent("hello world")).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
|
||||
// We should have exactly one Start and one Stop event
|
||||
|
|
@ -221,8 +221,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
(method == "GET"
|
||||
? await client.GetAsync(this.BuildRequestUrl())
|
||||
: await client.PostAsync(this.BuildRequestUrl(), new StringContent("hello world"))).Dispose();
|
||||
? await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)
|
||||
: await client.PostAsync(this.BuildRequestUrl(), new StringContent("hello world")).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
|
||||
// There should be no events because we turned off sampling.
|
||||
|
|
@ -258,7 +258,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
stream = webRequest.GetRequestStream();
|
||||
break;
|
||||
case 1:
|
||||
stream = await webRequest.GetRequestStreamAsync();
|
||||
stream = await webRequest.GetRequestStreamAsync().ConfigureAwait(false);
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
|
|
@ -320,7 +320,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
webResponse = webRequest.GetResponse();
|
||||
break;
|
||||
case 1:
|
||||
webResponse = await webRequest.GetResponseAsync();
|
||||
webResponse = await webRequest.GetResponseAsync().ConfigureAwait(false);
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
|
|
@ -407,7 +407,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
// Send a random Http request to generate some events
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
(await client.GetAsync(this.BuildRequestUrl())).Dispose();
|
||||
(await client.GetAsync(this.BuildRequestUrl()).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
|
||||
parent.Stop();
|
||||
|
|
@ -448,7 +448,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
request.Content = new StringContent("hello world");
|
||||
}
|
||||
|
||||
(await client.SendAsync(request)).Dispose();
|
||||
(await client.SendAsync(request).ConfigureAwait(false)).Dispose();
|
||||
}
|
||||
|
||||
// No events are sent.
|
||||
|
|
@ -476,8 +476,8 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
using (var client = new HttpClient())
|
||||
{
|
||||
using HttpResponseMessage response = method == "GET"
|
||||
? await client.GetAsync(url)
|
||||
: await client.PostAsync(url, new StringContent("hello world"));
|
||||
? await client.GetAsync(url).ConfigureAwait(false)
|
||||
: await client.PostAsync(url, new StringContent("hello world")).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// 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 HttpResponseMessage response = method == "GET"
|
||||
? await client.GetAsync(this.BuildRequestUrl(queryString: "redirects=10"))
|
||||
: await client.PostAsync(this.BuildRequestUrl(queryString: "redirects=10"), new StringContent("hello world"));
|
||||
? await client.GetAsync(this.BuildRequestUrl(queryString: "redirects=10")).ConfigureAwait(false)
|
||||
: await client.PostAsync(this.BuildRequestUrl(queryString: "redirects=10"), new StringContent("hello world")).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
// We should have exactly one Start and one Stop event
|
||||
|
|
@ -539,7 +539,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
return method == "GET"
|
||||
? new HttpClient().GetAsync(url)
|
||||
: 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
|
||||
var webException = (WebException)ex.InnerException;
|
||||
|
|
@ -582,7 +582,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
return method == "GET"
|
||||
? client.GetAsync(url, cts.Token)
|
||||
: client.PostAsync(url, new StringContent("hello world"), cts.Token);
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
Assert.True(ex is TaskCanceledException || ex is WebException);
|
||||
}
|
||||
|
||||
|
|
@ -621,7 +621,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
return method == "GET"
|
||||
? client.GetAsync(url)
|
||||
: client.PostAsync(url, new StringContent("hello world"));
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
Assert.True(ex is HttpRequestException);
|
||||
}
|
||||
|
||||
|
|
@ -663,7 +663,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
return method == "GET"
|
||||
? client.GetAsync(url)
|
||||
: client.PostAsync(url, new StringContent("hello world"));
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
Assert.True(ex is HttpRequestException);
|
||||
}
|
||||
|
||||
|
|
@ -695,7 +695,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
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());
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
request.Headers.Add("traceparent", "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01");
|
||||
|
||||
using var response = await request.GetResponseAsync();
|
||||
using var response = await request.GetResponseAsync().ConfigureAwait(false);
|
||||
|
||||
#if NETFRAMEWORK
|
||||
// Note: Back-off is part of the .NET Framework reflection only and
|
||||
|
|
@ -136,7 +136,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
request.Method = "GET";
|
||||
|
||||
using var response = await request.GetResponseAsync();
|
||||
using var response = await request.GetResponseAsync().ConfigureAwait(false);
|
||||
|
||||
#if NETFRAMEWORK
|
||||
Assert.True(httpWebRequestFilterApplied);
|
||||
|
|
@ -170,7 +170,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
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));
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
parent.TraceStateString = "k1=v1,k2=v2";
|
||||
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
|
||||
var activity = (Activity)activityProcessor.Invocations[2].Arguments[0];
|
||||
|
|
@ -281,7 +281,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
request.Method = "GET";
|
||||
|
||||
using var response = await request.GetResponseAsync();
|
||||
using var response = await request.GetResponseAsync().ConfigureAwait(false);
|
||||
|
||||
parent?.Stop();
|
||||
|
||||
|
|
@ -354,7 +354,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
request.Method = "GET";
|
||||
|
||||
using var response = await request.GetResponseAsync();
|
||||
using var response = await request.GetResponseAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
@ -383,7 +383,7 @@ namespace OpenTelemetry.Instrumentation.Http.Tests
|
|||
|
||||
request.Method = "GET";
|
||||
|
||||
using var response = await request.GetResponseAsync();
|
||||
using var response = await request.GetResponseAsync().ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ namespace OpenTelemetry.Tests
|
|||
|
||||
try
|
||||
{
|
||||
response = await base.SendAsync(request, cancellationToken);
|
||||
response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace OpenTelemetry.Instrumentation.W3cTraceContext.Tests
|
|||
Encoding.UTF8,
|
||||
"application/json"),
|
||||
};
|
||||
await this.httpClient.SendAsync(request);
|
||||
await this.httpClient.SendAsync(request).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace OpenTelemetry.Tests
|
|||
Assert.False(Sdk.SuppressInstrumentation);
|
||||
SuppressInstrumentationScope.Enter();
|
||||
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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,16 +86,16 @@ namespace OpenTelemetry.Trace.Tests
|
|||
|
||||
async Task DoSomeAsyncWork()
|
||||
{
|
||||
await Task.Delay(10);
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
using (tracer.GetTracer("tracername").StartRootSpan("RootSpan2"))
|
||||
{
|
||||
await Task.Delay(10);
|
||||
await Task.Delay(10).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
using (tracer.GetTracer("tracername").StartActiveSpan("RootSpan1"))
|
||||
{
|
||||
await DoSomeAsyncWork();
|
||||
await DoSomeAsyncWork().ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Assert.Equal(2, exportedItems.Count);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ namespace TestApp.AspNetCore
|
|||
this.impl.PreProcess(context);
|
||||
}
|
||||
|
||||
await this.next(context);
|
||||
await this.next(context).ConfigureAwait(false);
|
||||
|
||||
if (this.impl != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ namespace TestApp.AspNetCore
|
|||
|
||||
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)
|
||||
{
|
||||
return await Task.FromResult(true);
|
||||
return await Task.FromResult(true).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue