001package io.prometheus.client.hotspot;
002
003import io.prometheus.client.CollectorRegistry;
004
005/**
006 * Registers the default Hotspot collectors.
007 * <p>
008 * This is intended to avoid users having to add in new
009 * registrations every time a new exporter is added.
010 * <p>
011 * Example usage:
012 * <pre>
013 * {@code
014 *   DefaultExports.initialize();
015 * }
016 * </pre>
017 */
018public class DefaultExports {
019  private static boolean initialized = false;
020
021  /**
022   * Register the default Hotspot collectors with the default
023   * registry. It is safe to call this method multiple times, as
024   * this will only register the collectors once.
025   */
026  public static synchronized void initialize() {
027    if (!initialized) {
028      register(CollectorRegistry.defaultRegistry);
029      initialized = true;
030    }
031  }
032
033  /**
034   * Register the default Hotspot collectors with the given registry.
035   */
036  public static void register(CollectorRegistry registry) {
037    new StandardExports().register(registry);
038    new MemoryPoolsExports().register(registry);
039    new MemoryAllocationExports().register(registry);
040    new BufferPoolsExports().register(registry);
041    new GarbageCollectorExports().register(registry);
042    new ThreadExports().register(registry);
043    new ClassLoadingExports().register(registry);
044    new VersionInfoExports().register(registry);
045  }
046
047}