• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DemoBytom / DemoEngine / 24967157351

26 Apr 2026 09:11PM UTC coverage: 28.482% (+0.2%) from 28.251%
24967157351

push

coveralls.net

DemoBytom
Add OpenTelemetry to engine

1225 of 4301 relevant lines covered (28.48%)

0.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Demo.Engine.Core/Extensions/CoreHostExtensions.cs
1
// Copyright © Michał Dembski and contributors.
2
// Distributed under MIT license. See LICENSE file in the root for more information.
3

4
using System.Reflection;
5
using Microsoft.Extensions.Configuration;
6
using Microsoft.Extensions.DependencyInjection;
7
using Microsoft.Extensions.Hosting;
8
using Microsoft.Extensions.Logging;
9

10
namespace Demo.Engine.Core.Extensions;
11

12
public static class CoreHostExtensions
13
{
14
    /// <summary>
15
    /// Creates a default (yet different than <see cref="Host.CreateDefaultBuilder(string[])"/>)
16
    /// host builder
17
    /// </summary>
18
    /// <param name="hostBuilder"></param>
19
    /// <param name="args">command line arguments</param>
20
    /// <param name="appsettingsFile">appsettings filename, default is "appsettings.json"</param>
21
    /// <returns>Preconfigured <see cref="IHostBuilder"/></returns>
22
    public static IHostBuilder CreateDefault(
23
        this IHostBuilder hostBuilder,
24
        string[] args,
25
        string appsettingsFile = "appsettings.json")
26
        => hostBuilder
×
27
        .UseContentRoot(Directory.GetCurrentDirectory())
×
28
        .ConfigureHostConfiguration((configHost) =>
×
29
        {
×
30
            _ = configHost
×
31
                .SetBasePath(Directory.GetCurrentDirectory())
×
32
                .AddEnvironmentVariables("DEMOENGINE_")
×
33
                //.AddEnvironmentVariables("DOTNET_")
×
34
                //.AddEnvironmentVariables("OTEL_")
×
35
                .AddEnvironmentVariables()
×
36
                ;
×
37
            if (args is not null)
×
38
            {
×
39
                _ = configHost.AddCommandLine(args);
×
40
            }
×
41
        })
×
42
        .ConfigureAppConfiguration((hostingContext, configApp) =>
×
43
        {
×
44
            var env = hostingContext.HostingEnvironment;
×
45
            _ = configApp
×
46
                .AddJsonFile(appsettingsFile, optional: false, reloadOnChange: true);
×
47

×
48
            if (env.IsDevelopment())
×
49
            {
×
50
                var appAssembly = Assembly.GetExecutingAssembly(); //Assembly.Load(new AssemblyName(env.ApplicationName));
×
51
                if (appAssembly is not null)
×
52
                {
×
53
                    _ = configApp.AddUserSecrets(appAssembly, optional: true);
×
54
                }
×
55
            }
×
56

×
57
            if (args is not null)
×
58
            {
×
59
                _ = configApp.AddCommandLine(args);
×
60
            }
×
61
        })
×
62
        .ConfigureServices((hostContext, services) => services
×
63
            .Configure<ConsoleLifetimeOptions>(options
×
64
                //supresses the default "Application started. Press Ctrl+C to shut down." etc. log messages, that ConsoleLifetime produces
×
65
                => options.SuppressStatusMessages = true)
×
66
            .AddLogging(logging => logging
×
67
                .AddConfiguration(hostContext.Configuration.GetSection("Logging"))))
×
68
        .UseDefaultServiceProvider((context, options) =>
×
69
        {
×
70
            var isDev = context.HostingEnvironment.IsDevelopment();
×
71
            options.ValidateOnBuild = isDev;
×
72
            options.ValidateScopes = isDev;
×
73
        });
×
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc