-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tempo Serverless: Queriers Prefer Self (#1307)
* Added max_concurrent_queries to doc Signed-off-by: Joe Elliott <[email protected]> * added support for local search self Signed-off-by: Joe Elliott <[email protected]> * add functionality and test Signed-off-by: Joe Elliott <[email protected]> * changelog Signed-off-by: Joe Elliott <[email protected]> * clarifications Signed-off-by: Joe Elliott <[email protected]>
- Loading branch information
1 parent
4b26046
commit 642f15f
Showing
13 changed files
with
307 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package querier | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
"time" | ||
|
||
"github.com/grafana/tempo/modules/ingester/client" | ||
"github.com/grafana/tempo/pkg/tempopb" | ||
"github.com/stretchr/testify/require" | ||
"github.com/uber-go/atomic" | ||
"github.com/weaveworks/common/user" | ||
) | ||
|
||
func TestQuerierUsesSearchExternalEndpoint(t *testing.T) { | ||
numExternalRequests := atomic.NewInt32(0) | ||
|
||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
time.Sleep(100 * time.Millisecond) | ||
numExternalRequests.Inc() | ||
})) | ||
defer srv.Close() | ||
|
||
tests := []struct { | ||
cfg Config | ||
queriesToExecute int | ||
externalExpected int32 | ||
}{ | ||
// SearchExternalEndpoints is respected | ||
{ | ||
cfg: Config{ | ||
SearchExternalEndpoints: []string{srv.URL}, | ||
}, | ||
queriesToExecute: 3, | ||
externalExpected: 3, | ||
}, | ||
// No SearchExternalEndpoints causes the querier to service everything internally | ||
{ | ||
cfg: Config{}, | ||
queriesToExecute: 3, | ||
externalExpected: 0, | ||
}, | ||
// SearchPreferSelf is respected. this test won't pass b/c SearchBlock fails instantly and so | ||
// all 3 queries are executed locally and nothing is proxied to the external endpoint. | ||
// we'd have to mock the storage.Store interface to get this to pass. it's a big interface. | ||
// { | ||
// cfg: Config{ | ||
// SearchExternalEndpoints: []string{srv.URL}, | ||
// SearchPreferSelf: 2, | ||
// }, | ||
// queriesToExecute: 3, | ||
// externalExpected: 1, | ||
// }, | ||
} | ||
|
||
ctx := user.InjectOrgID(context.Background(), "blerg") | ||
|
||
for _, tc := range tests { | ||
numExternalRequests.Store(0) | ||
|
||
q, err := New(tc.cfg, client.Config{}, nil, nil, nil) | ||
require.NoError(t, err) | ||
|
||
for i := 0; i < tc.queriesToExecute; i++ { | ||
// ignore error purposefully here. all queries will error, but we don't care | ||
// numExternalRequests will tell us what we need to know | ||
_, _ = q.SearchBlock(ctx, &tempopb.SearchBlockRequest{}) | ||
} | ||
|
||
require.Equal(t, tc.externalExpected, numExternalRequests.Load()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters