Observatory Docs Home | Edit these docs


Observatory’s metrics feature allows you to collect data on your program. You can register a metric that you care about, like how many queries are being performed per second, or how many bodies are in a scene.

You register your metrics programmatically using the Metrics class in the dart:developer library. You can observe the metrics, as they collect, using the metrics link on the VM page.

Counter and Gauge are two metric classes provided for you. The following screenshot shows an example of a user-defined Counter metric named “Bodies”:

example showing Metrics using a Counter

The “Bodies” counter is registered on the numBodies variable and is set up with just a few lines of code:

import 'dart:async';
import 'dart:developer';

Counter numBodies = new Counter("Bodies", "number of Bodies created");

main() {
  numBodies.value = 17;
  new Timer.periodic(new Duration(seconds: 1), (t) {

Privacy Policy