jmxtrans / jmxtrans-agent

Java Agent based JMX metrics exporter.
MIT License
178 stars 110 forks source link

Support for using a properties file for placeholder expansion #64

Closed kerlandsson closed 8 years ago

kerlandsson commented 8 years ago

This PR adds the support for using a properties file for placeholder expansion, in addition to the existing support for system properties and environment variables. Values in the properties file take precendence over system properties and environment variables.

The support is enabled by adding the system property -Djmxtrans.agent.properties.file=<fileOrUrl>.

The format of the property value is the same as for the configuration file (supports file, classpath: and url notations).

The properties file is not watched for changes, but values will be fetched fresh if the configuration is reloaded at runtime.

Errors on loading the properties will cause the properties source to be ignored and a warning will e logged, but configuration will load anyways.

cyrille-leclerc commented 8 years ago

Thanks @kerlandsson!

I feel that we should introduce the equivalent of the Spring Resource API to unify the handling of "file://", "http://", "https://" resources.

Unifying handling of timeouts (see here)... Unifying the way we load configuration file and properties file.

Does it make sense to you?

kerlandsson commented 8 years ago

@cyrille-leclerc I agree, that makes a lot of sense. I was actually going to suggest something similar as an improvement since the way I load properties in this PR essentialy duplicates the already existing code.