Exemplo n.º 1
0
        public void VerifyAllConfigOptionsMappedToConfigObject()
        {
            var pipelineConfigObj = new Dictionary <string, object>
            {
                ["inputs"] = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        ["logLevel"] = "Verbose"
                    }
                }
            };

            using (var configFile = new TemporaryFile())
            {
                var pipelineConfig = JsonConvert.SerializeObject(pipelineConfigObj, EventFlowJsonUtilities.DefaultSerializerSettings);

                configFile.Write(pipelineConfig);
                var configBuilder = new ConfigurationBuilder();
                configBuilder.AddJsonFile(configFile.FilePath);
                var configuration       = configBuilder.Build();
                var inputsConfigSection = configuration.GetSection("inputs");
                var configFragments     = inputsConfigSection.GetChildren().ToList();

                var l4nInputConfiguration = new Log4netConfiguration();
                configFragments[0].Bind(l4nInputConfiguration);

                Assert.Equal("Verbose", l4nInputConfiguration.LogLevel);
            }
        }
Exemplo n.º 2
0
        public void Process_Include_Nested(string eol, string eof)
        {
            using var file0 = new TemporaryFile();
            using var file1 = new TemporaryFile();

            file0.Write(Lines(eol, eof,
                              "b",
                              $":r {file1.Path}",
                              "c"
                              ));

            file1.Write(Lines(eol, eof,
                              "included"
                              ));

            var preprocessor = new SqlCmdPreprocessor {
            };

            var batches = preprocessor.Process(
                Lines(eol, eof, "a", $":r {file0.Path}", "d")
                );

            batches.Should().Equal(
                Batch(
                    "a", eol,
                    "b", eol,
                    "included", eof,
                    "c", eof,
                    "d", eof
                    )
                );
        }
        public void CanReadKeywordsInHexFormat()
        {
            string inputConfiguration = @"
                {
                    ""type"": ""EventSource"",
                    ""sources"": [
                        { ""providerName"": ""EventSourceInput-TestEventSource"", ""keywords"": ""0x05"" }
                    ]
                }";


            using (var configFile = new TemporaryFile())
            {
                configFile.Write(inputConfiguration);
                var cb = new ConfigurationBuilder();
                cb.AddJsonFile(configFile.FilePath);
                var configuration = cb.Build();

                var healthReporterMock = new Mock <IHealthReporter>();
                var input = new EventSourceInput(configuration, healthReporterMock.Object);

                Assert.Equal((EventKeywords)0x5, input.EventSources.First().Keywords);

                healthReporterMock.Verify(o => o.ReportWarning(It.IsAny <string>(), It.IsAny <string>()), Times.Never());
                healthReporterMock.Verify(o => o.ReportProblem(It.IsAny <string>(), It.IsAny <string>()), Times.Never());
            }
        }
Exemplo n.º 4
0
        public void Process_Include_BatchSeparatorAfterInclusionBoundary(string eol, string eof)
        {
            using var file = new TemporaryFile();

            file.Write(
                Lines(eol, eof,
                      "GO",
                      "included"
                      )
                );

            var preprocessor = new SqlCmdPreprocessor {
            };

            var batches = preprocessor.Process(
                Lines(eol, eof,
                      $":r {file.Path}",
                      "GO",
                      "main"
                      )
                );

            batches.Should().Equal(
                Batch("included", eof),
                Batch("main", eof)
                );
        }
Exemplo n.º 5
0
        public void VerifyAllConfigOptionsMappedToConfigObject()
        {
            var pipelineConfigObj = new Dictionary <string, object>
            {
                ["outputs"] = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        ["type"]                            = "ElasticSearch",
                        ["indexNamePrefix"]                 = "myprefix",
                        ["serviceUri"]                      = "http://localhost:1000;http://localhost:1001;http://localhost:1002",
                        ["basicAuthenticationUserName"]     = "******",
                        ["basicAuthenticationUserPassword"] = "******",
                        ["numberOfShards"]                  = 10,
                        ["numberOfReplicas"]                = 20,
                        ["refreshInterval"]                 = "60s",
                        ["useSniffingConnectionPooling"]    = "true",
                        ["mappings"]                        = new Dictionary <string, object>
                        {
                            ["properties"] = new Dictionary <string, object>
                            {
                                ["timestamp"] = new Dictionary <string, object>
                                {
                                    ["type"] = "date_nanos"
                                }
                            }
                        }
                    }
                }
            };

            using (var configFile = new TemporaryFile())
            {
                var pipelineConfig = JsonConvert.SerializeObject(pipelineConfigObj, EventFlowJsonUtilities.GetDefaultSerializerSettings());

                configFile.Write(pipelineConfig);
                var configBuilder = new ConfigurationBuilder();
                configBuilder.AddJsonFile(configFile.FilePath);
                var configuration       = configBuilder.Build();
                var outputConfigSection = configuration.GetSection("outputs");
                var configFragments     = outputConfigSection.GetChildren().ToList();

                var esOutputConfiguration = new ElasticSearchOutputConfiguration();
                configFragments[0].Bind(esOutputConfiguration);

                Assert.Equal("myprefix", esOutputConfiguration.IndexNamePrefix);
                Assert.Equal("http://localhost:1000;http://localhost:1001;http://localhost:1002", esOutputConfiguration.ServiceUri);
                Assert.Equal("myesuser", esOutputConfiguration.BasicAuthenticationUserName);
                Assert.Equal("myespass", esOutputConfiguration.BasicAuthenticationUserPassword);
                Assert.Equal(10, esOutputConfiguration.NumberOfShards);
                Assert.Equal(20, esOutputConfiguration.NumberOfReplicas);
                Assert.Equal("60s", esOutputConfiguration.RefreshInterval);

                Assert.NotNull(esOutputConfiguration.Mappings);
                Assert.NotNull(esOutputConfiguration.Mappings.Properties);
                Assert.NotNull(esOutputConfiguration.Mappings.Properties["timestamp"]);

                Assert.Equal("date_nanos", esOutputConfiguration.Mappings.Properties["timestamp"].Type);
            }
        }
Exemplo n.º 6
0
        public void ConnectionStringOverridesConfigurationFile()
        {
            const string aiConfiguration = @"
                <?xml version=""1.0"" encoding=""utf-8""?>
                <ApplicationInsights xmlns=""http://schemas.microsoft.com/ApplicationInsights/2013/Settings"">
                    <InstrumentationKey>c8da242c-9f2d-45ab-913c-c9953516e9c2</InstrumentationKey>
                    <TelemetryChannel Type=""Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel""/>
                </ApplicationInsights>
            ";

            var healthReporterMock = new Mock <IHealthReporter>();
            var telemetry          = new TraceTelemetry();

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(aiConfiguration);
                var config = new ApplicationInsightsOutputConfiguration();
                config.ConnectionString      = "InstrumentationKey=d0198460-ce4a-4efa-9e17-3edef2b40f15";
                config.ConfigurationFilePath = configFile.FilePath;

                var output = new ApplicationInsightsOutput(config, healthReporterMock.Object);

                VerifyNoErrorsOrWarnings(healthReporterMock);

                output.telemetryClient.InitializeInstrumentationKey(telemetry);
            }

            Assert.Equal("d0198460-ce4a-4efa-9e17-3edef2b40f15", telemetry.Context.InstrumentationKey, StringComparer.OrdinalIgnoreCase);
        }
Exemplo n.º 7
0
        public void IConfigurationNoEndpoints()
        {
            var configObj = new { EndpointFilter = new { Allow = true } };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj));

                Assert.Throws <ArgumentException>(() => new AspNetCoreCorrelationConfiguration(build(configFile.FilePath)));
            }
        }
