Search in sources :

Example 1 with ExportConfigurationProperties

use of io.micronaut.configuration.metrics.micrometer.ExportConfigurationProperties in project micronaut-micrometer by micronaut-projects.

the class CloudWatchMeterRegistryFactory method cloudWatchMeterRegistry.

/**
 * Create a CloudWatchMeterRegistry bean if global metrics are enables
 * and the cloudwatch is enabled.  Will be true by default when this
 * configuration is included in project.
 *
 * @param exportConfigurationProperties The export configuration
 * @param cloudWatchAsyncClient  The cloud watch async client
 * @return A CloudWatchMeterRegistry
 */
@Singleton
CloudWatchMeterRegistry cloudWatchMeterRegistry(ExportConfigurationProperties exportConfigurationProperties, CloudWatchAsyncClient cloudWatchAsyncClient) {
    Properties exportConfig = exportConfigurationProperties.getExport();
    String cloudwatchNamespace = "cloudwatch.namespace";
    if (!exportConfig.containsKey(cloudwatchNamespace)) {
        exportConfig.setProperty(cloudwatchNamespace, CLOUDWATCH_DEFAULT_NAMESPACE);
    }
    return new CloudWatchMeterRegistry(exportConfig::getProperty, Clock.SYSTEM, cloudWatchAsyncClient);
}
Also used : CloudWatchMeterRegistry(io.micrometer.cloudwatch2.CloudWatchMeterRegistry) Properties(java.util.Properties) ExportConfigurationProperties(io.micronaut.configuration.metrics.micrometer.ExportConfigurationProperties) Singleton(jakarta.inject.Singleton)

Aggregations

CloudWatchMeterRegistry (io.micrometer.cloudwatch2.CloudWatchMeterRegistry)1 ExportConfigurationProperties (io.micronaut.configuration.metrics.micrometer.ExportConfigurationProperties)1 Singleton (jakarta.inject.Singleton)1 Properties (java.util.Properties)1