mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Mark elasticsearch errors as downstream (#96152)
Elasticsearch: mark elasticsearch errors as downstream
This commit is contained in:
parent
9df0f8a98d
commit
749f59b3e3
@ -1,8 +1,10 @@
|
||||
package elasticsearch
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/grafana/grafana-plugin-sdk-go/experimental/errorsource"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -117,6 +119,10 @@ func TestErrorTooManyDateHistogramBuckets(t *testing.T) {
|
||||
require.True(t, ok)
|
||||
require.Len(t, dataResponse.Frames, 0)
|
||||
require.ErrorContains(t, dataResponse.Error, "Trying to create too many buckets. Must be less than or equal to: [65536].")
|
||||
var sourceErr errorsource.Error
|
||||
ok = errors.As(dataResponse.Error, &sourceErr)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, sourceErr.ErrorSource().String(), "downstream")
|
||||
}
|
||||
|
||||
func TestNonElasticError(t *testing.T) {
|
||||
|
@ -75,7 +75,7 @@ func parseResponse(ctx context.Context, responses []*es.SearchResponse, targets
|
||||
resSpan.End()
|
||||
logger.Error("Processing error response from Elasticsearch", "error", string(me), "query", string(mt))
|
||||
errResult := getErrorFromElasticResponse(res)
|
||||
result.Responses[target.RefID] = errorsource.Response(errorsource.PluginError(errors.New(errResult), false))
|
||||
result.Responses[target.RefID] = errorsource.Response(errorsource.DownstreamError(errors.New(errResult), false))
|
||||
continue
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user