public static IServiceCollection AddPerfCounterManager(this IServiceCollection services, IConfiguration configuration)
    {
        IPerfCounter.Init();
        switch (configuration["PerfCounterStorage"])
        {
        case "database":
            services.AddScoped <IPerfCounter, PerfCounterInDatabase>();
            services.TryAddScoped <PerfCounterInDatabase>();
            break;

        default:
            services.AddSingleton <IPerfCounter, DefaultPerfCounter>();
            break;
        }

        services.Configure <HostOptions>(options => options.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore);
        services.AddHostedService <PerfCounterBackService>();
        return(services);
    }