Maven

Lightbend Telemetry uses a Java Agent to add specially crafted instrumentation to the Lightbend Platform for efficient telemetry.

You will need to add this agent agent to your Maven build and deployment to enable the telemetry.

Bintray credentials

Follow these instructions to set up your Bintray credentials for Maven.

Getting the Agent

To automatically pull down the agent as part of your build, you add the following plugin to download as part of the package task.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-dependency-plugin</artifactId>
  <version>2.10</version>
  <executions>
    <execution>
      <id>copy</id>
      <phase>package</phase>
      <goals>
        <goal>copy</goal>
      </goals>
      <configuration>
        <artifactItems>
          <artifactItem>
            <groupId>com.lightbend.cinnamon</groupId>
            <artifactId>cinnamon-agent</artifactId>
            <version>2.6.2</version>
            <overWrite>true</overWrite>
            <destFileName>cinnamon-agent.jar</destFileName>
          </artifactItem>
        </artifactItems>
      </configuration>
    </execution>
  </executions>
</plugin>

Adding the Agent

Next, the agent needs to be added as a java command line option. Here is a sample of how to add the agent to the exec plugin for the exec:exec task.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.4.0</version>
  <configuration>
    <executable>java</executable>
    <arguments>
      <argument>-classpath</argument>
      <classpath/>
      <argument>-javaagent:${project.build.directory}/dependency/cinnamon-agent.jar</argument>
      <argument>... your other arguments here ...</argument>
    </arguments>
  </configuration>
</plugin>

Complete Sample

Here is a complete sample of a Maven build file configured to use the Cinnamon Agent, the Coda Hale Metrics plugin, Akka Instrumentation, and Akka HTTP Instrumentation.

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>test.app</groupId>
  <artifactId>app</artifactId>
  <version>1.0-SNAPSHOT</version>

  <repositories>
    <repository>
      <id>lightbend-commercial</id>
      <name>Lightbend Commercial</name>
      <url>https://lightbend.bintray.com/commercial-releases</url>
    </repository>
  </repositories>

  <dependencies>
    <!-- Use Coda Hale Metrics -->
    <dependency>
      <groupId>com.lightbend.cinnamon</groupId>
      <artifactId>cinnamon-chmetrics_2.11</artifactId>
      <version>2.6.2</version>
    </dependency>
    <!-- Use Akka instrumentation -->
    <dependency>
      <groupId>com.lightbend.cinnamon</groupId>
      <artifactId>cinnamon-akka_2.11</artifactId>
      <version>2.6.2</version>
    </dependency>
    <dependency>
      <groupId>com.lightbend.cinnamon</groupId>
      <artifactId>cinnamon-akka-http_2.11</artifactId>
      <version>2.6.2</version>
    </dependency>
    <dependency>
      <groupId>com.typesafe.akka</groupId>
      <artifactId>akka-actor_2.11</artifactId>
      <version>2.5.6</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.10</version>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.lightbend.cinnamon</groupId>
                  <artifactId>cinnamon-agent</artifactId>
                  <version>2.6.2</version>
                  <overWrite>true</overWrite>
                  <destFileName>cinnamon-agent.jar</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <configuration>
          <executable>java</executable>
          <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>-javaagent:${project.build.directory}/dependency/cinnamon-agent.jar</argument>
            <argument>... your other arguments here ...</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>