com.github.marschall.micrometer.jfr.AbstractJfrMeter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of micrometer-jfr Show documentation
Show all versions of micrometer-jfr Show documentation
A Micrometer meter registry that generates JFR events
The newest version!
package com.github.marschall.micrometer.jfr;
import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.util.MeterEquivalence;
import jdk.jfr.EventFactory;
abstract class AbstractJfrMeter, E extends AbstractJfrMeterEvent> implements Meter {
private final Id id;
protected final F meterEventFactory;
protected final EventFactory jfrEventFactory;
AbstractJfrMeter(Id id, F meterEventFactory) {
this.id = id;
this.meterEventFactory = meterEventFactory;
this.jfrEventFactory = this.meterEventFactory.newEventFactory();
}
E newEmptyEvent() {
return this.meterEventFactory.newEmptyEvent(this.jfrEventFactory);
}
@Override
public Id getId() {
return this.id;
}
@Override
public void close() {
this.meterEventFactory.closeEventFactory(this.jfrEventFactory);
}
@Override
public String toString() {
return this.getClass().getSimpleName() + '(' + this.getId() + ')';
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Meter)) {
return false;
}
return MeterEquivalence.equals(this, o);
}
@Override
public int hashCode() {
return MeterEquivalence.hashCode(this);
}
}