Exemplo n.º 8
0
        public void IConfigurationInvalidOutRequests()
        {
            var configObj = new { InstrumentOutgoingRequests = 123 };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj));

                Assert.Throws <InvalidOperationException>(() => new AspNetCoreCorrelationConfiguration(build(configFile.FilePath)));
            }
        }
Exemplo n.º 9
0
        public void CanReadConfigurationFromJson()
        {
            var healthReporterMock = new Mock <IHealthReporter>();

            using (var configFile = new TemporaryFile())
            {
                string inputConfiguration = @"
                {
                    ""type"": ""Serilog""
                }";
                configFile.Write(inputConfiguration);
                var cb = new ConfigurationBuilder();
                cb.AddJsonFile(configFile.FilePath);
                var configuration = cb.Build();

                var input = new SerilogInput(configuration, healthReporterMock.Object);

                Assert.False(input.inputConfiguration.UseSerilogDepthLevel);
            }

            using (var configFile = new TemporaryFile())
            {
                string inputConfiguration = @"
                {
                    ""type"": ""Serilog"",
                    ""useSerilogDepthLevel"": ""false""
                }";
                configFile.Write(inputConfiguration);
                var cb = new ConfigurationBuilder();
                cb.AddJsonFile(configFile.FilePath);
                var configuration = cb.Build();

                var input = new SerilogInput(configuration, healthReporterMock.Object);

                Assert.False(input.inputConfiguration.UseSerilogDepthLevel);
            }

            using (var configFile = new TemporaryFile())
            {
                string inputConfiguration = @"
                {
                    ""type"": ""Serilog"",
                    ""useSerilogDepthLevel"": ""true""
                }";
                configFile.Write(inputConfiguration);
                var cb = new ConfigurationBuilder();
                cb.AddJsonFile(configFile.FilePath);
                var configuration = cb.Build();

                var input = new SerilogInput(configuration, healthReporterMock.Object);

                Assert.True(input.inputConfiguration.UseSerilogDepthLevel);
            }
        }
Exemplo n.º 10
0
        public void IConfigurationValidEndpointFilter()
        {
            var configObj = new { EndpointFilter = new { Allow = true, Endpoints = new [] { "1.com", "2.com" } } };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj));

                var config = new AspNetCoreCorrelationConfiguration(build(configFile.FilePath));
                Assert.False(config.EndpointFilter.Validate(new Uri("http://3.com")));
                Assert.True(config.EndpointFilter.Validate(new Uri("http://2.com")));
            }
        }
Exemplo n.º 11
0
        public void IConfigurationValidHeaders()
        {
            var configObj = new { Headers = new { CorrelationIdHeaderName = "correlation", RequestIdHeaderName = "request" } };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj));

                var config = new AspNetCoreCorrelationConfiguration(build(configFile.FilePath));
                Assert.True(config.InstrumentOutgoingRequests);
                Assert.Equal("correlation", CorrelationHeaderInfo.CorrelationIdHeaderName);
                Assert.Equal("request", CorrelationHeaderInfo.RequestIdHeaderName);
            }
        }
Exemplo n.º 12
0
        public void Process_Include_CrossInclusionBatches(string eol, string eof)
        {
            using var file0 = new TemporaryFile();
            using var file1 = new TemporaryFile();

            file0.Write(Lines(eol, eof,
                              "file0.a",
                              "GO",
                              "file0.b"
                              ));

            file1.Write(Lines(eol, eof,
                              "file1.a",
                              "GO",
                              "file1.b"
                              ));

            var preprocessor = new SqlCmdPreprocessor {
            };

            var batches = preprocessor.Process(Lines(eol, eof,
                                                     "beg",
                                                     $":r {file0.Path}",
                                                     "mid",
                                                     $":r {file1.Path}",
                                                     "end"
                                                     ));

            batches.Should().Equal(
                // Batch begins in top level and ends in included
                Batch(
                    "beg", eol,
                    "file0.a", eol
                    ),
                // Batch begins in included, continues to top level, and ends in another included
                Batch(
                    "file0.b", eof,
                    "mid", eol,
                    "file1.a", eol
                    ),
                // Batch begins in included and ends in top level
                Batch(
                    "file1.b", eof,
                    "end", eof
                    )
                );
        }
Exemplo n.º 13
0
        public void IConfigurationOutRequests()
        {
            var configObj = new { InstrumentOutgoingRequests = false };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj));

                var config = new AspNetCoreCorrelationConfiguration(build(configFile.FilePath));
                Assert.NotNull(config.ContextFactory);
                Assert.NotNull(config.ContextInjectors);
                Assert.NotNull(config.EndpointFilter);
                Assert.False(config.InstrumentOutgoingRequests);

                Assert.True(config.ContextInjectors.First() is CorrelationContextInjector);
            }
        }
        public void VerifyAllConfigOptionsMappedToConfigObject()
        {
            var pipelineConfigObj = new Dictionary <string, object>
            {
                ["outputs"] = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        ["type"]                            = "ElasticSearch",
                        ["indexNamePrefix"]                 = "myprefix",
                        ["eventDocumentTypeName"]           = "mytype",
                        ["serviceUri"]                      = "http://localhost:1000;http://localhost:1001;http://localhost:1002",
                        ["basicAuthenticationUserName"]     = "******",
                        ["basicAuthenticationUserPassword"] = "******",
                        ["numberOfShards"]                  = 10,
                        ["numberOfReplicas"]                = 20,
                        ["refreshInterval"]                 = "60s",
                    }
                }
            };

            using (var configFile = new TemporaryFile())
            {
                var pipelineConfig = JsonConvert.SerializeObject(pipelineConfigObj);

                configFile.Write(pipelineConfig);
                var configBuilder = new ConfigurationBuilder();
                configBuilder.AddJsonFile(configFile.FilePath);
                var configuration       = configBuilder.Build();
                var outputConfigSection = configuration.GetSection("outputs");
                var configFragments     = outputConfigSection.GetChildren().ToList();

                var esOutputConfiguration = new ElasticSearchOutputConfiguration();
                configFragments[0].Bind(esOutputConfiguration);

                Assert.Equal("myprefix", esOutputConfiguration.IndexNamePrefix);
                Assert.Equal("mytype", esOutputConfiguration.EventDocumentTypeName);
                Assert.Equal("http://localhost:1000;http://localhost:1001;http://localhost:1002", esOutputConfiguration.ServiceUri);
                Assert.Equal("myesuser", esOutputConfiguration.BasicAuthenticationUserName);
                Assert.Equal("myespass", esOutputConfiguration.BasicAuthenticationUserPassword);
                Assert.Equal(10, esOutputConfiguration.NumberOfShards);
                Assert.Equal(20, esOutputConfiguration.NumberOfReplicas);
                Assert.Equal("60s", esOutputConfiguration.RefreshInterval);
            }
        }
