示例#1
0
 public FileManager(MonitoringConfig config, ILogger logger, ShareFolder shareFolder, IMetricServer metricServer)
 {
     _shareFolder  = shareFolder;
     _config       = config;
     _logger       = logger;
     _metricServer = metricServer;
 }
示例#2
0
        protected override void LoadContent()
        {
            this.camera   = new PerspectiveCamera(this.GraphicsDevice.Viewport);
            this.injector = new Injector(this);

            this.injector.Resolve <Content>().LoadContent(this.Content);

            this.spriteBatch    = this.injector.Resolve <SpriteBatch>();
            this.renderPipeline = this.injector.Resolve <DeferredRenderPipeline>();
            this.sceneSelector  = this.injector.Resolve <SceneSelector>();

            this.server   = this.injector.Resolve <Server>();
            this.client   = this.injector.Resolve <Client>();
            this.keyboard = this.injector.Resolve <UI.Input.KeyboardInput>();

            this.metricServer = this.injector.Resolve <IMetricServer>();
            this.metricServer.Start(7070);


            this.uiManager = this.injector.Resolve <UIManager>();
            this.uiManager.LoadState();


            if (this.uiManager.State.NetState.AutoStartServer)
            {
                this.server.Start(Server.DefaultServerPort);
            }

            if (this.uiManager.State.NetState.AutoStartClient)
            {
                this.client.Connect(new IPEndPoint(IPAddress.Loopback, Server.DefaultServerPort));
            }
        }
示例#3
0
        public MetricsEndpointService(ILogger logger, IOptions <MonitoringOptions> options)
        {
            _logger  = logger ?? throw new ArgumentNullException(nameof(logger));
            _options = options?.Value ?? throw new ArgumentNullException(nameof(options));

            _server = new MetricServer(_options.MetricsEndpointPort, _options.MetricsEndpointPath);
        }
 /// <summary>
 /// Stop metric server if enabled
 /// </summary>
 /// <returns></returns>
 public static void StopWhenEnabled(this IMetricServer server, IModuleConfig config, Serilog.ILogger logger)
 {
     if (config.EnableMetrics)
     {
         server.Stop();;
         logger.Information("Stopped prometheus metric server");
     }
 }
示例#5
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            Console.WriteLine($"Staring metric server on {Host}:{Port}");

            _metricServer = new KestrelMetricServer(Host, Port).Start();

            return(Task.CompletedTask);
        }
示例#6
0
 /// <summary>
 /// Start metric server
 /// </summary>
 /// <returns></returns>
 public static void StartWhenEnabled(this IMetricServer server, IModuleConfig config, Serilog.ILogger logger)
 {
     if (config.EnableMetrics)
     {
         server.Start();
         logger.Information("Prometheus metric server started.");
     }
     else
     {
         logger.Information("Metrics Collection is disabled. Not starting prometheus metric server.");
     }
 }
示例#7
0
        protected override void LoadContent()
        {
            this.camera   = new PerspectiveCamera(this.GraphicsDevice.Viewport);
            this.injector = new Injector(this);

            this.spriteBatch    = this.injector.Resolve <SpriteBatch>();
            this.renderPipeline = this.injector.Resolve <DeferredRenderPipeline>();
            this.sceneSelector  = this.injector.Resolve <SceneSelector>();
            this.uiManager      = this.injector.Resolve <UIManager>();

            this.metricServer = this.injector.Resolve <IMetricServer>();
            this.metricServer.Start(7070);
        }
示例#8
0
        public MainSheduler(MonitoringConfig config, ILogger logger, IConfiguration configuration, Gauge counterException, IMetricServer metricServer = null)
        {
            Logger           = logger;
            MetricServer     = metricServer;
            CounterException = counterException;
            MonitoringConfig = config;
            AppConfiguration = configuration;
            var registry = new Registry();

            registry.Schedule <FileMonitoringJob>().NonReentrant().ToRunEvery(config.FileMonitoringTimeout).Seconds();
            registry.Schedule <ApiIntegrationJob>().NonReentrant().ToRunEvery(config.ApiIntegrationTimeout).Seconds();
            JobManager.Initialize(registry);
        }
        public static IMetricServer EnableMetricsServer(Prometheus config)
        {
            IMetricServer metricsServer = null;

            if (config.Enabled)
            {
                var port = config.Port ?? 4000;
                metricsServer = new KestrelMetricServer(port: port);
                metricsServer.Start();

                Log.Information("Metrics Server started and listening on: http://localhost:{0}/metrics", port);
            }

            return(metricsServer);
        }
 /// <summary>
 /// Start metric server
 /// </summary>
 /// <returns></returns>
 public static void StartWhenEnabled(this IMetricServer server, IModuleConfig config, Serilog.ILogger logger)
 {
     if (config.EnableMetrics)
     {
         try {
             server.Start();
             logger.Information("Prometheus metric server started.");
         }
         catch (HttpListenerException e) {
             logger.Error(e, "Unable to start metric server. For more info, please check troubleshooting guide for edge metrics collection");
         }
     }
     else
     {
         logger.Information("Metrics Collection is disabled. Not starting prometheus metric server.");
     }
 }
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="hostName">The host name that will server the data</param>
        /// <param name="port">The port that the metrics server willb exposed on</param>
        /// <param name="url">The URL suffix the metrics server will be exposed on (default: metrics/)</param>
        /// <param name="bufferSize">The number of metrics in a bucket, use multiples of 500 for optimal performance</param>
        /// <param name="ageBuckets">The number of buckets to keep before aging out</param>
        /// <param name="pulseDuration">The duration in seconds of a pulse summary</param>
        public PrometheusMetricsProvider(string hostName, int port, string url = "metrics/", int bufferSize = 1500, int ageBuckets = 5, int pulseDuration = 10)
        {
            _bufferSize    = bufferSize;
            _ageBuckets    = ageBuckets;
            _pulseDuration = pulseDuration;

            if (string.IsNullOrWhiteSpace(hostName))
            {
                _metricServer = new MetricServer(port, url);
            }
            else
            {
                _metricServer = new MetricServer(hostName, port, url);
            }

            _metricServer.Start();
        }
示例#12
0
        public MetricHostService(ILogger <MetricHostService> logger, IApplicationLifetime appLifetime, IOptions <MetricServiceOptions> options)
        {
            var conf = options ?? throw new ArgumentNullException(nameof(options));

            _logger      = logger ?? throw new ArgumentNullException(nameof(logger));
            _appLifetime = appLifetime ?? throw new ArgumentNullException(nameof(appLifetime));

            _options = new MetricServerOptions
            {
                Host     = conf.Value.Host,
                Port     = conf.Value.Port,
                UseHttps = conf.Value.Https
            };

            if (!string.IsNullOrEmpty(conf.Value.Path))
            {
                _options.MapPath = conf.Value.Path;
            }


            _metricServer = new MetricServer(Prometheus.Client.Metrics.DefaultCollectorRegistry, _options);
        }
示例#13
0
 public ApiClient(MonitoringConfig config, ILogger logger, IMetricServer metricServer)
 {
     _metricServer = metricServer;
     _config       = config;
     _logger       = logger;
 }
示例#14
0
 public PrometheusMetricsProvider(string hostname, int port, string url, CollectorRegistry registry = null, bool useHttps = false)
 {
     _server = new MetricServer(hostname, port, url, registry, useHttps);
     _server.Start();
 }
 public MonitoringMetricServer(ILogger logger)
 {
     metricServer = new Prometheus.MetricServer(port: 9200);
     _logger      = logger;
 }
示例#16
0
 public static void Start()
 {
     _Server = new MetricServer(50505);
     _Server.Start();
 }
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     _metricServer = new MetricServer("localhost", 9091);
     _metricServer.Start();
 }
示例#18
0
 public Task StartAsync(CancellationToken cancellationToken)
 {
     _logger.LogDebug("Staring metric server on {Host}:{Port}", _options.CurrentValue.Host, _options.CurrentValue.Port);
     _metricServer = new KestrelMetricServer(_options.CurrentValue.Host, _options.CurrentValue.Port).Start();
     return(Task.CompletedTask);
 }
 public static void Start()
 {
     _Server = new MetricServer(50505, new IOnDemandCollector[] { new DotNetStatsCollector(), new PerfCounterCollector() });
     _Server.Start();
 }
示例#20
0
 public MetricService(ILogger <MetricService> logger, IMetricServer server)
 {
     _server = server;
     _logger = logger;
 }