Skip to content

A Java metrics interface with fast buffered metrics and third party reporters

License

Notifications You must be signed in to change notification settings

uber-java/tally

Folders and files

NameName
Last commit message
Last commit date
Dec 21, 2023
Nov 7, 2017
Nov 7, 2017
Dec 6, 2024
Jan 19, 2021
Dec 21, 2023
Aug 13, 2021
Aug 13, 2021
Aug 13, 2021
Jun 27, 2024
Sep 17, 2019
Dec 6, 2024
Aug 24, 2017
Dec 6, 2024
Jun 27, 2024
Aug 24, 2017
Aug 24, 2017
Aug 24, 2017
Jan 21, 2021

Repository files navigation

✔️ tally Build Status Coverage Status Maven Central

Fast, buffered, hierarchical stats collection in Java. Go here for the Go client.

Abstract

Tally provides a common interface for emitting metrics, while letting you not worry about the velocity of metrics emission.

By default, it buffers counters, gauges and histograms at a specified interval but does not buffer timer values. This is primarily so timer values can have all their values sampled if desired and if not they can be sampled as summaries or histograms independently by a reporter.

Structure

  • Scope: Keeps track of metrics, and their common metadata.
  • Metrics: Counters, Gauges, Timers and Histograms.
  • Reporter: Implemented by you. Accepts aggregated values from the scope. Forwards the aggregated values to your metrics ingestion pipeline.

Create a Scope

// Implement as you will
StatsReporter reporter = new MyStatsReporter();

Map<String, String> tags = new HashMap<>(2, 1);
tags.put("dc", "east-1");
tags.put("type","leader");

Scope scope = new RootScopeBuilder()
    .reporter(reporter)
    .tags(tags)
    .reportEvery(Duration.ofSeconds(1));

Get/Create a metric; use it

Counter reqCounter = scope.counter("requests");
reqCounter.inc(1);

Gauge queueGauge = scope.gauge("queue_length");
queueGauge.update(42);

Report your metrics

Use one of the inbuilt reporters or implement your own using the StatsReporter interface.

Usage examples

Run the example by running:

$ ./gradlew run

This runs the PrintStatsReporterExample class in the tally-example project.

Artifacts publishing

All artifacts are published under the group com.uber.m3.

  1. tally-m3: The tally M3 reporter.
  2. tally-statsd: The tally StatsD reporter.
  3. tally-core: The tally core functionality that includes interfaces and utilities to report metrics to M3.
  4. tally-example: Usage examples with different reporters.
  5. tally-prometheus: The tally Prometheus reporter (experimental; see prometheus/README.md).

Versioning

We follow semantic versioning outlined here. In summary, given a version of MAJOR.MINOR.PATCH (e.g. 1.2.0):

  • MAJOR version changes are breaking changes to the public API
  • MINOR version changes are backwards-compatible changes that include new functionality
  • PATCH version changes are backwards-compatible bug fixes

Released under the MIT License.