diff --git a/src/main/java/com/teragrep/aer_02/EventDataConsumer.java b/src/main/java/com/teragrep/aer_02/EventDataConsumer.java index 6109070..774da36 100644 --- a/src/main/java/com/teragrep/aer_02/EventDataConsumer.java +++ b/src/main/java/com/teragrep/aer_02/EventDataConsumer.java @@ -79,20 +79,19 @@ final class EventDataConsumer implements AutoCloseable { private final JmxReporter jmxReporter; private final Slf4jReporter slf4jReporter; - EventDataConsumer(Sourceable configSource, int prometheusPort) { - this(configSource, new MetricRegistry(), prometheusPort); + EventDataConsumer(Sourceable configSource) { + this(configSource, new MetricRegistry()); } - EventDataConsumer(Sourceable configSource, MetricRegistry metricRegistry, int prometheusPort) { + EventDataConsumer(Sourceable configSource, MetricRegistry metricRegistry) { this( configSource, new DefaultOutput("defaultOutput", new RelpConfig(configSource), metricRegistry), - metricRegistry, - prometheusPort + metricRegistry ); } - EventDataConsumer(Sourceable configSource, Output output, MetricRegistry metricRegistry, int prometheusPort) { + EventDataConsumer(Sourceable configSource, Output output, MetricRegistry metricRegistry) { this.metricRegistry = metricRegistry; this.output = output; this.realHostName = getRealHostName(); diff --git a/src/main/java/com/teragrep/aer_02/SyslogBridge.java b/src/main/java/com/teragrep/aer_02/SyslogBridge.java index 25fa260..3f2bfb2 100644 --- a/src/main/java/com/teragrep/aer_02/SyslogBridge.java +++ b/src/main/java/com/teragrep/aer_02/SyslogBridge.java @@ -47,7 +47,6 @@ import com.microsoft.azure.functions.annotation.*; import com.microsoft.azure.functions.*; -import com.teragrep.aer_02.config.MetricsConfig; import com.teragrep.aer_02.config.source.EnvironmentSource; import com.teragrep.aer_02.config.source.Sourceable; import io.prometheus.client.CollectorRegistry; @@ -111,9 +110,7 @@ public void eventHubTriggerToSyslog( if (consumer == null) { final Sourceable configSource = new EnvironmentSource(); - final int prometheusPort = new MetricsConfig(configSource).prometheusPort; - - consumer = new EventDataConsumer(configSource, prometheusPort); + consumer = new EventDataConsumer(configSource); } for (int index = 0; index < events.length; index++) { diff --git a/src/main/java/com/teragrep/aer_02/config/AzureConfig.java b/src/main/java/com/teragrep/aer_02/config/AzureConfig.java deleted file mode 100644 index c6d7941..0000000 --- a/src/main/java/com/teragrep/aer_02/config/AzureConfig.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Teragrep Eventhub Reader as an Azure Function - * Copyright (C) 2024 Suomen Kanuuna Oy - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * - * - * Additional permission under GNU Affero General Public License version 3 - * section 7 - * - * If you modify this Program, or any covered work, by linking or combining it - * with other code, such other code is not for that reason alone subject to any - * of the requirements of the GNU Affero GPL version 3 as long as this Program - * is the same Program as licensed from Suomen Kanuuna Oy without any additional - * modifications. - * - * Supplemented terms under GNU Affero General Public License version 3 - * section 7 - * - * Origin of the software must be attributed to Suomen Kanuuna Oy. Any modified - * versions must be marked as "Modified version of" The Program. - * - * Names of the licensors and authors may not be used for publicity purposes. - * - * No rights are granted for use of trade names, trademarks, or service marks - * which are in The Program if any. - * - * Licensee must indemnify licensors and authors for any liability that these - * contractual assumptions impose on licensors and authors. - * - * To the extent this program is licensed as part of the Commercial versions of - * Teragrep, the applicable Commercial License may apply to this file if you as - * a licensee so wish it. - */ -package com.teragrep.aer_02.config; - -import com.teragrep.aer_02.config.source.Sourceable; - -public final class AzureConfig { - - public final Sourceable configSource; - public final String namespaceName; - public final String eventHubName; - public final String blobStorageEndpoint; - public final String blobStorageContainerName; - - public AzureConfig(Sourceable configSource) { - this.configSource = configSource; - this.namespaceName = getNamespaceName(); - this.eventHubName = getEventHubName(); - this.blobStorageEndpoint = getBlobStorageEndpoint(); - this.blobStorageContainerName = getBlobStorageContainerName(); - } - - private String getNamespaceName() { - return configSource.source("azure.namespace", ".servicebus.windows.net"); - } - - private String getEventHubName() { - return configSource.source("azure.eventhub", ""); - } - - private String getBlobStorageEndpoint() { - return configSource - .source("azure.blobstorage.endpoint", "https://.blob.core.windows.net"); - } - - private String getBlobStorageContainerName() { - return configSource.source("azure.blobstorage.container", ""); - } -} diff --git a/src/test/java/com/teragrep/aer_02/ConfigTest.java b/src/test/java/com/teragrep/aer_02/ConfigTest.java index 3aeaa81..7311a2c 100644 --- a/src/test/java/com/teragrep/aer_02/ConfigTest.java +++ b/src/test/java/com/teragrep/aer_02/ConfigTest.java @@ -45,28 +45,15 @@ */ package com.teragrep.aer_02; -import com.teragrep.aer_02.config.AzureConfig; import com.teragrep.aer_02.config.RelpConfig; import com.teragrep.aer_02.config.SyslogConfig; import com.teragrep.aer_02.config.source.EnvironmentSource; import com.teragrep.aer_02.config.source.PropertySource; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class ConfigTest { - @Disabled(value = "fix maven") - @Test - public void testConfigFromEnv() { - AzureConfig azureConfig = new AzureConfig(new EnvironmentSource()); // AZURE_NAMESPACE comes from maven - Assertions - .assertEquals( - "azure_namespace_from_env", azureConfig.namespaceName, - "Expected to get config from environment variable" - ); - } - @Test public void testConfigFromProperty() { String expected = "testing.hostname.example.com"; diff --git a/src/test/java/com/teragrep/aer_02/EventContextConsumerTest.java b/src/test/java/com/teragrep/aer_02/EventContextConsumerTest.java index 74f615f..0bc2e2e 100644 --- a/src/test/java/com/teragrep/aer_02/EventContextConsumerTest.java +++ b/src/test/java/com/teragrep/aer_02/EventContextConsumerTest.java @@ -47,7 +47,6 @@ import com.codahale.metrics.Gauge; import com.codahale.metrics.MetricRegistry; -import com.teragrep.aer_02.config.MetricsConfig; import com.teragrep.aer_02.config.source.PropertySource; import com.teragrep.aer_02.config.source.Sourceable; import com.teragrep.aer_02.fakes.*; @@ -65,7 +64,6 @@ public class EventContextConsumerTest { private final Sourceable configSource = new PropertySource(); - private final int prometheusPort = new MetricsConfig(configSource).prometheusPort; @Test public void testLatencyMetric() { @@ -78,12 +76,7 @@ public void testLatencyMetric() { Map systemProps = new HashMap<>(); systemProps.put("SequenceNumber", "1"); MetricRegistry metricRegistry = new MetricRegistry(); - EventDataConsumer eventDataConsumer = new EventDataConsumer( - configSource, - new OutputFake(), - metricRegistry, - prometheusPort - ); + EventDataConsumer eventDataConsumer = new EventDataConsumer(configSource, new OutputFake(), metricRegistry); final double records = 10; for (int i = 0; i < records; i++) {