Exemplo n.º 1
0
        public void PrometheusStopServerWithoutStarting()
        {
            var collector = new NicGuidSensor();
            var registry  = PrometheusCollection.SetupDefault(collector);
            var mserver   = new MetricServer("localhost", 21883, registry: registry);
            var server    = new PrometheusServer(mserver, collector);

            // Asserting that the following doesn't throw when the server
            // is disposed before starting
            server.Dispose();
        }
Exemplo n.º 2
0
        public async void PrometheusNicGuid()
        {
            var collector = new NicGuidSensor();
            var registry  = PrometheusCollection.SetupDefault(collector);
            var mserver   = new MetricServer("localhost", 21882, registry: registry);

            using var server = new PrometheusServer(mserver, collector);
            using var client = new HttpClient();
            server.Start();
            var resp = await client.GetAsync("http://localhost:21882/metrics");

            Assert.True(resp.IsSuccessStatusCode);
            var content = await resp.Content.ReadAsStringAsync();

            Assert.Contains("Bluetooth Network Connection 2", content);
        }
Exemplo n.º 3
0
        public async void PrometheusTestServer()
        {
            var collector = new TestSensorCreator();
            var registry  = PrometheusCollection.SetupDefault(collector);
            var mserver   = new MetricServer("localhost", 21881, registry: registry);

            using var server = new PrometheusServer(mserver, collector);
            using var client = new HttpClient();
            server.Start();
            var resp = await client.GetAsync("http://localhost:21881/metrics");

            Assert.True(resp.IsSuccessStatusCode);
            var content = await resp.Content.ReadAsStringAsync();

            Assert.Contains("# HELP ohm_cpu_celsius Metric reported by open hardware sensor", content);
        }
Exemplo n.º 4
0
        public async void PrometheusTestServer()
        {
            var collector            = new TestSensorCreator();
            var prometheusCollection = new PrometheusCollection(collector, "my-pc");
            var mserver = new MetricServer("localhost", 21881);
            var server  = new PrometheusServer(mserver, collector, prometheusCollection);

            try
            {
                server.Start();
                var client = new HttpClient();
                var resp   = await client.GetAsync("http://localhost:21881/metrics");

                Assert.True(resp.IsSuccessStatusCode);
                var content = await resp.Content.ReadAsStringAsync();

                Assert.Contains("# HELP intelcpu_0_temperature_0 Metric reported by open hardware sensor", content);
            }
            finally
            {
                server.Stop();
            }
        }
Exemplo n.º 5
0
        public async void PrometheusNicGuid()
        {
            var collector            = new NicGuidSensor();
            var prometheusCollection = new PrometheusCollection(collector, "my-pc", Metrics.DefaultRegistry);
            var mserver = new MetricServer("localhost", 21881);
            var server  = new PrometheusServer(mserver, collector);

            try
            {
                server.Start();
                var client = new HttpClient();
                var resp   = await client.GetAsync("http://localhost:21881/metrics");

                Assert.True(resp.IsSuccessStatusCode);
                var content = await resp.Content.ReadAsStringAsync();

                Assert.Contains("Bluetooth Network Connection 2", content);
            }
            finally
            {
                server.Stop();
            }
        }