Skip to content

Commit

Permalink
Fix prometheus port
Browse files Browse the repository at this point in the history
  • Loading branch information
ruanwenjun committed Jan 12, 2022
1 parent 0b3757b commit a3333fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Properties;

Expand All @@ -38,7 +40,6 @@ public class OpenTelemetryConfiguration {

private int eventMeshPrometheusPort = 19090;


static {
loadProperties();
initializeConfig();
Expand All @@ -55,28 +56,26 @@ private void initializeConfig() {
}
}

private Properties loadProperties() {
String configFile = getConfigFilePath();
log.info("loading config: {}", configFile);
try {
Properties properties = new Properties();
properties.load(new BufferedReader(new FileReader(configFile)));
return properties;
} catch (IOException e) {
throw new IllegalArgumentException(
String.format("Cannot load opentelemetry configuration file from :%s", configFile));
}
}


private static String getConfigFilePath() {
// get from classpath
private void loadProperties() {
URL resource = OpenTelemetryConfiguration.class.getClassLoader().getResource(CONFIG_FILE);
if (resource != null && new File(resource.getPath()).exists()) {
return resource.getPath();
if (resource != null) {
try (InputStream inputStream = resource.openStream()) {
if (inputStream.available() > 0) {
properties.load(new BufferedReader(new InputStreamReader(inputStream)));
}
} catch (IOException e) {
throw new RuntimeException("Load opentelemetry.properties file from classpath error");
}
}
// get from config home
return System.getProperty("confPath", System.getenv("confPath")) + File.separator + CONFIG_FILE;
try {
String configPath = System.getProperty("confPath", System.getenv("confPath")) + File.separator + CONFIG_FILE;
if (new File(configPath).exists()) {
properties.load(new BufferedReader(new FileReader(configPath)));
}
} catch (IOException e) {
throw new IllegalArgumentException("Cannot load opentelemetry.properties file from conf");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ public void init() throws Exception {
metricsPlugins -> metricsPlugins.forEach(
pluginType -> metricsRegistries.add(MetricsPluginFactory.getMetricsRegistry(pluginType))));

httpRetryer = new HttpRetryer(this);
httpRetryer.init();

metrics = new HTTPMetricsServer(this, metricsRegistries);
metrics.init();

Expand All @@ -211,9 +214,6 @@ public void init() throws Exception {
producerManager = new ProducerManager(this);
producerManager.init();

httpRetryer = new HttpRetryer(this);
httpRetryer.init();

registerHTTPRequestProcessor();

super.openTelemetryTraceFactory = new OpenTelemetryTraceFactory(eventMeshHttpConfiguration);
Expand Down

0 comments on commit a3333fb

Please sign in to comment.