Vertx Extra

Extension to metrics-java-client which adapts the client for use in the Vert.x framework.

License

License

Categories

Categories

Net Metrics Application Testing & Monitoring Monitoring Networking
GroupId

GroupId

com.arpnetworking.metrics.extras
ArtifactId

ArtifactId

vertx-extra
Last Version

Last Version

0.5.0
Release Date

Release Date

Type

Type

jar
Description

Description

Vertx Extra
Extension to metrics-java-client which adapts the client for use in the Vert.x framework.
Source Code Management

Source Code Management

https://github.com/arpnetworking/metrics-vertx-extra

Download vertx-extra

How to add to project

<!-- https://jarcasting.com/artifacts/com.arpnetworking.metrics.extras/vertx-extra/ -->
<dependency>
    <groupId>com.arpnetworking.metrics.extras</groupId>
    <artifactId>vertx-extra</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.arpnetworking.metrics.extras/vertx-extra/
implementation 'com.arpnetworking.metrics.extras:vertx-extra:0.5.0'
// https://jarcasting.com/artifacts/com.arpnetworking.metrics.extras/vertx-extra/
implementation ("com.arpnetworking.metrics.extras:vertx-extra:0.5.0")
'com.arpnetworking.metrics.extras:vertx-extra:jar:0.5.0'
<dependency org="com.arpnetworking.metrics.extras" name="vertx-extra" rev="0.5.0">
  <artifact name="vertx-extra" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.arpnetworking.metrics.extras', module='vertx-extra', version='0.5.0')
)
libraryDependencies += "com.arpnetworking.metrics.extras" % "vertx-extra" % "0.5.0"
[com.arpnetworking.metrics.extras/vertx-extra "0.5.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.12
com.arpnetworking.metrics : metrics-client jar 0.4.3

provided (8)

Group / Artifact Type Version
io.vertx : vertx-core jar 3.2.1
io.vertx : vertx-codegen jar 3.2.1
com.fasterxml.jackson.core : jackson-core jar 2.6.2
com.fasterxml.jackson.core : jackson-annotations jar 2.6.2
com.fasterxml.jackson.core : jackson-databind jar 2.6.2
com.google.code.findbugs : annotations jar 3.0.0
com.google.code.findbugs : jsr305 jar 3.0.0
com.arpnetworking.build : build-resources jar 1.0.5

test (4)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-all jar 1.10.19
io.vertx : vertx-unit jar 3.2.1
com.google.collections : google-collections jar 1.0

Project Modules

There are no modules declared in this project.

Vertx Extra

License: Apache 2 Travis Build Maven Artifact

Vertx 3.x compatible wrapper around the metrics Java client.

For Vertx 2.x you must use the 0.4.1 version of this library. There will be no further development in support of Vertx 2.x and future Vertx 3.x integration will most likely move to Vertx's Metrics SPI.

Instrumenting Your Vertx Application

Add Dependency

Determine the latest version of the vertx extra in Maven Central.

Maven

Add a dependency to your pom:

<dependency>
    <groupId>com.arpnetworking.metrics.extras</groupId>
    <artifactId>vertx-extra</artifactId>
    <version>VERSION</version>
</dependency>

The Maven Central repository is included by default.

Gradle

Add a dependency to your build.gradle:

compile group: 'com.arpnetworking.metrics.extras', name: 'vertx-extra', version: 'VERSION'

Add the Maven Central Repository into your build.gradle:

repositories {
    mavenCentral()
}

SBT

Add a dependency to your project/Build.scala:

val appDependencies = Seq(
    "com.arpnetworking.metrics.extras" % "vertx-extra" % "VERSION"
)

The Maven Central repository is included by default.

SharedMetrics

To create a shareable MetricsFactory instance in Vertx wrap a MetricsFactory instance in a SharedMetrics instance. For example:

final MetricsFactory shareableMetricsFactory = new SharedMetricsFactory(
    new MetricsFactory.Builder()
        .setSinks(Collections.singletonList(
            new TsdQueryLogSink.Builder()
                .setPath("/var/logs")
                .setName("myapp-query")
                .build()));
        .build());

To create a shareable Metrics instance in Vertx wrap the Metrics instance from either the MetricsFactory or SharedMetricsFactory in a SharedMetrics instance. For example:

final MetricsFactory metricsFactory = new MetricsFactory.Builder()
    .setSinks(Collections.singletonList(
        new TsdQueryLogSink.Builder()
            .setPath("/var/logs")
            .setName("myapp-query")
            .build()));
    .build();
final Metrics metrics = new SharedMetrics(metricsFactory.create());

If you do not want to use a shared MetricsFactory instance, but still have multiple verticles write to the same sink, you will need to implement the abstract class SinkVerticle. For example:

public final class MySinkVerticle extends SinkVerticle {

    /**
     * {@inheritDoc}
     */
    @Override
    public List<Sink> createSinks() {
        final Sink sink = Arrays.asList(
            new TsdQueryLogSink.Builder()
                .setPath("/var/logs")
                .setName("myapp-query")
                .build());
        return ImmutableList.of(sink);
    }
}

Once you have implemented the SinkVerticle, you will need to define a MetricsFactory instance that communicates with this verticle. This MetricsFactory instance will write to an EventBusSink configured to send events to the Verticle defined above. Example:

final Sink sink = new EventBusSink.Builder()
        .setEventBus(vertx.eventBus())
        .setSinkAddress("metrics.sink.default")
        .build();
final MetricsFactory metricsFactory = new TsdMetricsFactory.Builder()
    .setSinks(Collections.singletonList(sink))
    .build();

Please refer to the Java metrics client documentation metrics-client-java/README.md for more information on using Metrics and MetricsFactory.

Building

Prerequisites:

Building: metrics-vertx-extra> ./mvnw verify

To use the local version you must first install it locally:

metrics-vertx-extra> ./mvnw install

You can determine the version of the local build from the pom file. Using the local version is intended only for testing or development.

You may also need to add the local repository to your build in order to pick-up the local version:

  • Maven - Included by default.
  • Gradle - Add mavenLocal() to build.gradle in the repositories block.
  • SBT - Add resolvers += Resolver.mavenLocal into project/plugins.sbt.

License

Published under Apache Software License 2.0, see LICENSE

© Groupon Inc., 2014

Versions

Version
0.5.0
0.4.1