Docs · Java

Java logging and alerts, in 5 minutes

Your Java app's errors with their stack trace, each request's thread across your services and a phone alert when an order never finishes. One file, no dependencies, in the background.

  1. 1

    Install

    // copy Estiaje.java into your project (Java 17+)

    It's a file with no dependencies: copy it from here. Change "mi-api" to your service's name.

  2. 2

    Your key

    Create your account and put the key in ESTIAJE_TOKEN. Or ask your AI “connect this repo to Estiaje” (the connector). Without the key nothing leaves over the network: you can instrument today.

  3. 3

    Your errors and each request's thread

    ● Tested in CI
    // at startup, in your main
    Estiaje.capturarErrores();   // uncaught errors
    
    // each request's thread, in a filter
    @Component
    public class HiloEstiaje extends OncePerRequestFilter {
        @Override
        protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
                throws ServletException, IOException {
            Estiaje.empezarHilo(req.getHeader("traceparent"));
            try {
                chain.doFilter(req, res);
            } finally {
                Estiaje.terminarHilo();
            }
        }
    }
    // a worker or a program that exits right away
    public static void main(String[] args) {
        Estiaje.capturarErrores();   // uncaught errors
        Estiaje.empezarHilo(null);   // a new thread for this job
        procesar();
        Estiaje.evento("corte.terminado", Map.of()).join();   // wait for the send before exiting
    }
  4. 4

    The process that must finish

    Estiaje.evento("order.paid", Map.of("order_id", order.getId(), "amount", order.getTotal()));
    // … when it ships …
    Estiaje.evento("order.shipped", Map.of("order_id", order.getId()));
  5. 5

    The alert

    In the dashboard, under Processes: “every order.paid expects its order.shipped, by order_id, within 30 minutes”. If it never comes, you get a phone, email or Slack alert, with the money at risk.

And if you want more
  • Errors you catch: Estiaje.error(e, Map.of("order_id", order.getId())), with their stack.
  • When calling another service with RestClient, pass the thread: an interceptor that sets traceparent from Estiaje.traceparent() (the recipe).
  • Java 17+; it uses Java's own HttpClient, nothing else.

Everything else is in the full docs.

Create account, 14 days of Pro No card required.