scala-cloudwatch-metrics


License

License

Categories

Categories

Scala Languages Metrics Application Testing & Monitoring Monitoring
GroupId

GroupId

com.gu
ArtifactId

ArtifactId

scala-cloudwatch-metrics_2.11
Last Version

Last Version

1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504
Release Date

Release Date

Type

Type

jar
Description

Description

scala-cloudwatch-metrics
scala-cloudwatch-metrics
Project URL

Project URL

https://github.com/guardian/scala-cloudwatch-metrics
Project Organization

Project Organization

com.gu
Source Code Management

Source Code Management

https://github.com/guardian/scala-cloudwatch-metrics

Download scala-cloudwatch-metrics_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/scala-cloudwatch-metrics_2.11/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>scala-cloudwatch-metrics_2.11</artifactId>
    <version>1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/scala-cloudwatch-metrics_2.11/
implementation 'com.gu:scala-cloudwatch-metrics_2.11:1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504'
// https://jarcasting.com/artifacts/com.gu/scala-cloudwatch-metrics_2.11/
implementation ("com.gu:scala-cloudwatch-metrics_2.11:1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504")
'com.gu:scala-cloudwatch-metrics_2.11:jar:1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504'
<dependency org="com.gu" name="scala-cloudwatch-metrics_2.11" rev="1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504">
  <artifact name="scala-cloudwatch-metrics_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='scala-cloudwatch-metrics_2.11', version='1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504')
)
libraryDependencies += "com.gu" % "scala-cloudwatch-metrics_2.11" % "1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504"
[com.gu/scala-cloudwatch-metrics_2.11 "1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.4
com.amazonaws : aws-java-sdk-cloudwatch jar 1.10.69
org.scalaz.stream : scalaz-stream_2.11 jar 0.6
org.slf4j : slf4j-api jar 1.7.5
org.slf4j : slf4j-simple jar 1.7.5

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.11 jar 2.2.1

Project Modules

There are no modules declared in this project.

scala-cloudwatch-metrics

A wrapper for sending Cloudwatch metrics in Scala. The intention is to make it easier to send CloudWatch metrics and allow batching of metrics for sending to cloudwatch to reduce cost and latency

This work is extracted from the Grid Project.

Installation

libraryDependencies ++= Seq(
  "com.gu" % "scala-cloudwatch-metrics_2.11" % "1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504"
)

scala-cloudwatch-metrics is published for Scala 2.11

Usage

// Set up your metrics
import com.amazonaws.auth.AWSCredentials
import com.gu.cloudwatch.metrics.CloudWatchMetrics


class AppMetrics(stage: String, creds: AWSCredentials)  
  extends CloudWatchMetrics(stage, creds) {

  val barCounter = new CountMetric("Bar")
  val fooTimer = new TimeMetric("Foo") 

} 

// Put data to metrics
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import com.gu.cloudwatch.metrics.FutureSyntax._


class AppMetricsExamples(appMetrics: AppMetrics) {
  def countExample {
    Future {
      // Do something
    }.incrementOnFailure(appMetrics.barCounter) { case _ => true }
  }

  def timerExample {
    val latency = 1 // The latency in milliseconds of some operation
    val dimensions = List(new Dimension().withName("name").withValue("value"))

    appMetrics.fooTimer.runRecordOne(latency, dimensions)
  } 
}

License

scala-cloudwatch-metrics is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
1.0-2f4ebc7e4a85551e011566e40393d5b1b2fbf504