Skip to content

Instantly share code, notes, and snippets.

@jkschneider
Created February 6, 2018 18:58
Show Gist options
  • Save jkschneider/8b54ba8e4351dc84ddd5759a7e3191cb to your computer and use it in GitHub Desktop.
Save jkschneider/8b54ba8e4351dc84ddd5759a7e3191cb to your computer and use it in GitHub Desktop.
Micrometer 400
package io.micrometer.core.samples;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Tags;
import io.micrometer.core.samples.utils.SampleConfig;
import java.util.Collections;
import java.util.List;
public class GaugeCollection {
public static void main(String[] args) throws InterruptedException {
MeterRegistry registry = SampleConfig.myMonitoringSystem();
List<Integer> someList = Collections.singletonList(1);
registry.gaugeCollectionSize(
"gauge.list",
Tags.of("sometag", "tag.value"),
someList);
for(int i = 0; i < 20; i++) {
Thread.sleep(1000);
}
System.out.println("made list null");
someList = null;
// at some point, the list gets garbage collected and the metric drops off of Datadog
for(;;) {
Thread.sleep(100);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment