Example #1
0
        public static void Main(string[] args)
        {
            var configBuilder = new ConfigurationBuilder();
            var config        = configBuilder.AddJsonFile(Path.Combine("configs", "appsettings.json"))
                                .AddEnvironmentVariables()
                                .AddCommandLine(args)
                                .Build();
            var options = new TestConsoleOptions();

            config.Bind(nameof(TestConsoleOptions), options);

            CreateHostBuilder(args, options).Build().Run();
        }
Example #2
0
 public static IHostBuilder CreateHostBuilder(string[] args)
 {
     return(Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration(configurationBuilder =>
     {
         var configBuilder = new ConfigurationBuilder();
         var config = configBuilder
                      .AddJsonFile(Path.Combine("configs", "appsettings.json"))
                      .AddEnvironmentVariables()
                      .Build();
         var testConsoleOptions = new TestConsoleOptions();
         config.Bind(nameof(TestConsoleOptions), testConsoleOptions);
         var databaseType = testConsoleOptions.DatabaseType;
         var strategy = RelationLocatorStrategy.SharedTable;
         configurationBuilder
         .AddJsonFile("configs/appsettings.json")
         .AddJsonFile($"configs/db_configs/claptrap.{databaseType:G}.json".ToLower())
         .AddJsonFile($"configs/db_configs/claptrap.{databaseType:G}.{strategy:G}.json".ToLower());
         configurationBuilder.AddEnvironmentVariables();
     })
            .ConfigureServices(services =>
     {
         services.AddOpenTelemetryTracing(
             builder => builder
             .AddAspNetCoreInstrumentation()
             .AddGrpcClientInstrumentation()
             .AddHttpClientInstrumentation()
             .SetSampler(new ParentBasedSampler(new AlwaysOffSampler()))
             .SetResourceBuilder(ResourceBuilder.CreateDefault().AddService("claptrap-host"))
             .AddSource(ClaptrapActivitySource.Instance.Name)
             .AddZipkinExporter(options =>
                                options.Endpoint = new Uri("http://localhost:9412/api/v2/spans"))
             );
     })
            .UseServiceProviderFactory(_ => new AutofacServiceProviderFactory())
            .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); })
            .UseClaptrapMetrics()
            .ConfigureLogging(logging =>
     {
         logging.ClearProviders();
         logging.SetMinimumLevel(LogLevel.Trace);
     })
            .UseNLog());
 }
Example #3
0
        public static IHostBuilder CreateHostBuilder(string[] args, TestConsoleOptions testConsoleOptions) =>
        Host.CreateDefaultBuilder(args)
        .UseServiceProviderFactory(context => new AutofacServiceProviderFactory())
        .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup <Startup>(); })
        .ConfigureLogging(logging =>
        {
            logging.ClearProviders();
            logging.SetMinimumLevel(LogLevel.Trace);
        })
        .UseNLog()
        .ConfigureAppConfiguration(configurationBuilder =>
        {
            var databaseType = testConsoleOptions.DatabaseType;
            var strategy     = RelationLocatorStrategy.SharedTable;
            configurationBuilder
            .AddJsonFile("configs/appsettings.json")
            .AddJsonFile($"configs/db_configs/claptrap.{databaseType:G}.json".ToLower())
            .AddJsonFile($"configs/db_configs/claptrap.{databaseType:G}.{strategy:G}.json".ToLower());

            configurationBuilder.AddEnvironmentVariables();
        })
        .UseClaptrapMetrics();