Skip to content

Commit

Permalink
Merge pull request #39 from smrutilal2/enrich
Browse files Browse the repository at this point in the history
log metric id and capacity
  • Loading branch information
smrutilal2 authored Apr 21, 2021
2 parents c251e99 + f9dfde5 commit c211d9e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public class BasicHistogramAggregator extends ConcurrentMonoidIntTable implement
private static final String[] AGGREGATION_FIELDS = {"count", "sum", "min", "max", "lastValue"};
private static final long[] IDENTITY = {0L, 0L, Long.MAX_VALUE, Long.MIN_VALUE, 0L};

private final String metricId;
private final DistributionBucket buckets;

private final String[] fields;
Expand Down Expand Up @@ -82,8 +81,7 @@ public BasicHistogramAggregator(final String metricId, final DistributionBucket
*/
public BasicHistogramAggregator(final String metricId, final DistributionBucket buckets,
final int maxCardinality, final int cardinality) {
super(AGGREGATION_FIELDS.length + buckets.getCount(), maxCardinality, cardinality, IDENTITY);
this.metricId = metricId;
super(metricId, AGGREGATION_FIELDS.length + buckets.getCount(), maxCardinality, cardinality, IDENTITY);
this.buckets = buckets;
this.fields = buildFields();
this.types = buildTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public abstract class ConcurrentMonoidIntTable {
throw new Error(e);
}
}

protected final String metricId;
///CLOVER:ON

/**
Expand All @@ -64,17 +66,18 @@ public abstract class ConcurrentMonoidIntTable {
private volatile int used = 0;

/**
* @param recordSize number of fields in a record
* @param metricId identifier of the metric
* @param recordSize number of fields in a record
* @param maxCapacity maximum capacity of table in records. Table doesn't grow beyond this value.
* @param initialCapacity requested capacity of table in records
* @param identity monoid's identity for the agg fields
*/
protected ConcurrentMonoidIntTable(final int recordSize, final int maxCapacity, int initialCapacity,
final long[] identity) {
this(identity.length, recordSize - identity.length, maxCapacity, initialCapacity, identity);
protected ConcurrentMonoidIntTable(final String metricId, final int recordSize, final int maxCapacity, int initialCapacity,
final long[] identity) {
this(metricId, identity.length, recordSize - identity.length, maxCapacity, initialCapacity, identity);
}

private ConcurrentMonoidIntTable(final int numAggFields, final int dataSize,
private ConcurrentMonoidIntTable(final String metricId, final int numAggFields, final int dataSize,
final int maxCapacity, int initialCapacity, final long[] identity) {

if (initialCapacity < 0) {
Expand All @@ -89,6 +92,7 @@ private ConcurrentMonoidIntTable(final int numAggFields, final int dataSize,
if (initialCapacity == 0) {
initialCapacity = DEFAULT_INITIAL_CAPACITY;
}
this.metricId = metricId;
this.numAggFields = numAggFields;
final int numInts = (RESERVED_FIELDS + numAggFields) * 2 + dataSize;
// Align to L1 cache line (64-byte)
Expand Down Expand Up @@ -410,7 +414,8 @@ protected long index(String[] tags, boolean isReading) {
private boolean growTable() {

if (capacity >= maxCapacity) {
LOGGER.error("Maximum table capacity reached");
LOGGER.error(
"Maximum cardinality reached for metric: {} cardinality: {}", metricId, capacity);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public abstract class ConcurrentMonoidLongTable implements Aggregator {

/**
* Create a simple linear probing hash table for a monoid operation.
* @param metricId identifier of the metric
* @param metricId identifier of the metric
* @param maxCapacity maximum capacity of table in records.
* @param initialCapacity requested capacity of table in records
* @param fields sorted array of field names used in reporting
Expand Down Expand Up @@ -337,7 +337,8 @@ long index(final String[] tags, final boolean isReading) {
private boolean growTable() {

if (capacity >= maxCapacity) {
LOGGER.error("Maximum linear probing table capacity reached (needed {}, max {}, metric-id \"{}\")", capacity, maxCapacity, metricId);
LOGGER.error(
"Maximum cardinality reached for metric: {} cardinality: {}", metricId, capacity);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/undertow-httphandler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ dependencies {
compile platform(group: 'org.apache.logging.log4j', name: 'log4j-bom', version: '2.13.3')
compile group: 'org.apache.logging.log4j', name: 'log4j-core'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl'
compile group: 'io.undertow', name: 'undertow-core', version: '2.2.3.Final'
compile group: 'io.undertow', name: 'undertow-core', version: '2.2.7.Final'
}

0 comments on commit c211d9e

Please sign in to comment.