-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor CloudWatch reporting by adding dedicated reporter class (#92)
- Loading branch information
Séamus Ó Ceanainn
authored
Apr 12, 2022
1 parent
e07f0cf
commit ff763ef
Showing
2 changed files
with
26 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package reporter | ||
|
||
import com.amazonaws.services.cloudwatch.{AmazonCloudWatchAsync, AmazonCloudWatchAsyncClientBuilder} | ||
import com.blacklocus.metrics.CloudWatchReporterBuilder | ||
import com.codahale.metrics.MetricRegistry | ||
import config.CloudWatch | ||
import filter.CloudWatchMetricFilter | ||
|
||
import java.util.concurrent.TimeUnit | ||
|
||
class RemoraCloudWatchReporter(metricRegistry: MetricRegistry, cloudWatchConfig: CloudWatch) { | ||
val amazonCloudWatchAsync: AmazonCloudWatchAsync = AmazonCloudWatchAsyncClientBuilder.defaultClient | ||
|
||
val logMetricFilter = new CloudWatchMetricFilter(cloudWatchConfig.metricFilter) | ||
|
||
def startReporter(): Unit = new CloudWatchReporterBuilder() | ||
.withNamespace(cloudWatchConfig.name) | ||
.withRegistry(metricRegistry) | ||
.withClient(amazonCloudWatchAsync) | ||
.withFilter(logMetricFilter) | ||
.build() | ||
.start(cloudWatchConfig.intervalMinutes, TimeUnit.MINUTES) | ||
} |