package io.prometheus.client.hotspot;

/**
 * Registers the default Hotspot collectors.
 * <p>
 * This is intended to avoid users having to add in new
 * registrations every time a new exporter is added.
 * <p>
 * Example usage:
 * <pre>
 * {@code
 *   DefaultExports.initialize();
 * }
 * </pre>
 */
public class DefaultExports {
  private static boolean initialized = false;
  /**
   * Register the default Hotspot collectors.
   */
  public static synchronized void initialize() {
    if (!initialized) {
      new StandardExports().register();
      new MemoryPoolsExports().register();
      new MemoryAllocationExports().register();
      new BufferPoolsExports().register();
      new GarbageCollectorExports().register();
      new ThreadExports().register();
      new ClassLoadingExports().register();
      new VersionInfoExports().register();
      initialized = true;
    }
  }

}

@@ -32,16 +32,64 @@
 tspot;%0A%0A
+import io.prometheus.client.CollectorRegistry;%0A%0A
 /**%0A * R
@@ -418,16 +418,17 @@
  false;%0A
+%0A
   /**%0A  
@@ -473,91 +473,450 @@
 tors
-.%0A   */%0A  public static synchronized void initialize() %7B%0A    if (!initialized) %7B%0A  
+ with the default%0A   * registry. It is safe to call this method multiple times, as%0A   * this will only register the collectors once.%0A   */%0A  public static synchronized void initialize() %7B%0A    if (!initialized) %7B%0A      register(CollectorRegistry.defaultRegistry);%0A      initialized = true;%0A    %7D%0A  %7D%0A%0A  /**%0A   * Register the default Hotspot collectors with the given registry.%0A   */%0A  public static void register(CollectorRegistry registry) %7B%0A
     
@@ -938,37 +938,43 @@
 orts().register(
+registry
 );%0A
-  
     new MemoryPo
@@ -991,33 +991,39 @@
 ().register(
+registry
 );%0A    
- 
- 
 new MemoryAl
@@ -1041,37 +1041,43 @@
 orts().register(
+registry
 );%0A
-  
     new BufferPo
@@ -1090,37 +1090,43 @@
 orts().register(
+registry
 );%0A
-  
     new GarbageC
@@ -1148,33 +1148,39 @@
 ().register(
+registry
 );%0A    
-  
 new ThreadEx
@@ -1188,37 +1188,43 @@
 orts().register(
+registry
 );%0A
-  
     new ClassLoa
@@ -1242,29 +1242,35 @@
 ().register(
+registry
 );%0A
-  
     new Vers
@@ -1299,42 +1299,18 @@
 ter(
-);%0A      initialized = true;%0A    %7D
+registry);
 %0A  %7D

Allow DefaultExports to be registered with an arbitrary CollectorRegistry (#450)