Class PrometheusPropertiesLoader
It would be great to implement a subset of Spring Boot's Externalized Configuration, like support for YAML, Properties, and env vars, or support for Spring's naming conventions for properties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PrometheusPropertiesload()static PrometheusProperties(package private) static PrometheusProperties.MetricPropertiesMaploadMetricsConfigs(PropertySource propertySource) private static PropertySourceloadProperties(Map<Object, Object> externalProperties) private static PropertiesLoad properties from environment variables.private static Propertiesprivate static void(package private) static StringNormalize a property key for consistent lookup.private static voidvalidateAllPropertiesProcessed(PropertySource propertySource)
-
Constructor Details
-
PrometheusPropertiesLoader
public PrometheusPropertiesLoader()
-
-
Method Details
-
load
- Throws:
PrometheusPropertiesException
-
load
public static PrometheusProperties load(Map<Object, Object> externalProperties) throws PrometheusPropertiesException- Throws:
PrometheusPropertiesException
-
loadMetricsConfigs
-
validateAllPropertiesProcessed
-
loadProperties
-
normalizeAndPutAll
-
loadPropertiesFromClasspath
-
loadPropertiesFromFile
- Throws:
PrometheusPropertiesException
-
loadPropertiesFromEnvironment
Load properties from environment variables.Environment variables are converted to lowercase but keep underscores as-is. For example, the environment variable IO_PROMETHEUS_METRICS_EXEMPLARS_ENABLED becomes io_prometheus_metrics_exemplars_enabled.
The transformation to dot notation happens at access time in PropertySource.
Only environment variables starting with IO_PROMETHEUS are considered.
- Returns:
- properties loaded from environment variables (with lowercase keys and underscores)
-
normalizePropertyKey
Normalize a property key for consistent lookup.Converts camelCase property keys to snake_case. This allows both snake_case (preferred) and camelCase (deprecated) property names to be used.
For example: exemplarsEnabled → exemplars_enabled exemplars_enabled → exemplars_enabled (unchanged)
- Parameters:
key- the property key- Returns:
- the normalized property key
-