Skip to content

Commit

Permalink
Fix /qualitymetrics to return data in expected format (#6733)
Browse files Browse the repository at this point in the history
## 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]>
  • Loading branch information
yurishkuro authored Feb 15, 2025
1 parent 23d2254 commit c78f5c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 1 addition & 5 deletions cmd/query/app/http_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,5 @@ func spanNameHandler(spanName string, handler http.Handler) http.Handler {

func (aH *APIHandler) getQualityMetrics(w http.ResponseWriter, r *http.Request) {
data := qualitymetrics.GetSampleData()
structuredRes := structuredResponse{
Data: data,
Errors: []structuredError{},
}
aH.writeJSON(w, r, &structuredRes)
aH.writeJSON(w, r, &data)
}
6 changes: 4 additions & 2 deletions cmd/query/app/http_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"go.uber.org/zap/zaptest/observer"

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

func TestMetricsReaderError(t *testing.T) {
Expand Down

0 comments on commit c78f5c3

Please sign in to comment.