/// <summary> /// Add App Metrics automatically by Elect /// </summary> /// <param name="webHostBuilder"></param> /// <param name="configuration"></param> public static IWebHostBuilder UseElectAppMetrics(this IWebHostBuilder webHostBuilder, ElectAppMetricsOptions configuration) { _configuration = configuration; return(webHostBuilder.UseElectAppMetrics(string.Empty)); }
private static ElectAppMetricsOptions GetElectAppMetricsOptions(IConfiguration configuration, string sectionName = "ElectAppMetrics") { var electAppMetricsOptions = new ElectAppMetricsOptions(); electAppMetricsOptions.IsEnable = configuration.GetValueByEnv <bool>($"{sectionName}:{nameof(electAppMetricsOptions.IsEnable)}"); electAppMetricsOptions.IsEnableMetricsEndpoint = configuration.GetValueByEnv <bool>( $"{sectionName}:{nameof(electAppMetricsOptions.IsEnableMetricsEndpoint)}"); electAppMetricsOptions.MetricsEndpoint = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.MetricsEndpoint)}"); electAppMetricsOptions.IsEnableMetricsTextEndpoint = configuration.GetValueByEnv <bool>( $"{sectionName}:{nameof(electAppMetricsOptions.IsEnableMetricsTextEndpoint)}"); electAppMetricsOptions.MetricsTextEndpoint = configuration.GetValueByEnv <string>( $"{sectionName}:{nameof(electAppMetricsOptions.MetricsTextEndpoint)}"); electAppMetricsOptions.IsEnableEnvEndpoint = configuration.GetValueByEnv <bool>( $"{sectionName}:{nameof(electAppMetricsOptions.IsEnableEnvEndpoint)}"); electAppMetricsOptions.EnvEndpoint = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.EnvEndpoint)}"); electAppMetricsOptions.IsInfluxEnabled = configuration.GetValueByEnv <bool>($"{sectionName}:{nameof(electAppMetricsOptions.IsInfluxEnabled)}"); electAppMetricsOptions.InfluxEndpoint = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.InfluxEndpoint)}"); electAppMetricsOptions.InfluxDatabase = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.InfluxDatabase)}"); electAppMetricsOptions.InfluxUserName = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.InfluxUserName)}"); electAppMetricsOptions.InfluxPassword = configuration.GetValueByEnv <string>($"{sectionName}:{nameof(electAppMetricsOptions.InfluxPassword)}"); electAppMetricsOptions.InfluxInterval = configuration.GetValueByEnv <int>($"{sectionName}:{nameof(electAppMetricsOptions.InfluxInterval)}"); electAppMetricsOptions.IsPrometheusEnabled = configuration.GetValueByEnv <bool>( $"{sectionName}:{nameof(electAppMetricsOptions.IsPrometheusEnabled)}"); electAppMetricsOptions.PrometheusFormatter = configuration.GetValueByEnv <ElectPrometheusFormatter>( $"{sectionName}:{nameof(electAppMetricsOptions.PrometheusFormatter)}"); electAppMetricsOptions.Tags = configuration.GetValueByEnv <Dictionary <string, string> >( $"{sectionName}:{nameof(electAppMetricsOptions.PrometheusFormatter)}"); return(electAppMetricsOptions); }