Skip to content
Garvit Joshi edited this page Apr 2, 2026 · 5 revisions

Tremor Java Client

tremor-client-java is a lightweight Java 8 client for Tremor ingestion. It keeps the public API small, uses OkHttp for transport, Gson for JSON, and focuses on one job: sending exception events to Tremor cleanly.

TremorClient is thread-safe and can be reused as a singleton in your application.

What It Covers

  • Synchronous ingestion to POST /tremor/api/v1/ingest
  • Direct Throwable capture for the easy path
  • Explicit event builders when you want full payload control
  • Caller-managed or library-managed OkHttpClient
  • Local validation before the HTTP request is sent
  • Fingerprint return value from Tremor on success

Quick Examples

Singleton Client

import in.riido.tremor.client.TremorClient;

public final class ErrorReporter {

    private final String tremorKey = "...";
    private final TremorClient tremorClient =
        TremorClient.builder(tremorKey).baseUrl("https://tremor.example.com/tremor").build();

    public TremorClient tremor() {
        return tremorClient;
    }
}

Most applications should create one TremorClient and reuse it.

Real-World Catch Block Example

import in.riido.tremor.client.TremorCaptureOptions;
import in.riido.tremor.client.TremorClient;

public final class OrderService {

    private final String tremorKey = "...";
    private final TremorClient tremorClient =
        TremorClient.builder(tremorKey).baseUrl("https://tremor.example.com/tremor").build();

    public void processOrder(String orderId) {
        try {
            chargePayment(orderId);
            reserveInventory(orderId);
        } catch (Exception exception) {
            tremorClient.send(
                exception,
                TremorCaptureOptions.builder()
                    .tag("orders")
                    .tag("payment")
                    .tag("critical")
                    .putUserCustomData("orderId", orderId)
                    .version("1.2.3")
                    .build());
            throw exception;
        }
    }
}

This is the most common pattern: catch, send to Tremor with tags and custom data, then keep your normal exception flow.

Suppress Strategy for Best-Effort Work

import in.riido.tremor.client.TremorCaptureOptions;
import in.riido.tremor.client.TremorClient;

public final class CacheRefreshJob {

    private final String tremorKey = "...";
    private final TremorClient tremorClient =
        TremorClient.builder(tremorKey).baseUrl("https://tremor.example.com/tremor").build();

    public void refresh() {
        tremorClient.reportAndSuppress(
            TremorCaptureOptions.builder().tag("background-job").build(),
            () -> {
                refreshCacheFromRemote();
            });
    }
}

Use reportAndSuppress(...) only when you intentionally want to report the failure and continue running.

Send an Explicit Event

import in.riido.tremor.client.TremorClient;
import in.riido.tremor.client.model.TremorError;
import in.riido.tremor.client.model.TremorEvent;
import in.riido.tremor.client.model.TremorStackFrame;

String tremorKey = "...";

TremorError error = TremorError.builder()
    .className("java.lang.IllegalStateException")
    .message("checkout failed")
    .frame(new TremorStackFrame("CheckoutService", "submit", "CheckoutService.java", 42))
    .build();

TremorEvent event = TremorEvent.builder()
    .machineName("api-1")
    .version("1.2.3")
    .tag("payments")
    .error(error)
    .build();

try (TremorClient client = TremorClient.builder(tremorKey).build()) {
    String fingerprint = client.send(event);
}

Requirements

  • Java 8 or higher
  • A Tremor server exposing /tremor/api/v1/ingest

Getting Started

  1. Installation
  2. Configuration
  3. Throwable Capture
  4. Explicit Event Model
  5. Error Handling
  6. Troubleshooting

Documentation

Core Pages

Sending Events

License

Apache License 2.0

Clone this wiki locally