diff --git a/pkg/metricstore/buffer.go b/pkg/metricstore/buffer.go index 8530f893..72467f6c 100644 --- a/pkg/metricstore/buffer.go +++ b/pkg/metricstore/buffer.go @@ -146,7 +146,9 @@ var ( // ErrDataDoesNotAlign indicates that aggregated data from child scopes // does not align with the parent scope's expected timestamps/intervals. - ErrDataDoesNotAlign error = errors.New("[METRICSTORE]> data from lower granularities does not align") + ErrDataDoesNotAlignMissingFront error = errors.New("[METRICSTORE]> data from lower granularities does not align (missing data prior to start of the buffers)") + ErrDataDoesNotAlignMissingBack error = errors.New("[METRICSTORE]> data from lower granularities does not align (missing data after the end of the buffers)") + ErrDataDoesNotAlignDataLenMismatch error = errors.New("[METRICSTORE]> data from lower granularities does not align (collected data length is different than expected data length)") ) // buffer stores time-series data for a single metric at a specific hierarchical level. diff --git a/pkg/metricstore/metricstore.go b/pkg/metricstore/metricstore.go index e8bd6812..9ba69c55 100644 --- a/pkg/metricstore/metricstore.go +++ b/pkg/metricstore/metricstore.go @@ -712,16 +712,16 @@ func (m *MemoryStore) Read(selector util.Selector, metric string, from, to, reso } else if from != cfrom || to != cto || len(data) != len(cdata) { missingfront, missingback := int((from-cfrom)/minfo.Frequency), int((to-cto)/minfo.Frequency) if missingfront != 0 { - return ErrDataDoesNotAlign + return ErrDataDoesNotAlignMissingFront } newlen := len(cdata) - missingback if newlen < 1 { - return ErrDataDoesNotAlign + return ErrDataDoesNotAlignMissingBack } cdata = cdata[0:newlen] if len(cdata) != len(data) { - return ErrDataDoesNotAlign + return ErrDataDoesNotAlignDataLenMismatch } from, to = cfrom, cto diff --git a/pkg/metricstore/stats.go b/pkg/metricstore/stats.go index 2feec2ff..f9db2d43 100644 --- a/pkg/metricstore/stats.go +++ b/pkg/metricstore/stats.go @@ -91,8 +91,10 @@ func (m *MemoryStore) Stats(selector util.Selector, metric string, from, to int6 if n == 0 { from, to = cfrom, cto - } else if from != cfrom || to != cto { - return ErrDataDoesNotAlign + } else if from != cfrom { + return ErrDataDoesNotAlignMissingFront + } else if to != cto { + return ErrDataDoesNotAlignMissingBack } samples += stats.Samples