Skip to content

Commit c78f5c3

Browse files
authored
Fix /qualitymetrics to return data in expected format (#6733)
## Which problem is this PR solving? - Follow up to #6608 - Resolves #6607 ## Description of the changes - Remove intermediate `data:` element from the response - Match response to what the UI expects - Fix unit test that wasn't testing the output ## How was this change tested? - unit tests - manual test with jaegertracing/jaeger-ui#2641 --------- Signed-off-by: Yuri Shkuro <[email protected]>
1 parent 23d2254 commit c78f5c3

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

cmd/query/app/http_handler.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,5 @@ func spanNameHandler(spanName string, handler http.Handler) http.Handler {
557557

558558
func (aH *APIHandler) getQualityMetrics(w http.ResponseWriter, r *http.Request) {
559559
data := qualitymetrics.GetSampleData()
560-
structuredRes := structuredResponse{
561-
Data: data,
562-
Errors: []structuredError{},
563-
}
564-
aH.writeJSON(w, r, &structuredRes)
560+
aH.writeJSON(w, r, &data)
565561
}

cmd/query/app/http_handler_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"go.uber.org/zap/zaptest/observer"
3232

3333
"github.com/jaegertracing/jaeger-idl/model/v1"
34+
"github.com/jaegertracing/jaeger/cmd/query/app/qualitymetrics"
3435
"github.com/jaegertracing/jaeger/cmd/query/app/querysvc"
3536
"github.com/jaegertracing/jaeger/internal/storage/metricstore/disabled"
3637
metricsmocks "github.com/jaegertracing/jaeger/internal/storage/v1/api/metricstore/mocks"
@@ -870,8 +871,9 @@ func TestGetQualityMetrics(t *testing.T) {
870871
handler.getQualityMetrics(rr, req)
871872
assert.Equal(t, http.StatusOK, rr.Code)
872873
assert.Equal(t, "application/json", rr.Header().Get("Content-Type"))
873-
var resp structuredResponse
874-
assert.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp), "unable to unmarshal response")
874+
var resp qualitymetrics.TQualityMetrics
875+
require.NoError(t, json.Unmarshal(rr.Body.Bytes(), &resp))
876+
require.Contains(t, resp.TraceQualityDocumentationLink, "github.com/jaegertracing")
875877
}
876878

877879
func TestMetricsReaderError(t *testing.T) {

0 commit comments

Comments
 (0)