Integrating the Simple Client

The Codetrails Error Analytics Simple Client is a small Java library you can use to send errors to the Codetrails Error Analytics service.

How to Send an Error Report

Once installed, you can send a report to your service by first creating an Incident object from a Throwable and then sending this to the service’s submission URL.

package com.example.application;

public class Application {

  private static final String CEA_SUBMISSION_URL =
      "https://aer.ctrlflow.com/example/community/new";

  public void reportCaughtException() {
    try {
      ...
    } catch (Exception e) {
      Incident incident = IncidentBuilder.from(e)
          .withLogMessage("Caught an exception") // Optional
          .withProductId("com.example.application") // Required
          .withProductVersion("1.0.0") // Required
          .withUserName("John Doe") // Optional
          .withUserEmail("john.doe@example.com") // Optional
          .build();
      SimpleAerClient.send(incident, CEA_SUBMISSION_URL);
    }
  }
}

The above will send an error report containing the log message, stack trace, and additional information about the user and product to your Codetrails Error Analytics service.

Important
The send method sends the report synchronously, i.e., it blocks until the report has been send completely. You may want to send reports asynchronously instead (e.g., using an Executor).
Tip
Consider registering a Thread.UncaughtExceptionHandler and call your Check out the Simple Client example on GitHub for details.

How to Install the Client

If you are using Apache Maven, just add the following to the <dependencies> section of your POM:

pom.xml
<dependency>
  <groupId>com.ctrlflow.aer.client.bundles</groupId>
  <artifactId>com.ctrlflow.aer.client.simple</artifactId>
  <version>2.0.1</version>
</dependency>

This will automatically install the Codetrails Error Analytics Simple Client as well as any required dependencies from the Central Repository.

How to Configure the Client

The Codetrails Error Analytics Simple Client requires no upfront configuration. To send error reports, all you need to do is pass the submission URL of your Codetrails Error Analytics service to the send method. You can find this URL on the Help > System Information page:

client rest api urls.png
Figure 1. Help > System Information > REST API URLs panel.

results matching ""

    No results matching ""