Exemplo n.º 1
0
        private static async Task AssertDiagnosticObserverForWebApplicationBuilder(
            bool useImplicitRouting,
            string path,
            HttpStatusCode statusCode,
            bool isError,
            string resourceName,
            SerializableDictionary expectedTags,
            bool featureFlagEnabled,
            int childSpanCount                         = 1,
            string childSpan1ResourceName              = null,
            SerializableDictionary firstChildSpanTags  = null,
            string childSpan2ResourceName              = null,
            SerializableDictionary secondChildSpanTags = null,
            bool expandRouteParameters                 = false)
        {
            var startup = new EndpointRoutingStartup();
            var builder = Microsoft.AspNetCore.Builder.WebApplication.CreateBuilder();

            startup.ConfigureServices(builder.Services);

            var startupFilter = ErrorHandlingHelper.GetStartupFilter(path);

            if (startupFilter is not null && useImplicitRouting)
            {
                builder.Services.AddSingleton <IStartupFilter>(startupFilter);
            }

            builder.WebHost.UseTestServer();

            var app = builder.Build();

            ErrorHandlingHelper.AddErrorHandlerInline(app, path);
            if (!useImplicitRouting)
            {
                app.UseRouting();
            }

            EndpointRoutingStartup.ConfigureEndpoints(app);

            await app.StartAsync();

            var testServer = (TestServer)app.Services.GetService(typeof(IServer));
            var client     = testServer.CreateClient();

            await AssertDiagnosticObserverSubmitsSpans(
                client,
                path,
                statusCode,
                isError,
                resourceName,
                expectedTags,
                featureFlagEnabled,
                childSpanCount,
                childSpan1ResourceName,
                firstChildSpanTags,
                childSpan2ResourceName,
                secondChildSpanTags,
                expandRouteParameters);
        }
Exemplo n.º 2
0
 public void BadHttpRequest()
 {
     ErrorHandlingHelper.ThrowBadHttpRequestException();
 }