Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Implements a basic SelectSeries API for querying metrics on profiles #160

Merged
merged 4 commits into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions grafana/fire-datasource/pkg/plugin/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ func (d *FireDatasource) query(ctx context.Context, pCtx backend.PluginContext,
// add the frames to the response.
response.Frames = append(response.Frames, frame)

log.DefaultLogger.Debug("Querying SelectSeries()", "queryModel", qm)

seriesResp, err := d.client.SelectSeries(ctx, connect.NewRequest(&querierv1.SelectSeriesRequest{
ProfileTypeID: qm.ProfileTypeID,
LabelSelector: qm.LabelSelector,
Start: query.TimeRange.From.UnixMilli(),
End: query.TimeRange.To.UnixMilli(),
Step: query.Interval.Seconds(),
// todo add one or more group bys
GroupBy: []string{},
}))
if err != nil {
response.Error = err
return response
}
// todo remove me and add the series to the frame.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aocenas will take over from here.

log.DefaultLogger.Debug("Series", seriesResp.Msg.Series)
return response
}

Expand Down
7 changes: 6 additions & 1 deletion grafana/fire-datasource/pkg/plugin/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"time"

"github.com/bufbuild/connect-go"
querierv1 "github.com/grafana/fire/pkg/gen/querier/v1"
"github.com/grafana/grafana-plugin-sdk-go/backend"
"github.com/grafana/grafana-plugin-sdk-go/data"
"github.com/stretchr/testify/require"

querierv1 "github.com/grafana/fire/pkg/gen/querier/v1"
)

// This is where the tests for the datasource backend live.
Expand Down Expand Up @@ -93,3 +94,7 @@ func (f FakeClient) SelectMergeStacktraces(ctx context.Context, c *connect.Reque
},
}, nil
}

func (f FakeClient) SelectSeries(ctx context.Context, req *connect.Request[querierv1.SelectSeriesRequest]) (*connect.Response[querierv1.SelectSeriesResponse], error) {
panic("implement me")
}
10 changes: 5 additions & 5 deletions pkg/distributor/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
pushv1 "github.com/grafana/fire/pkg/gen/push/v1"
"github.com/grafana/fire/pkg/gen/push/v1/pushv1connect"
"github.com/grafana/fire/pkg/ingester/clientpool"
"github.com/grafana/fire/pkg/testutil"
"github.com/grafana/fire/pkg/testhelper"
)

func Test_ConnectPush(t *testing.T) {
mux := http.NewServeMux()
ing := newFakeIngester(t, false)
d, err := New(Config{}, testutil.NewMockRing([]ring.InstanceDesc{
d, err := New(Config{}, testhelper.NewMockRing([]ring.InstanceDesc{
{Addr: "foo"},
}, 3), func(addr string) (client.PoolClient, error) {
return ing, nil
Expand Down Expand Up @@ -84,7 +84,7 @@ func Test_Replication(t *testing.T) {
},
},
})
d, err := New(Config{}, testutil.NewMockRing([]ring.InstanceDesc{
d, err := New(Config{}, testhelper.NewMockRing([]ring.InstanceDesc{
{Addr: "1"},
{Addr: "2"},
{Addr: "3"},
Expand All @@ -107,7 +107,7 @@ func Test_Subservices(t *testing.T) {
ing := newFakeIngester(t, false)
d, err := New(Config{
PoolConfig: clientpool.PoolConfig{ClientCleanupPeriod: 1 * time.Second},
}, testutil.NewMockRing([]ring.InstanceDesc{
}, testhelper.NewMockRing([]ring.InstanceDesc{
{Addr: "foo"},
}, 1), func(addr string) (client.PoolClient, error) {
return ing, nil
Expand Down Expand Up @@ -138,7 +138,7 @@ type fakeIngester struct {
t testing.TB
requests []*pushv1.PushRequest
fail bool
testutil.FakePoolClient
testhelper.FakePoolClient

mtx sync.Mutex
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/gen/google/v1/profile.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading