io.ebeaninternal.server.profile.DTimedProfileLocation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ebean Show documentation
Show all versions of ebean Show documentation
composite of common runtime dependencies for all platforms
package io.ebeaninternal.server.profile;
import io.ebean.meta.MetricVisitor;
import io.ebean.metric.TimedMetric;
import io.ebean.metric.TimedMetricStats;
/**
* Default profile location that uses stack trace.
*/
class DTimedProfileLocation extends DProfileLocation implements TimedProfileLocation {
private final String label;
private final TimedMetric timedMetric;
private final boolean overrideMetricName;
private String fullName;
DTimedProfileLocation(int lineNumber, String label, TimedMetric timedMetric) {
super(lineNumber);
this.label = label;
this.timedMetric = timedMetric;
this.overrideMetricName = "".equals(label);
}
@Override
protected void initWith(String locationLabel) {
if (overrideMetricName) {
fullName = "txn.named." + locationLabel;
}
}
@Override
public String getLabel() {
return label;
}
@Override
public TimedMetric getMetric() {
return timedMetric;
}
@Override
public void add(long executionTime) {
timedMetric.add(executionTime);
}
@Override
public void visit(MetricVisitor visitor) {
TimedMetricStats collect = timedMetric.collect(visitor.isReset());
if (collect != null) {
if (overrideMetricName) {
collect.setName(fullName);
}
collect.setLocation(location());
visitor.visitTimed(collect);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy