Use only local tsdb for federation (#7096)

Signed-off-by: yeya24 <yb532204897@gmail.com>
This commit is contained in:
Ben Ye 2020-04-07 11:42:42 -04:00 committed by GitHub
parent 34c7f6e3c4
commit ecda6013ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View file

@ -75,7 +75,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
)
w.Header().Set("Content-Type", string(format))
q, err := h.storage.Querier(req.Context(), mint, maxt)
q, err := h.localStorage.Querier(req.Context(), mint, maxt)
if err != nil {
federationErrors.Inc()
http.Error(w, err.Error(), http.StatusInternalServerError)
@ -209,10 +209,10 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
// Attach global labels if they do not exist yet.
for _, ln := range externalLabelNames {
lv := externalLabels[ln]
if _, ok := globalUsed[string(ln)]; !ok {
if _, ok := globalUsed[ln]; !ok {
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
Name: proto.String(string(ln)),
Value: proto.String(string(lv)),
Name: proto.String(ln),
Value: proto.String(lv),
})
}
}

View file

@ -199,8 +199,7 @@ func TestFederation(t *testing.T) {
}
h := &Handler{
storage: suite.Storage(),
queryEngine: suite.QueryEngine(),
localStorage: suite.Storage(),
lookbackDelta: 5 * time.Minute,
now: func() model.Time { return 101 * 60 * 1000 }, // 101min after epoch.
config: &config.Config{

View file

@ -180,6 +180,7 @@ type Handler struct {
context context.Context
tsdb func() *tsdb.DB
storage storage.Storage
localStorage storage.Storage
notifier *notifier.Manager
apiV1 *api_v1.API
@ -284,6 +285,7 @@ func New(logger log.Logger, o *Options) *Handler {
lookbackDelta: o.LookbackDelta,
tsdb: o.TSDB,
storage: o.Storage,
localStorage: o.TSDB(),
notifier: o.Notifier,
now: model.Now,

View file

@ -399,6 +399,7 @@ func TestDebugHandler(t *testing.T) {
Host: "localhost.localdomain:9090",
Scheme: "http",
},
TSDB: func() *tsdb.DB { return nil },
}
handler := New(nil, opts)
handler.Ready()
@ -425,6 +426,7 @@ func TestHTTPMetrics(t *testing.T) {
Host: "localhost.localdomain:9090",
Scheme: "http",
},
TSDB: func() *tsdb.DB { return nil },
})
getReady := func() int {
t.Helper()