Exemple #1
0
        public static IMetricsBuilder ConfigurePrometheus(CeresOptions options, IMetricsBuilder builder)
        {
            if (options.Prometheus == null)
            {
                builder.OutputMetrics.AsPrometheusProtobuf();
                builder.OutputMetrics.AsPrometheusPlainText();
                return(builder);
            }

            switch (options.Prometheus.OutputFormat)
            {
            case "proto":
                builder.OutputMetrics.AsPrometheusProtobuf();
                break;

            case "text":
                builder.OutputMetrics.AsPrometheusPlainText();
                break;

            default:
                builder.OutputMetrics.AsPrometheusProtobuf();
                builder.OutputMetrics.AsPrometheusPlainText();
                break;
            }

            return(builder);
        }
        private static void ConfigureEndpoints(ISolariBuilder builder, CeresOptions options)
        {
            builder.AddBuildAction(new BuildAction("Ceres Endpoints")
            {
                Action = provider =>
                {
                    var appBuilder = provider.GetService <ISolariMarshal>();
                    if (appBuilder == null)
                    {
                        return;
                    }

                    if (options.UseEnvEndpoint)
                    {
                        appBuilder.ApplicationBuilder.UseEnvInfoEndpoint();
                    }
                    if (options.UseProtoEndpoint)
                    {
                        appBuilder.ApplicationBuilder.UseMetricsEndpoint();
                    }
                    if (options.UseTextEndpoint)
                    {
                        appBuilder.ApplicationBuilder.UseMetricsTextEndpoint();
                    }
                }
            });
        }
 public CpuMeasurementHostedService(IOptions <CeresOptions> ceresOptions, ILogger <CpuMeasurementHostedService> logger,
                                    IHostApplicationLifetime lifetime, IMetrics metrics)
 {
     _logger   = logger;
     _lifetime = lifetime;
     _metrics  = metrics;
     _options  = ceresOptions.Value;
 }
 public MemoryMeasurementHostedService(IMetrics metrics, ILogger <MemoryMeasurementHostedService> logger,
                                       IOptions <CeresOptions> options, IHostApplicationLifetime lifetime)
 {
     _logger   = logger;
     _lifetime = lifetime;
     _options  = options.Value;
     _metrics  = metrics;
 }
 private static void ConfigureInfluxDb(ISolariBuilder builder, CeresOptions options, IMetricsBuilder metricsBuilder)
 {
     if (options.InfluxDb is null || !options.InfluxDb.Enabled)
     {
         return;
     }
     ConfigureReporters.ConfigureInfluxDbReporter(options, metricsBuilder);
     builder.Services.AddMetricsReportingHostedService();
 }
 private static void ConfigureMetricsBuilder(IMetricsBuilder metricsBuilder, CeresOptions options, ApplicationOptions appOptions)
 {
     metricsBuilder.Configuration.Configure(a =>
     {
         a.Enabled = options.Enabled;
         a.AddServerTag();
         a.AddEnvTag();
         a.GlobalTags.Add("app", appOptions.ApplicationName);
         a.DefaultContextLabel = appOptions.ApplicationName;
         a.ReportingEnabled    = options.InfluxDb?.Enabled ?? false;
     });
 }
Exemple #7
0
 public static IMetricsBuilder ConfigureInfluxDbReporter(CeresOptions options, IMetricsBuilder builder)
 {
     return(builder.Report.ToInfluxDb(build =>
     {
         build.InfluxDb.BaseUri = new Uri(options.InfluxDb.Uri);
         build.InfluxDb.Consistenency = options.InfluxDb.Consistency;
         build.InfluxDb.Database = options.InfluxDb.Database;
         build.InfluxDb.Password = options.InfluxDb.Password;
         build.InfluxDb.UserName = options.InfluxDb.UserName;
         build.InfluxDb.RetentionPolicy = options.InfluxDb.RetentionPolicy;
         build.InfluxDb.CreateDataBaseIfNotExists = options.InfluxDb.CreateDataBaseIfNotExists;
         build.FlushInterval = options.InfluxDb.GetFlushInterval();
         build.HttpPolicy.Timeout = options.InfluxDb.GetTimeout();
         build.HttpPolicy.BackoffPeriod = options.InfluxDb.GetBackoffPeriod();
         build.HttpPolicy.FailuresBeforeBackoff = options.InfluxDb.FailuresBeforeBackoff;
         build.MetricsOutputFormatter = new MetricsInfluxDbLineProtocolOutputFormatter();
     }));
 }