Skip to content

Commit

Permalink
@W-13740046: Add logs to debug the aggregated metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Rithika committed Jul 20, 2023
1 parent 964f91d commit e9088e3
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ public void add(DataPoint m)
void add( DataPoint m, long currentTimeInMillis )
{

log.info("Adding data points");
MetricAggregationPolicy policy = aggregationPolicyProvider.metricAggregationPolicyFor( m.name );

// one metric can map to 0..N aggregates
List<MetricAggregate> aggregates = policy.getAggregates();
log.info("Get the aggregates list size: " + aggregates.size());

// no aggregates for this metric - done.
if( aggregates.size() == 0 )
Expand All @@ -124,12 +126,15 @@ void add( DataPoint m, long currentTimeInMillis )
}

int slotTs = slotStrategy.getSlotTs(m.ts);
log.info("Get the slot value: " + slotTs);

int now = Math.toIntExact(currentTimeInMillis / 1000);
log.info("Get the current time: " + now);

// check if point arrived too late and this slot has already been closed
if ( isLate(now, slotTs) )
{
log.info("The point arrived late so slot is closed");
latePointLogger.logLatePoint(m, now, LatePointLogger.Reason.SLOT_EXPIRED,
String.format("slot expiration: [%s]", slotTs + slotMaxLifeSec));
return;
Expand All @@ -138,8 +143,10 @@ void add( DataPoint m, long currentTimeInMillis )
// one metric can map to multiple aggregates
for (MetricAggregate agg : aggregates)
{
log.info("Retrieve each aggregate");
if ( agg.isDropOriginal() )
{
log.info("Dropping the metric");
m.drop();
}

Expand All @@ -148,11 +155,14 @@ void add( DataPoint m, long currentTimeInMillis )
Slot s = slots.computeIfAbsent(slotTs, k -> new Slot(k, latePointLogger, batchSize, aggregatorFlushTimer,
flushedAggregates, createdSlots) );
s.apply(agg, m, now);
log.info("Compute the value for slot");
}
log.info("Completed adding the data points");

}

private boolean isLate(int now, int slotTs) {
log.info("Check if the point is arriving late");
return now > slotTs + slotMaxLifeSec;
}

Expand Down

0 comments on commit e9088e3

Please sign in to comment.