Skip to content

Commit

Permalink
Fix GH#24: Remove AzureConfig, also removes prometheusPort as it was …
Browse files Browse the repository at this point in the history
…unused. (#29)

* Remove unused AzureConfig and prometheusPort variable. Related AzureConfig tests also removed.

* apply spotless
  • Loading branch information
eemhu authored Nov 8, 2024
1 parent c2b2290 commit 2a62090
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 113 deletions.
11 changes: 5 additions & 6 deletions src/main/java/com/teragrep/aer_02/EventDataConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/teragrep/aer_02/SyslogBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++) {
Expand Down
82 changes: 0 additions & 82 deletions src/main/java/com/teragrep/aer_02/config/AzureConfig.java

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/java/com/teragrep/aer_02/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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() {
Expand All @@ -78,12 +76,7 @@ public void testLatencyMetric() {
Map<String, Object> 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++) {
Expand Down

0 comments on commit 2a62090

Please sign in to comment.