Guest User

Untitled

a guest
Feb 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. package io.micrometer.core.samples;
  2.  
  3. import io.micrometer.core.instrument.MeterRegistry;
  4. import io.micrometer.core.instrument.Tags;
  5. import io.micrometer.core.samples.utils.SampleConfig;
  6.  
  7. import java.util.Collections;
  8. import java.util.List;
  9.  
  10. public class GaugeCollection {
  11. public static void main(String[] args) throws InterruptedException {
  12. MeterRegistry registry = SampleConfig.myMonitoringSystem();
  13.  
  14. List<Integer> someList = Collections.singletonList(1);
  15.  
  16. registry.gaugeCollectionSize(
  17. "gauge.list",
  18. Tags.of("sometag", "tag.value"),
  19. someList);
  20.  
  21. for(int i = 0; i < 20; i++) {
  22. Thread.sleep(1000);
  23. }
  24.  
  25. System.out.println("made list null");
  26. someList = null;
  27.  
  28. // at some point, the list gets garbage collected and the metric drops off of Datadog
  29. for(;;) {
  30. Thread.sleep(100);
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment