public PrometheusCountersTest() { var PUSHGATEWAY_ENABLED = Environment.GetEnvironmentVariable("PUSHGATEWAY_ENABLED") ?? "true"; var PUSHGATEWAY_SERVICE_HOST = Environment.GetEnvironmentVariable("PUSHGATEWAY_SERVICE_HOST") ?? "localhost"; var PUSHGATEWAY_SERVICE_PORT = Environment.GetEnvironmentVariable("PUSHGATEWAY_SERVICE_PORT") ?? "9091"; _enabled = BooleanConverter.ToBoolean(PUSHGATEWAY_ENABLED); if (_enabled) { _counters = new PrometheusCounters(); _counters.Configure(ConfigParams.FromTuples( "interval", "5000", "connection.host", PUSHGATEWAY_SERVICE_HOST, "connection.port", PUSHGATEWAY_SERVICE_PORT )); var contextInfo = new ContextInfo(); contextInfo.Name = "Test"; contextInfo.Description = "This is a test container"; var references = References.FromTuples( new Descriptor("pip-services", "context-info", "default", "default", "1.0"), contextInfo, new Descriptor("pip-services", "counters", "prometheus", "default", "1.0"), _counters ); _counters.SetReferences(references); _fixture = new CountersFixture(_counters); _counters.OpenAsync(null).Wait(); } }
public PrometheusMetricsServiceTest() { var config = ConfigParams.FromTuples( "connection.protocol", "http", "connection.host", "localhost", "connection.port", "3000" ); _service = new PrometheusMetricsService(); _service.Configure(config); var contextInfo = new ContextInfo(); contextInfo.Name = "Test"; contextInfo.Description = "This is a test container"; _counters = new PrometheusCounters(); var references = References.FromTuples( new Descriptor("pip-services", "context-info", "default", "default", "1.0"), contextInfo, new Descriptor("pip-services", "counters", "prometheus", "default", "1.0"), _counters, new Descriptor("pip-services", "metrics-service", "prometheus", "default", "1.0"), _service ); _service.SetReferences(references); _counters.OpenAsync(null).Wait(); _service.OpenAsync(null).Wait(); Task.Delay(500).Wait(); }