Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- }
- }
Add Comment
Please, Sign In to add comment