Crunch Projects

A simplified Prometheus API for Java

  • API geared aimed at application developers rather than Prometheus experts.
  • Name-based metrics; no need to create instances or handle registration.
  • Cleaner timer / summary syntax, via resource/try
  • Aim is to simplify Prometheus adoption, reduce excessive code intrusion.
  • Lexical compatibility with Codahale/Dropwizard Metrics API, simplifying complete migration.
  • Regular Prometheus API can always be used directly for more advanced cases (unclear what those might be).

Example

class Example {
    private final PrometheusMetrics metrics;

    public void onUserLogin(Object event) {
        metrics.gauge("Sessions.open").inc();
        metrics.counter("Sessions.total").inc();
    }

    public String handleLogin() {
        try (Context timer = metrics.summary("Sessions.handleLogin").time()) {
            return "Login handled!";
        }
    }
}

A simplified Prometheus API for Kotlin

  • API geared aimed at application developers rather than Prometheus experts.
  • Name-based metrics; no need to create instances or handle registration.
  • Cleaner timer / summary syntax, via resource/try
  • Aim is to simplify Prometheus adoption, reduce excessive code intrusion.
  • Lexical compatibility with Codahale/Dropwizard Metrics API, simplifying complete migration.
  • Regular Prometheus API can always be used directly for more advanced cases (unclear what those might be).

Example

class Example(private val metrics: PrometheusMetrics) {

    fun onUserLogin(event: Any) {
        metrics.gauge("Sessions.open").inc()
    }

    fun onUserLogout(event: Any) {
        metrics.gauge("Sessions.open").dec()
    }

    fun onError(event: Any) {
        metrics.error("generic", "Generic errors")
    }

    fun handleLogin(): String {
        metrics.timer("Sessions.handleLogin").time().use { return "Login handled!" }
    }
}