Skip to content

Commit

Permalink
Add support for remote jmx rules files.
Browse files Browse the repository at this point in the history
  • Loading branch information
luigidemasi committed Nov 22, 2024
1 parent 8eef5ca commit a2f8e56
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
import io.opentelemetry.sdk.autoconfigure.AutoConfiguredOpenTelemetrySdk;
import io.opentelemetry.sdk.autoconfigure.spi.ConfigProperties;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.net.URL;
import java.time.Duration;
import java.util.List;

Expand Down Expand Up @@ -81,10 +80,15 @@ private static void buildFromDefaultRules(
private static void buildFromUserRules(
MetricConfiguration conf, ConfigProperties configProperties) {
List<String> configFiles = configProperties.getList("otel.jmx.config");
String configFileUrlString;
for (String configFile : configFiles) {
JmxMetricInsight.getLogger().log(FINE, "JMX config file name: {0}", configFile);
configFileUrlString = configFile;
if (configFile != null && !configFile.contains("://")) {
configFileUrlString = "file://" + configFile;
}
JmxMetricInsight.getLogger().log(FINE, "JMX config file name: {0}", configFileUrlString);
RuleParser parserInstance = RuleParser.get();
try (InputStream inputStream = Files.newInputStream(Paths.get(configFile))) {
try (InputStream inputStream = new URL(configFileUrlString).openStream()) {
parserInstance.addMetricDefsTo(conf, inputStream, configFile);
} catch (Exception e) {
// yaml parsing errors are caught and logged inside of addMetricDefsTo
Expand Down

0 comments on commit a2f8e56

Please sign in to comment.