Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up test cases by using consistent variable name #2672

Merged
merged 2 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/Console/TestConsoleExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private static object RunWithActivitySource()
{
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use Console exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("console-test"))
.AddProcessor(new MyProcessor()) // This must be added before ConsoleExporter
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestGrpcNetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal static object Run()
//
// dotnet run grpc

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddGrpcClientInstrumentation()
.AddSource("grpc-net-client-test")
.AddConsoleExporter()
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal static object Run()
{
System.Console.WriteLine("Hello World!");

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddHttpClientInstrumentation()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("http-service-example"))
.AddSource("http-client-test")
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestInMemoryExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private static void RunWithActivitySource(ICollection<Activity> exportedItems)
{
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use InMemory exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("inmemory-test"))
.AddInMemoryExporter(exportedItems)
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestJaegerExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ internal static object RunWithActivity(string host, int port)
{
// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use the Jaeger exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("jaeger-test"))
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.AddJaegerExporter(o =>
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOpenTracingShim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal static object Run(OpenTracingShimOptions options)
{
// Enable OpenTelemetry for the source "MyCompany.MyProduct.MyWebServer"
// and use Console exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("MyCompany.MyProduct.MyWebServer")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("MyServiceName"))
.AddConsoleExporter()
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestOtlpExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static object RunWithActivitySource(string endpoint, string protocol)

// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use OTLP exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("otlp-test"))
.AddOtlpExporter(opt =>
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestRedis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ internal static object Run(string zipkinUri)
var connection = ConnectionMultiplexer.Connect("localhost");

// Configure exporter to export traces to Zipkin
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddZipkinExporter(o =>
{
o.Endpoint = new Uri(zipkinUri);
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestZPagesExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ internal static object Run()
// Start the server
httpServer.Start();

using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("zpages-test")
.AddZPagesExporter(o =>
{
Expand Down
2 changes: 1 addition & 1 deletion examples/Console/TestZipkinExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal static object Run(string zipkinUri)

// Enable OpenTelemetry for the sources "Samples.SampleServer" and "Samples.SampleClient"
// and use the Zipkin exporter.
using var openTelemetry = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource("Samples.SampleClient", "Samples.SampleServer")
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("zipkin-test"))
.AddZipkinExporter(o =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ public void UseOpenTelemetryProtocolActivityExporterWithCustomActivityProcessor(
endCalled = true;
};

var openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(ActivitySourceName)
.AddProcessor(testActivityProcessor)
.AddOtlpExporter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void CheckingCustomActivityProcessor()
endCalled = true;
};

using var openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(ActivitySourceName)
.AddProcessor(testActivityProcessor)
.AddZPagesExporter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void SuppresssesInstrumentation()
var zipkinExporter = new ZipkinExporter(exporterOptions);
var exportActivityProcessor = new BatchActivityExportProcessor(zipkinExporter);

var openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(ActivitySourceName)
.AddProcessor(testActivityProcessor)
.AddProcessor(exportActivityProcessor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void AspNetRequestsAreCollectedSuccessfully(
List<Activity> exportedItems = new List<Activity>(16);

Sdk.SetDefaultTextMapPropagator(new TraceContextPropagator());
using (openTelemetry = Sdk.CreateTracerProviderBuilder()
using (tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetInstrumentation((options) =>
{
options.Filter = httpContext =>
Expand Down Expand Up @@ -275,7 +275,7 @@ public void ExtractContextIrrespectiveOfSamplingDecision(SamplingDecision sampli

var activityProcessor = new Mock<BaseProcessor<Activity>>();
Sdk.SetDefaultTextMapPropagator(propagator.Object);
using (var openTelemetry = Sdk.CreateTracerProviderBuilder()
using (var tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new TestSampler(samplingDecision))
.AddAspNetInstrumentation()
.AddProcessor(activityProcessor.Object).Build())
Expand Down Expand Up @@ -312,7 +312,7 @@ public void ExtractContextIrrespectiveOfTheFilterApplied()
bool isFilterCalled = false;
var activityProcessor = new Mock<BaseProcessor<Activity>>();
Sdk.SetDefaultTextMapPropagator(propagator.Object);
using (var openTelemetry = Sdk.CreateTracerProviderBuilder()
using (var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetInstrumentation(options =>
{
options.Filter = context =>
Expand Down
24 changes: 12 additions & 12 deletions test/OpenTelemetry.Instrumentation.AspNetCore.Tests/BasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public sealed class BasicTests
: IClassFixture<WebApplicationFactory<Startup>>, IDisposable
{
private readonly WebApplicationFactory<Startup> factory;
private TracerProvider openTelemetrySdk = null;
private TracerProvider tracerProvider = null;

public BasicTests(WebApplicationFactory<Startup> factory)
{
Expand All @@ -70,7 +70,7 @@ public async Task StatusIsUnsetOn200Response()
var activityProcessor = new Mock<BaseProcessor<Activity>>();
void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation()
.AddProcessor(activityProcessor.Object)
.Build();
Expand Down Expand Up @@ -114,7 +114,7 @@ public async Task SuccessfulTemplateControllerCallGeneratesASpan(bool shouldEnri
activityProcessor.Setup(x => x.OnStart(It.IsAny<Activity>())).Callback<Activity>(c => c.SetTag("enriched", "no"));
void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation(options =>
{
if (shouldEnrich)
Expand Down Expand Up @@ -163,7 +163,7 @@ public async Task SuccessfulTemplateControllerCallUsesParentContext()
.WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder().AddAspNetCoreInstrumentation()
this.tracerProvider = Sdk.CreateTracerProviderBuilder().AddAspNetCoreInstrumentation()
.AddProcessor(activityProcessor.Object)
.Build();
})))
Expand Down Expand Up @@ -225,7 +225,7 @@ public async Task CustomPropagator()
builder.ConfigureTestServices(services =>
{
Sdk.SetDefaultTextMapPropagator(propagator.Object);
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation()
.AddProcessor(activityProcessor.Object)
.Build();
Expand Down Expand Up @@ -286,7 +286,7 @@ public async Task RequestNotCollectedWhenFilterIsApplied()

void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation((opt) => opt.Filter = (ctx) => ctx.Request.Path != "/api/values/2")
.AddProcessor(activityProcessor.Object)
.Build();
Expand Down Expand Up @@ -330,7 +330,7 @@ public async Task RequestNotCollectedWhenFilterThrowException()

void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation((opt) => opt.Filter = (ctx) =>
{
if (ctx.Request.Path == "/api/values/2")
Expand Down Expand Up @@ -403,7 +403,7 @@ public async Task ExtractContextIrrespectiveOfSamplingDecision(SamplingDecision
.WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new TestSampler(samplingDecision))
.AddAspNetCoreInstrumentation()
.Build();
Expand Down Expand Up @@ -462,7 +462,7 @@ public async Task ExtractContextIrrespectiveOfTheFilterApplied()
.WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation(options =>
{
options.Filter = context =>
Expand Down Expand Up @@ -522,7 +522,7 @@ public async Task BaggageClearedWhenActivityStopped()

void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddAspNetCoreInstrumentation(new AspNetCoreInstrumentation(
new TestHttpInListener(new AspNetCoreInstrumentationOptions())
{
Expand Down Expand Up @@ -572,7 +572,7 @@ public async Task FilterAndEnrichAreOnlyCalledWhenSampled(SamplingDecision sampl
bool enrichCalled = false;
void ConfigureTestServices(IServiceCollection services)
{
this.openTelemetrySdk = Sdk.CreateTracerProviderBuilder()
this.tracerProvider = Sdk.CreateTracerProviderBuilder()
.SetSampler(new TestSampler(samplingDecision))
.AddAspNetCoreInstrumentation(options =>
{
Expand Down Expand Up @@ -605,7 +605,7 @@ void ConfigureTestServices(IServiceCollection services)

public void Dispose()
{
this.openTelemetrySdk?.Dispose();
this.tracerProvider?.Dispose();
}

private static void WaitForProcessorInvocations(Mock<BaseProcessor<Activity>> activityProcessor, int invocationCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void Dispose()
public async Task HttpWebRequestInstrumentationInjectsHeadersAsync()
{
var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation()
.Build();
Expand Down Expand Up @@ -108,7 +108,7 @@ public async Task HttpWebRequestInstrumentationInjectsHeadersAsyncWhenActivityIs
});

Sdk.SetDefaultTextMapPropagator(propagator.Object);
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation()
.Build();
Expand Down Expand Up @@ -155,7 +155,7 @@ public async Task HttpWebRequestInstrumentationInjectsHeadersAsync_CustomFormat(

var activityProcessor = new Mock<BaseProcessor<Activity>>();
Sdk.SetDefaultTextMapPropagator(propagator.Object);
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation()
.Build();
Expand Down Expand Up @@ -199,7 +199,7 @@ public async Task HttpWebRequestInstrumentationInjectsHeadersAsync_CustomFormat(
public async Task HttpWebRequestInstrumentationBacksOffIfAlreadyInstrumented()
{
var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation()
.Build();
Expand All @@ -222,7 +222,7 @@ public async Task HttpWebRequestInstrumentationBacksOffIfAlreadyInstrumented()
public async Task RequestNotCollectedWhenInstrumentationFilterApplied()
{
var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation(
c => c.Filter = (req) => !req.RequestUri.OriginalString.Contains(this.url))
Expand All @@ -238,7 +238,7 @@ public async Task RequestNotCollectedWhenInstrumentationFilterApplied()
public async Task RequestNotCollectedWhenInstrumentationFilterThrowsException()
{
var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation(
c => c.Filter = (req) => throw new Exception("From Instrumentation filter"))
Expand All @@ -256,7 +256,7 @@ public async Task RequestNotCollectedWhenInstrumentationFilterThrowsException()
public void AddHttpClientInstrumentationUsesHttpWebRequestInstrumentationOptions()
{
var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var tracerProviderSdk = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation(options =>
{
Expand All @@ -273,7 +273,7 @@ public async Task HttpWebRequestInstrumentationOnExistingInstance()
await client.GetAsync(this.url).ConfigureAwait(false);

var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation()
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void HttpOutCallsAreCollectedSuccessfully(HttpTestData.HttpOutTestCase tc
out var port);

var activityProcessor = new Mock<BaseProcessor<Activity>>();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.AddHttpClientInstrumentation(options =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void SuccessfulCommandTest(
var activityProcessor = new Mock<BaseProcessor<Activity>>();
activityProcessor.Setup(x => x.OnStart(It.IsAny<Activity>())).Callback<Activity>(c => c.SetTag("enriched", "no"));
var sampler = new TestSampler();
using var shutdownSignal = Sdk.CreateTracerProviderBuilder()
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddProcessor(activityProcessor.Object)
.SetSampler(sampler)
.AddSqlClientInstrumentation(options =>
Expand Down
Loading