/** * Record an observation of an error. If it is the first observation of this error type for a stack trace * then a new entry will be created. For subsequent observations of the same error type and stack trace a * counter and time of last observation will be updated. * * @param observation to be logged as an error observation. * @return true if successfully logged otherwise false if insufficient space remaining in the log. */ public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; }
try existingObservation = newObservation(timestamp, existingObservations, observation); if (INSUFFICIENT_SPACE == existingObservation)
/** * Record an observation of an error. If it is the first observation of this error type for a stack trace * then a new entry will be created. For subsequent observations of the same error type and stack trace a * counter and time of last observation will be updated. * * @param observation to be logged as an error observation. * @return true if successfully logged otherwise false if insufficient space remaining in the log. */ public boolean record(final Throwable observation) { final long timestamp = clock.time(); DistinctObservation distinctObservation; synchronized (this) { distinctObservation = find(distinctObservations, observation); if (null == distinctObservation) { distinctObservation = newObservation(timestamp, observation); if (INSUFFICIENT_SPACE == distinctObservation) { return false; } } } final int offset = distinctObservation.offset; buffer.getAndAddInt(offset + OBSERVATION_COUNT_OFFSET, 1); buffer.putLongOrdered(offset + LAST_OBSERVATION_TIMESTAMP_OFFSET, timestamp); return true; }