Exemplo n.º 15
0
        public void VerifyAllConfigOptionsMappedToConfigObject()
        {
            var pipelineConfigObj = new Dictionary <string, object>
            {
                ["outputs"] = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        ["type"]       = "Http",
                        ["format"]     = "JsonLines",
                        ["ServiceUri"] = "http://localhost:1000",
                        ["basicAuthenticationUserName"]     = "******",
                        ["basicAuthenticationUserPassword"] = "******",
                        ["httpContentType"] = "application/x-custom",
                        ["headers"]         = new Dictionary <string, string>
                        {
                            ["X-Foo"] = "example"
                        }
                    }
                }
            };

            using (var configFile = new TemporaryFile())
            {
                var pipelineConfig = JsonConvert.SerializeObject(pipelineConfigObj, EventFlowJsonUtilities.GetDefaultSerializerSettings());

                configFile.Write(pipelineConfig);
                var configBuilder = new ConfigurationBuilder();
                configBuilder.AddJsonFile(configFile.FilePath);
                var configuration       = configBuilder.Build();
                var outputConfigSection = configuration.GetSection("outputs");
                var configFragments     = outputConfigSection.GetChildren().ToList();

                var httpOutputConfiguration = new HttpOutputConfiguration();
                configFragments[0].Bind(httpOutputConfiguration);

                Assert.Equal("http://localhost:1000", httpOutputConfiguration.ServiceUri);
                Assert.Equal(HttpOutputFormat.JsonLines, httpOutputConfiguration.Format);
                Assert.Equal("mywebuser", httpOutputConfiguration.BasicAuthenticationUserName);
                Assert.Equal("mywebpass", httpOutputConfiguration.BasicAuthenticationUserPassword);
                Assert.Equal("application/x-custom", httpOutputConfiguration.HttpContentType);
                Assert.Equal("example", httpOutputConfiguration.Headers["X-Foo"]);
            }
        }
Exemplo n.º 16
0
        public void IConfigurationInvalidHeaders(string corrHeader, string requestHeader)
        {
            var configObj = new
            {
                Headers = corrHeader == null && requestHeader == null
                    ? null
                    : new
                {
                    CorrelationIdHeaderName = corrHeader,
                    RequestIdHeaderName     = requestHeader
                }
            };

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(JsonConvert.SerializeObject(configObj, new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                }));

                Assert.Throws <ArgumentException>(() => new AspNetCoreCorrelationConfiguration(build(configFile.FilePath)));
            }
        }
Exemplo n.º 17
0
        private static IConfiguration GetAppInsightsTestPipelineConfiguration()
        {
            const string diagnosticPipelineConfiguration = @"
            {
                ""inputs"": [
                    { ""type"": ""ApplicationInsights"" }
                ],
                ""outputs"": [
                    { 
                        ""type"": ""UnitTestOutput"",
                        ""preserveEvents"": ""true""
                    }
                ],

                ""schemaVersion"": ""2016-08-11"",

                ""extensions"": [
                        {
                        ""category"": ""outputFactory"",
                        ""type"": ""UnitTestOutput"",
                        ""qualifiedTypeName"": ""Microsoft.Diagnostics.EventFlow.TestHelpers.UnitTestOutputFactory, Microsoft.Diagnostics.EventFlow.TestHelpers""
                    },
                    {
                        ""category"": ""healthReporter"",
                        ""type"": ""CustomHealthReporter"",
                        ""qualifiedTypeName"": ""Microsoft.Diagnostics.EventFlow.TestHelpers.CustomHealthReporter, Microsoft.Diagnostics.EventFlow.TestHelpers""
                    }
                ]
            }";

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(diagnosticPipelineConfiguration);
                ConfigurationBuilder builder = new ConfigurationBuilder();
                builder.AddJsonFile(configFile.FilePath);
                var configuration = builder.Build();
                return(configuration);
            }
        }
Exemplo n.º 18
0
        public void VerifyAllConfigOptionsMappedToConfigObject()
        {
            var pipelineConfigObj = new Dictionary <string, object>
            {
                ["outputs"] = new List <Dictionary <string, object> >
                {
                    new Dictionary <string, object>
                    {
                        ["type"]       = "Http",
                        ["format"]     = "JsonLines",
                        ["ServiceUri"] = "http://localhost:1000",
                        ["basicAuthenticationUserName"]     = "******",
                        ["basicAuthenticationUserPassword"] = "******",
                        ["httpContentType"] = "application/x-custom",
                    }
                }
            };

            using (var configFile = new TemporaryFile())
            {
                var pipelineConfig = JsonConvert.SerializeObject(pipelineConfigObj);

                configFile.Write(pipelineConfig);
                var configBuilder = new ConfigurationBuilder();
                configBuilder.AddJsonFile(configFile.FilePath);
                var configuration       = configBuilder.Build();
                var outputConfigSection = configuration.GetSection("outputs");
                var configFragments     = outputConfigSection.GetChildren().ToList();

                var httpOutputConfiguration = new HttpOutputConfiguration();
                configFragments[0].Bind(httpOutputConfiguration);

                Assert.Equal(httpOutputConfiguration.ServiceUri, "http://localhost:1000");
                Assert.Equal(httpOutputConfiguration.Format, HttpOutputFormat.JsonLines);
                Assert.Equal(httpOutputConfiguration.BasicAuthenticationUserName, "mywebuser");
                Assert.Equal(httpOutputConfiguration.BasicAuthenticationUserPassword, "mywebpass");
                Assert.Equal(httpOutputConfiguration.HttpContentType, "application/x-custom");
            }
        }
