Search in sources :

Example 26 with Singleton

use of jakarta.inject.Singleton 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

Singleton (jakarta.inject.Singleton)26 Bean (io.micronaut.context.annotation.Bean)7 Factory (io.micronaut.context.annotation.Factory)6 Properties (java.util.Properties)6 GraphQLSchema (graphql.schema.GraphQLSchema)5 BufferedReader (java.io.BufferedReader)5 InputStreamReader (java.io.InputStreamReader)5 GraphQL (graphql.GraphQL)4 RuntimeWiring (graphql.schema.idl.RuntimeWiring)4 SchemaGenerator (graphql.schema.idl.SchemaGenerator)4 SchemaParser (graphql.schema.idl.SchemaParser)4 TypeDefinitionRegistry (graphql.schema.idl.TypeDefinitionRegistry)4 ResourceResolver (io.micronaut.core.io.ResourceResolver)4 Named (jakarta.inject.Named)4 Test (org.junit.Test)3 ConfiguredStreamBuilder (io.micronaut.configuration.kafka.streams.ConfiguredStreamBuilder)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 Arrays (java.util.Arrays)2 Locale (java.util.Locale)2 ConsumerConfig (org.apache.kafka.clients.consumer.ConsumerConfig)2