Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions internal/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ type Metric struct {
var (
//Only Gauge is a supported metric types
ErrInvalidType = errors.New("unknown metric type provided. Only gauge is supported")
//The value was not found in the aggregation result set
ErrValueNotFound = errors.New("value not found in result set")

//No cached metric available
ErrNotCached = errors.New("metric not available from cache")
)
Expand Down Expand Up @@ -471,7 +470,7 @@ func (metric *Metric) getValue(result AggregationResult) (float64, error) {
}
}

return 0, ErrValueNotFound
return 0, fmt.Errorf("value for metric %s with key %s not found in result set", metric.Name, metric.Value)
}

func (metric *Metric) getLabels(result AggregationResult) ([]string, error) {
Expand Down
7 changes: 4 additions & 3 deletions internal/collector/collector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ func TestInitializeMetrics(t *testing.T) {
aggregation: &Aggregation{
Metrics: []*Metric{
{
Name: "simple_gauge_value_not_found",
Type: "gauge",
Name: "simple_gauge_value_not_found",
Type: "gauge",
Value: "total",
},
},
Pipeline: "[{\"$match\":{\"foo\":\"bar\"}}]",
},
docs: []interface{}{AggregationResult{}},
//error: "1 error occurred:\n\t* value not found in result set\n\n",
//error: "value for metric simple_gauge_value_not_found with key total not found in result set",
expected: ``,
},
{
Expand Down