public void ValueConfirmation()
        {
            var provider = new PrometheusMetricsProvider("localhost", 9610);
            var counter  = provider.CreateCounter("metricName1", "metricHelp", true, new string[] { "label1", "label2" });
            var pulse    = provider.CreatePulse("metricName2", "metricHelp", true, new string[] { "label1", "label2" });
            var summary  = provider.CreateSummary("metricName3", "metricHelp", 10, true, new string[] { "label1", "label2" });
            var gauge    = provider.CreateGauge("metricName4", "metricHelp", true, new string[] { "label1", "label2" });


            Assert.IsTrue(string.Equals(counter.Name, "metricName1", StringComparison.Ordinal), "Counter name not expected");
            Assert.IsTrue(string.Equals(counter.Help, "metricHelp", StringComparison.Ordinal), "Counter help not expected");
            Assert.IsTrue(counter.Labels.Length == 2, "Counter labels not expected length");
            Assert.IsTrue(string.Equals(counter.Labels[0], "label1", StringComparison.Ordinal), "Counter label value 0 not expected");
            Assert.IsTrue(string.Equals(counter.Labels[1], "label2", StringComparison.Ordinal), "Counter label value 1 not expected");

            Assert.IsTrue(string.Equals(pulse.Name, "metricName2", StringComparison.Ordinal), "Pulse name not expected");
            Assert.IsTrue(string.Equals(pulse.Help, "metricHelp", StringComparison.Ordinal), "Pulse help not expected");
            Assert.IsTrue(pulse.Labels.Length == 2, "Pulse labels not expected length");
            Assert.IsTrue(string.Equals(pulse.Labels[0], "label1", StringComparison.Ordinal), "Pulse label value 0 not expected");
            Assert.IsTrue(string.Equals(pulse.Labels[1], "label2", StringComparison.Ordinal), "Pulse label value 1 not expected");

            Assert.IsTrue(string.Equals(summary.Name, "metricName3", StringComparison.Ordinal), "Summary name not expected");
            Assert.IsTrue(string.Equals(summary.Help, "metricHelp", StringComparison.Ordinal), "Summary help not expected");
            Assert.IsTrue(summary.Labels.Length == 2, "Summary labels not expected length");
            Assert.IsTrue(string.Equals(summary.Labels[0], "label1", StringComparison.Ordinal), "Summary label value 0 not expected");
            Assert.IsTrue(string.Equals(summary.Labels[1], "label2", StringComparison.Ordinal), "Summary label value 1 not expected");

            Assert.IsTrue(string.Equals(gauge.Name, "metricName4", StringComparison.Ordinal), "Gauge name not expected");
            Assert.IsTrue(string.Equals(gauge.Help, "metricHelp", StringComparison.Ordinal), "Gauge help not expected");
            Assert.IsTrue(gauge.Labels.Length == 2, "Gauge labels not expected length");
            Assert.IsTrue(string.Equals(gauge.Labels[0], "label1", StringComparison.Ordinal), "Gauge label value 0 not expected");
            Assert.IsTrue(string.Equals(gauge.Labels[1], "label2", StringComparison.Ordinal), "Gauge label value 1 not expected");
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().SetMinimumLevel(LogLevel.Information));

            var metricsProvider = new PrometheusMetricsProvider()
                                  .AddDotNetRuntimeStats();

            var serializationProvider = new Utf8JsonProvider();
            var hashingProvider       = new Argon2IDHasher();
            var hashKey = hashingProvider
                          .GetHashKeyAsync("passwordforencryption", "saltforencryption", 32)
                          .GetAwaiter()
                          .GetResult();

            var encryptionProvider  = new AesGcmEncryptionProvider(hashKey, hashingProvider.Type);
            var compressionProvider = new LZ4PickleProvider();

            var rabbitService = new RabbitService(
                "Config.json",
                serializationProvider,
                encryptionProvider,
                compressionProvider,
                loggerFactory);

            services.AddSingleton(
                s =>
            {
                return(new ConsumerDataflowService(
                           s.GetRequiredService <IConfiguration>(),
                           loggerFactory,
                           rabbitService,
                           serializationProvider,
                           compressionProvider,
                           encryptionProvider,
                           metricsProvider));
            });
        }