Exemplo n.º 19
0
        public void Process_Include_BatchInsideInclude(string eol, string eof)
        {
            using var file = new TemporaryFile();

            file.Write(Lines(eol, eof,
                             "file.a",
                             "GO",
                             "file.b",
                             "GO",
                             "file.c"
                             ));

            var preprocessor = new SqlCmdPreprocessor {
            };

            var batches = preprocessor.Process(Lines(eol, eof,
                                                     "beg",
                                                     $":r {file.Path}",
                                                     "end"
                                                     ));

            batches.Should().Equal(
                // Batch begins in top level and ends in included
                Batch(
                    "beg", eol,
                    "file.a", eol
                    ),
                // Batch begins in included and ends in same included
                Batch(
                    "file.b", eol
                    ),
                // Batch begins in included and ends in top level
                Batch(
                    "file.c", eof,
                    "end", eof
                    )
                );
        }
        public void CanReadJsonConfiguration()
        {
            string inputConfiguration = @"
                {
                    ""type"": ""ActivitySource"",
                    ""sources"": [
                        {
                            ""ActivitySourceName"": ""Alpha""
                        },
                        {
                            ""ActivityName"": ""SuperImportant""
                        },
                        {
                            ""ActivitySourceName"": ""Bravo"",
                            ""ActivityName"": ""BravoOne""
                        },
                        {
                            ""ActivitySourceName"": ""Bravo"",
                            ""ActivityName"": ""BravoTwo"",
                            ""CapturedData"": ""PropagationData"",
                            ""CapturedEvents"": ""Start""
                        },
                    ]
                }
            ";

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(inputConfiguration);
                var cb = new ConfigurationBuilder();
                cb.AddJsonFile(configFile.FilePath);
                var configuration = cb.Build();

                var healthReporter = new Mock <IHealthReporter>();
                var input          = new ActivitySourceInput(configuration, healthReporter.Object);

                healthReporter.VerifyNoOtherCalls();
                Assert.Collection(input.Configuration.Sources,
                                  sc => {
                    Assert.Equal("Alpha", sc.ActivitySourceName, StringComparer.Ordinal);
                    Assert.True(string.IsNullOrEmpty(sc.ActivityName));
                    Assert.Equal(ActivitySamplingResult.AllData, sc.CapturedData);
                    Assert.Equal(CapturedActivityEvents.Stop, sc.CapturedEvents);
                },
                                  sc => {
                    Assert.True(string.IsNullOrEmpty(sc.ActivitySourceName));
                    Assert.Equal("SuperImportant", sc.ActivityName, StringComparer.Ordinal);
                    Assert.Equal(ActivitySamplingResult.AllData, sc.CapturedData);
                    Assert.Equal(CapturedActivityEvents.Stop, sc.CapturedEvents);
                },
                                  sc => {
                    Assert.Equal("Bravo", sc.ActivitySourceName, StringComparer.Ordinal);
                    Assert.Equal("BravoOne", sc.ActivityName, StringComparer.Ordinal);
                    Assert.Equal(ActivitySamplingResult.AllData, sc.CapturedData);
                    Assert.Equal(CapturedActivityEvents.Stop, sc.CapturedEvents);
                },
                                  sc => {
                    Assert.Equal("Bravo", sc.ActivitySourceName, StringComparer.OrdinalIgnoreCase);
                    Assert.Equal("BravoTwo", sc.ActivityName, StringComparer.Ordinal);
                    Assert.Equal(ActivitySamplingResult.PropagationData, sc.CapturedData);
                    Assert.Equal(CapturedActivityEvents.Start, sc.CapturedEvents);
                }
                                  );
            }
        }
        public void ReportsAllTelemetryTypes()
        {
            string pipelineConfiguration = @"
                {
                    ""inputs"": [
                        { ""type"": ""ApplicationInsights"" }
                    ],
                    ""outputs"": [
                        { 
                            ""type"": ""UnitTestOutput"",
                            ""preserveEvents"": ""true""
                        }
                    ],

                    ""schemaVersion"": ""2016-08-11"",

                    ""extensions"": [
                         {
                            ""category"": ""outputFactory"",
                            ""type"": ""UnitTestOutput"",
                            ""qualifiedTypeName"": ""Microsoft.Diagnostics.EventFlow.TestHelpers.UnitTestOutputFactory, Microsoft.Diagnostics.EventFlow.TestHelpers""
                        },
                        {
                            ""category"": ""healthReporter"",
                            ""type"": ""CustomHealthReporter"",
                            ""qualifiedTypeName"": ""Microsoft.Diagnostics.EventFlow.TestHelpers.CustomHealthReporter, Microsoft.Diagnostics.EventFlow.TestHelpers""
                        }
                    ]
                }";

            using (var configFile = new TemporaryFile())
            {
                configFile.Write(pipelineConfiguration);
                ConfigurationBuilder builder = new ConfigurationBuilder();
                builder.AddJsonFile(configFile.FilePath);
                var configuration = builder.Build();

                UnitTestOutput unitTestOutput = null;
                using (var pipeline = DiagnosticPipelineFactory.CreatePipeline(configuration))
                {
                    unitTestOutput = pipeline.Sinks.First().Output as UnitTestOutput;

                    string configurationDoc = File.ReadAllText("ApplicationInsights.config");
                    TelemetryConfiguration      telemetryConfiguration = TelemetryConfiguration.CreateFromConfiguration(configurationDoc);
                    EventFlowTelemetryProcessor efTelemetryProcessor   = telemetryConfiguration.TelemetryProcessors.OfType <EventFlowTelemetryProcessor>().First();
                    efTelemetryProcessor.Pipeline = pipeline;

                    TelemetryClient client = new TelemetryClient(telemetryConfiguration);
                    client.TrackTrace("This is a trace");
                    client.TrackRequest("DoStuff", DateTimeOffset.UtcNow, TimeSpan.FromMilliseconds(20), "200 OK", success: true);
                    client.TrackEvent("ImportantEvent", new Dictionary <string, string> {
                        { "eventProp", "foo" }
                    });
                    client.TrackDependency("otherService", "inquire", DateTimeOffset.UtcNow, TimeSpan.FromMilliseconds(57), success: true);
                    client.TrackMetric("rps", 340.7);
                    try
                    {
                        throw new Exception("Oops!");
                    }
                    catch (Exception e)
                    {
                        client.TrackException(e);
                    }
                    client.TrackPageView("Home page");
                    client.TrackAvailability("frontend-service-ping", DateTimeOffset.UtcNow, TimeSpan.FromMilliseconds(73.5), "Munich-DE", success: true);
                }

                Assert.Equal(8, unitTestOutput.EventCount);
                Assert.Collection(unitTestOutput.CapturedEvents,
                                  e => Assert.Equal("trace", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("request", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("event", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("dependency", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("metric", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("exception", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("page_view", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]),
                                  e => Assert.Equal("availability", e.Payload[EventFlowTelemetryProcessor.TelemetryTypeProperty]));
            }
        }