Java Code Examples for io.micrometer.core.instrument.Metrics#globalRegistry()

The following examples show how to use io.micrometer.core.instrument.Metrics#globalRegistry() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeterMapCleanerTask.java    From summerframework with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SimpleMeterRegistry meterRegistry = new SimpleMeterRegistry();
    Metrics.globalRegistry.add(meterRegistry);
    MeterMapCleanerTask task = new MeterMapCleanerTask(Metrics.globalRegistry);
    task.start("0/2 * * * * ?");

    ScheduledExecutorService s = Executors.newSingleThreadScheduledExecutor();
    s.scheduleAtFixedRate(() -> {
        meterRegistry.counter(UUID.randomUUID().toString()).increment();
        System.out.println(meterRegistry.getMeters().size());
    }, 0, 100, TimeUnit.MILLISECONDS);

    try {
        TimeUnit.SECONDS.sleep(5);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    s.shutdown();
    task.stop();
}
 
Example 2
Source File: MeterRegistryConfigurer.java    From foremast with Apache License 2.0 5 votes vote down vote up
void configure(MeterRegistry registry) {
    // Customizers must be applied before binders, as they may add custom
    // tags or alter timer or summary configuration.
    customize(registry);
    addFilters(registry);
    addBinders(registry);
    if (this.addToGlobalRegistry && registry != Metrics.globalRegistry) {
        Metrics.addRegistry(registry);
    }
}
 
Example 3
Source File: MeterRegistryConfigurer.java    From foremast with Apache License 2.0 5 votes vote down vote up
void configure(MeterRegistry registry) {
    // Customizers must be applied before binders, as they may add custom
    // tags or alter timer or summary configuration.
    customize(registry);
    addFilters(registry);
    addBinders(registry);
    if (this.addToGlobalRegistry && registry != Metrics.globalRegistry) {
        Metrics.addRegistry(registry);
    }
}
 
Example 4
Source File: MonoMetrics.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
/**
 * For testing purposes.
 *
 * @param meterRegistry the registry to use
 */
MonoMetrics(Mono<? extends T> mono, @Nullable MeterRegistry meterRegistry) {
	super(mono);

	this.name = resolveName(mono);
	this.tags = resolveTags(mono, FluxMetrics.DEFAULT_TAGS_MONO, this.name);

	if (meterRegistry == null) {
		this.meterRegistry = Metrics.globalRegistry;
	}
	else {
		this.meterRegistry = meterRegistry;
	}
}
 
Example 5
Source File: FluxMetricsFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
/**
 * For testing purposes.
 *
 * @param candidate the registry to use, as a plain {@link Object} to avoid leaking dependency
 */
FluxMetricsFuseable(Flux<? extends T> flux, @Nullable MeterRegistry candidate) {
	super(flux);

	this.name = resolveName(flux);
	this.tags = resolveTags(flux, FluxMetrics.DEFAULT_TAGS_FLUX, this.name);

	if (candidate == null) {
		this.registryCandidate = Metrics.globalRegistry;
	}
	else {
		this.registryCandidate = candidate;
	}
}
 
Example 6
Source File: FluxMetrics.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
/**
 * For testing purposes.
 *
 * @param registry the registry to use, or null for global one
 */
FluxMetrics(Flux<? extends T> flux, @Nullable MeterRegistry registry) {
	super(flux);

	this.name = resolveName(flux);
	this.tags = resolveTags(flux, DEFAULT_TAGS_FLUX, this.name);

	if (registry == null) {
		this.registryCandidate = Metrics.globalRegistry;
	}
	else {
		this.registryCandidate = registry;
	}
}
 
Example 7
Source File: MonoMetricsFuseable.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
/**
 * For testing purposes.
 *
 * @param registryCandidate the registry to use, as a plain {@link Object} to avoid leaking dependency
 */
MonoMetricsFuseable(Mono<? extends T> mono, @Nullable MeterRegistry registryCandidate) {
	super(mono);

	this.name = resolveName(mono);
	this.tags = resolveTags(mono, FluxMetrics.DEFAULT_TAGS_MONO, this.name);

	if (registryCandidate == null) {
		this.registryCandidate = Metrics.globalRegistry;
	}
	else {
		this.registryCandidate = registryCandidate;
	}
}
 
Example 8
Source File: MicrometerUtil.java    From summerframework with Apache License 2.0 4 votes vote down vote up
public static final MeterRegistry registry() {
    return Metrics.globalRegistry;
}
 
Example 9
Source File: Monitors.java    From summerframework with Apache License 2.0 4 votes vote down vote up
private static final MeterRegistry registry() {
    return Metrics.globalRegistry;
}
 
Example 10
Source File: StatsProviderImpl.java    From pravega with Apache License 2.0 4 votes vote down vote up
StatsProviderImpl(MetricsConfig conf) {
    this(conf, Metrics.globalRegistry);
}
 
Example 11
Source File: TimedAspect.java    From micrometer with Apache License 2.0 2 votes vote down vote up
/**
 * Create a {@code TimedAspect} instance with {@link Metrics#globalRegistry}.
 *
 * @since 1.2.0
 */
public TimedAspect() {
    this(Metrics.globalRegistry);
}