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 Varati committed Jul 19, 2023
1 parent e62ded5 commit 6941aad
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,25 +111,27 @@ 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 )
{
return;
}

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 +140,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 +152,13 @@ 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 6941aad

Please sign in to comment.