#2290 - Add MetaTimedMetric locationHash() which is a crc32 checksum of package + type + method (excludes line number)

This commit is contained in:
rbygrave
2021-08-06 14:48:42 +12:00
parent 4787303160
commit fea7de42d5
19 changed files with 124 additions and 43 deletions
@@ -45,6 +45,14 @@ public interface ProfileLocation {
*/
String label();
/**
* Return a hash of the location that intentionally excludes the line number.
* <p>
* The hash is expected to be stable regardless of line number in the source file
* so that is identifies the class and method location over a long time.
*/
long hash();
/**
* Return the full location.
*/
@@ -6,6 +6,14 @@ package io.ebean.meta;
*/
public interface MetaTimedMetric extends MetaMetric {
/**
* Return the metric location hash if defined.
* <p>
* This hash excludes line number with the intention of being stable over time
* as code changes move the source line (but the method is the same).
*/
long locationHash();
/**
* Return the metric location if defined.
*/
@@ -14,6 +14,7 @@ public class MetricData {
private Long mean;
private Long max;
private Long total;
private long locHash;
public MetricData(String name) {
this.name = name;
@@ -38,6 +39,14 @@ public class MetricData {
this.sqlHash = sqlHash;
}
public void setLocHash(long locHash) {
this.locHash = locHash;
}
public long getLocHash() {
return locHash;
}
public String getLoc() {
return loc;
}
@@ -12,6 +12,11 @@ public interface TimedMetricStats extends MetaTimedMetric {
*/
void setLocation(String location);
/**
* Additionally set the location hash.
*/
void setLocationHash(long locationHash);
/**
* Override the name based on profile location.
*/