1 /***********************************************************************
2  * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Apache License, Version 2.0
5  * which accompanies this distribution and is available at
6  * http://www.opensource.org/licenses/apache2.0.php.
7  ***********************************************************************/
8 
9 package org.locationtech.geomesa.metrics.micrometer
10 package cloudwatch
11 import com.typesafe.config.Config
12 import io.micrometer.cloudwatch2.CloudWatchMeterRegistry
13 import io.micrometer.core.instrument.{Clock, MeterRegistry}
14 import pureconfig.generic.semiauto.deriveReader
15 import pureconfig.{ConfigReader, ConfigSource}
16 import software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient
17 
18 object CloudwatchFactory extends RegistryFactory {
19 
20   override def apply(conf: Config): MeterRegistry = {
21     implicit val reader: ConfigReader[CloudwatchConfig] = deriveReader[CloudwatchConfig]
22     val config = ConfigSource.fromConfig(conf).loadOrThrow[CloudwatchConfig]
23     new CloudWatchMeterRegistry(k => config.properties.getOrElse(k, null), Clock.SYSTEM, CloudWatchAsyncClient.create())
24   }
25 
26   private case class CloudwatchConfig(
27       namespace: String = "geomesa",
28       properties: Map[String, String] = Map.empty
29     )
30 }
Line Stmt Id Pos Tree Symbol Tests Code
21 97510 1019 - 1049 ApplyToImplicitArgs pureconfig.generic.semiauto.deriveReader pureconfig.generic.semiauto.deriveReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]({ val inst$macro$28: pureconfig.generic.DerivedConfigReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig] = { final class anon$lazy$macro$27 extends AnyRef with Serializable { def <init>(): anon$lazy$macro$27 = { anon$lazy$macro$27.super.<init>(); () }; <stable> <accessor> lazy val inst$macro$23: pureconfig.ConfigReader[String] = pureconfig.this.ConfigReader.stringConfigReader.asInstanceOf[pureconfig.ConfigReader[String]]; <stable> <accessor> lazy val inst$macro$25: pureconfig.ConfigReader[Map[String,String]] = pureconfig.this.ConfigReader.mapReader[String](pureconfig.this.ConfigReader.stringConfigReader).asInstanceOf[pureconfig.ConfigReader[Map[String,String]]]; <stable> <accessor> lazy val inst$macro$26: pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.HNil,shapeless.HNil] = generic.this.MapShapedReader.labelledHNilReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig](generic.this.ProductHint.default[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]).asInstanceOf[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.HNil,shapeless.HNil]]; <stable> <accessor> lazy val inst$macro$24: pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[Map[String,String]] :: shapeless.HNil] = generic.this.MapShapedReader.labelledHConsReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, Symbol @@ String("properties"), Map[String,String], shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out, shapeless.HNil](Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("properties")]](scala.Symbol.apply("properties").asInstanceOf[Symbol @@ String("properties")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("properties")]]), shapeless.Lazy.apply[pureconfig.ConfigReader[Map[String,String]]](anon$lazy$macro$27.this.inst$macro$25), shapeless.Lazy.apply[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.HNil,shapeless.HNil]](anon$lazy$macro$27.this.inst$macro$26), generic.this.ProductHint.default[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]).asInstanceOf[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[Map[String,String]] :: shapeless.HNil]]; <stable> <accessor> lazy val inst$macro$22: pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[String] :: Option[Map[String,String]] :: shapeless.HNil] = generic.this.MapShapedReader.labelledHConsReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, Symbol @@ String("namespace"), String, shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out, Option[Map[String,String]] :: shapeless.HNil](Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("namespace")]](scala.Symbol.apply("namespace").asInstanceOf[Symbol @@ String("namespace")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("namespace")]]), shapeless.Lazy.apply[pureconfig.ConfigReader[String]](anon$lazy$macro$27.this.inst$macro$23), shapeless.Lazy.apply[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[Map[String,String]] :: shapeless.HNil]](anon$lazy$macro$27.this.inst$macro$24), generic.this.ProductHint.default[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]).asInstanceOf[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[String] :: Option[Map[String,String]] :: shapeless.HNil]]; <stable> <accessor> lazy val inst$macro$1: pureconfig.generic.DerivedConfigReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig] = generic.this.DerivedConfigReader.productReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out, Option[String] :: Option[Map[String,String]] :: shapeless.HNil](shapeless.this.LabelledGeneric.materializeProduct[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, (Symbol @@ String("namespace")) :: (Symbol @@ String("properties")) :: shapeless.HNil, String :: Map[String,String] :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](DefaultSymbolicLabelling.instance[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, (Symbol @@ String("namespace")) :: (Symbol @@ String("properties")) :: shapeless.HNil](::.apply[Symbol @@ String("namespace"), (Symbol @@ String("properties")) :: shapeless.HNil.type](scala.Symbol.apply("namespace").asInstanceOf[Symbol @@ String("namespace")], ::.apply[Symbol @@ String("properties"), shapeless.HNil.type](scala.Symbol.apply("properties").asInstanceOf[Symbol @@ String("properties")], HNil))), Generic.instance[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, String :: Map[String,String] :: shapeless.HNil](((x0$7: org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig) => x0$7 match { case (namespace: String, properties: Map[String,String])org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig((namespace$macro$16 @ _), (properties$macro$17 @ _)) => ::.apply[String, Map[String,String] :: shapeless.HNil.type](namespace$macro$16, ::.apply[Map[String,String], shapeless.HNil.type](properties$macro$17, HNil)).asInstanceOf[String :: Map[String,String] :: shapeless.HNil] }), ((x0$8: String :: Map[String,String] :: shapeless.HNil) => x0$8 match { case (head: String, tail: Map[String,String] :: shapeless.HNil)String :: Map[String,String] :: shapeless.HNil((namespace$macro$14 @ _), (head: Map[String,String], tail: shapeless.HNil)Map[String,String] :: shapeless.HNil((properties$macro$15 @ _), HNil)) => CloudwatchFactory.this.CloudwatchConfig.apply(namespace$macro$14, properties$macro$15) })), hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("namespace"), String, (Symbol @@ String("properties")) :: shapeless.HNil, Map[String,String] :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("properties"), Map[String,String], shapeless.HNil, shapeless.HNil, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hnilZipWithKeys, Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("properties")]](scala.Symbol.apply("properties").asInstanceOf[Symbol @@ String("properties")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("properties")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("namespace")]](scala.Symbol.apply("namespace").asInstanceOf[Symbol @@ String("namespace")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("namespace")]])), scala.Predef.$conforms[shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]), Default.this.AsOptions.asOption[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, String :: Map[String,String] :: shapeless.HNil, Some[String] :: Some[Map[String,String]] :: shapeless.HNil, Option[String] :: Option[Map[String,String]] :: shapeless.HNil](shapeless.Default.mkDefault[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, Some[String] :: Some[Map[String,String]] :: shapeless.HNil](::.apply[Some[String], Some[Map[String,String]] :: shapeless.HNil.type](scala.Some.apply[String](CloudwatchFactory.this.CloudwatchConfig.apply$default$1), ::.apply[Some[Map[String,String]], shapeless.HNil.type](scala.Some.apply[Map[String,String]](CloudwatchFactory.this.CloudwatchConfig.apply$default$2), HNil))), Generic.instance[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig, String :: Map[String,String] :: shapeless.HNil](((x0$9: org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig) => x0$9 match { case (namespace: String, properties: Map[String,String])org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig((namespace$macro$20 @ _), (properties$macro$21 @ _)) => ::.apply[String, Map[String,String] :: shapeless.HNil.type](namespace$macro$20, ::.apply[Map[String,String], shapeless.HNil.type](properties$macro$21, HNil)).asInstanceOf[String :: Map[String,String] :: shapeless.HNil] }), ((x0$10: String :: Map[String,String] :: shapeless.HNil) => x0$10 match { case (head: String, tail: Map[String,String] :: shapeless.HNil)String :: Map[String,String] :: shapeless.HNil((namespace$macro$18 @ _), (head: Map[String,String], tail: shapeless.HNil)Map[String,String] :: shapeless.HNil((properties$macro$19 @ _), HNil)) => CloudwatchFactory.this.CloudwatchConfig.apply(namespace$macro$18, properties$macro$19) })), AsOptions.this.Helper.hconsSomeHelper[String, Some[Map[String,String]] :: shapeless.HNil, Map[String,String] :: shapeless.HNil, Option[Map[String,String]] :: shapeless.HNil](AsOptions.this.Helper.hconsSomeHelper[Map[String,String], shapeless.HNil, shapeless.HNil, shapeless.HNil](AsOptions.this.Helper.hnilHelper))), shapeless.Lazy.apply[pureconfig.generic.MapShapedReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig,shapeless.labelled.FieldType[Symbol @@ String("namespace"),String] :: shapeless.labelled.FieldType[Symbol @@ String("properties"),Map[String,String]] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out,Option[String] :: Option[Map[String,String]] :: shapeless.HNil]](anon$lazy$macro$27.this.inst$macro$22)).asInstanceOf[pureconfig.generic.DerivedConfigReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]] }; new anon$lazy$macro$27().inst$macro$1 }; shapeless.Lazy.apply[pureconfig.generic.DerivedConfigReader[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]](inst$macro$28) })
22 97511 1067 - 1126 ApplyToImplicitArgs pureconfig.ConfigSource.loadOrThrow pureconfig.ConfigSource.fromConfig(conf).loadOrThrow[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]((ClassTag.apply[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig](classOf[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory$$CloudwatchConfig]): scala.reflect.ClassTag[org.locationtech.geomesa.metrics.micrometer.cloudwatch.CloudwatchFactory.CloudwatchConfig]), reader)
23 97513 1202 - 1214 Select io.micrometer.core.instrument.Clock.SYSTEM io.micrometer.core.instrument.Clock.SYSTEM
23 97512 1164 - 1200 Apply scala.collection.MapLike.getOrElse config.properties.getOrElse[String](k, null)
23 97515 1131 - 1247 Apply io.micrometer.cloudwatch2.CloudWatchMeterRegistry.<init> new io.micrometer.cloudwatch2.CloudWatchMeterRegistry(((k: String) => config.properties.getOrElse[String](k, null)), io.micrometer.core.instrument.Clock.SYSTEM, software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient.create())
23 97514 1216 - 1246 Apply software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient.create software.amazon.awssdk.services.cloudwatch.CloudWatchAsyncClient.create()