mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Pyroscope: Remove "phlare" from variable, types, strings etc (#75140)
This commit is contained in:
parent
d1296f7213
commit
15e54df9f2
2
.github/commands.json
vendored
2
.github/commands.json
vendored
@ -149,7 +149,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type":"label",
|
"type":"label",
|
||||||
"name":"datasource/Phlare",
|
"name":"datasource/grafana-pyroscope",
|
||||||
"action":"addToProject",
|
"action":"addToProject",
|
||||||
"addToProject":{
|
"addToProject":{
|
||||||
"url":"https://github.com/orgs/grafana/projects/221"
|
"url":"https://github.com/orgs/grafana/projects/221"
|
||||||
|
@ -13,9 +13,9 @@ import * as common from '@grafana/schema';
|
|||||||
|
|
||||||
export const pluginVersion = "10.2.0-pre";
|
export const pluginVersion = "10.2.0-pre";
|
||||||
|
|
||||||
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
|
export type PyroscopeQueryType = ('metrics' | 'profile' | 'both');
|
||||||
|
|
||||||
export const defaultPhlareQueryType: PhlareQueryType = 'both';
|
export const defaultPyroscopeQueryType: PyroscopeQueryType = 'both';
|
||||||
|
|
||||||
export interface GrafanaPyroscopeDataQuery extends common.DataQuery {
|
export interface GrafanaPyroscopeDataQuery extends common.DataQuery {
|
||||||
/**
|
/**
|
||||||
|
@ -95,9 +95,9 @@ func TestIntegrationPluginManager(t *testing.T) {
|
|||||||
ms := mssql.ProvideService(cfg)
|
ms := mssql.ProvideService(cfg)
|
||||||
sv2 := searchV2.ProvideService(cfg, db.InitTestDB(t), nil, nil, tracer, features, nil, nil, nil)
|
sv2 := searchV2.ProvideService(cfg, db.InitTestDB(t), nil, nil, tracer, features, nil, nil, nil)
|
||||||
graf := grafanads.ProvideService(sv2, nil)
|
graf := grafanads.ProvideService(sv2, nil)
|
||||||
phlare := pyroscope.ProvideService(hcp, acimpl.ProvideAccessControl(cfg))
|
pyroscope := pyroscope.ProvideService(hcp, acimpl.ProvideAccessControl(cfg))
|
||||||
parca := parca.ProvideService(hcp)
|
parca := parca.ProvideService(hcp)
|
||||||
coreRegistry := coreplugin.ProvideCoreRegistry(am, cw, cm, es, grap, idb, lk, otsdb, pr, tmpo, td, pg, my, ms, graf, phlare, parca)
|
coreRegistry := coreplugin.ProvideCoreRegistry(am, cw, cm, es, grap, idb, lk, otsdb, pr, tmpo, td, pg, my, ms, graf, pyroscope, parca)
|
||||||
|
|
||||||
testCtx := CreateIntegrationTestCtx(t, cfg, coreRegistry)
|
testCtx := CreateIntegrationTestCtx(t, cfg, coreRegistry)
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -16,10 +16,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
_ backend.QueryDataHandler = (*PhlareDatasource)(nil)
|
_ backend.QueryDataHandler = (*PyroscopeDatasource)(nil)
|
||||||
_ backend.CallResourceHandler = (*PhlareDatasource)(nil)
|
_ backend.CallResourceHandler = (*PyroscopeDatasource)(nil)
|
||||||
_ backend.CheckHealthHandler = (*PhlareDatasource)(nil)
|
_ backend.CheckHealthHandler = (*PyroscopeDatasource)(nil)
|
||||||
_ backend.StreamHandler = (*PhlareDatasource)(nil)
|
_ backend.StreamHandler = (*PyroscopeDatasource)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
type ProfilingClient interface {
|
type ProfilingClient interface {
|
||||||
@ -30,16 +30,16 @@ type ProfilingClient interface {
|
|||||||
GetProfile(ctx context.Context, profileTypeID string, labelSelector string, start int64, end int64, maxNodes *int64) (*ProfileResponse, error)
|
GetProfile(ctx context.Context, profileTypeID string, labelSelector string, start int64, end int64, maxNodes *int64) (*ProfileResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhlareDatasource is a datasource for querying application performance profiles.
|
// PyroscopeDatasource is a datasource for querying application performance profiles.
|
||||||
type PhlareDatasource struct {
|
type PyroscopeDatasource struct {
|
||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
client ProfilingClient
|
client ProfilingClient
|
||||||
settings backend.DataSourceInstanceSettings
|
settings backend.DataSourceInstanceSettings
|
||||||
ac accesscontrol.AccessControl
|
ac accesscontrol.AccessControl
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPhlareDatasource creates a new datasource instance.
|
// NewPyroscopeDatasource creates a new datasource instance.
|
||||||
func NewPhlareDatasource(httpClientProvider httpclient.Provider, settings backend.DataSourceInstanceSettings, ac accesscontrol.AccessControl) (instancemgmt.Instance, error) {
|
func NewPyroscopeDatasource(httpClientProvider httpclient.Provider, settings backend.DataSourceInstanceSettings, ac accesscontrol.AccessControl) (instancemgmt.Instance, error) {
|
||||||
opt, err := settings.HTTPClientOptions()
|
opt, err := settings.HTTPClientOptions()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -49,15 +49,15 @@ func NewPhlareDatasource(httpClientProvider httpclient.Provider, settings backen
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &PhlareDatasource{
|
return &PyroscopeDatasource{
|
||||||
httpClient: httpClient,
|
httpClient: httpClient,
|
||||||
client: NewPhlareClient(httpClient, settings.URL),
|
client: NewPyroscopeClient(httpClient, settings.URL),
|
||||||
settings: settings,
|
settings: settings,
|
||||||
ac: ac,
|
ac: ac,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PhlareDatasource) CallResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
func (d *PyroscopeDatasource) CallResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||||
logger.Debug("CallResource", "Path", req.Path, "Method", req.Method, "Body", req.Body)
|
logger.Debug("CallResource", "Path", req.Path, "Method", req.Method, "Body", req.Body)
|
||||||
if req.Path == "profileTypes" {
|
if req.Path == "profileTypes" {
|
||||||
return d.profileTypes(ctx, req, sender)
|
return d.profileTypes(ctx, req, sender)
|
||||||
@ -73,7 +73,7 @@ func (d *PhlareDatasource) CallResource(ctx context.Context, req *backend.CallRe
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PhlareDatasource) profileTypes(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
func (d *PyroscopeDatasource) profileTypes(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||||
types, err := d.client.ProfileTypes(ctx)
|
types, err := d.client.ProfileTypes(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -89,7 +89,7 @@ func (d *PhlareDatasource) profileTypes(ctx context.Context, req *backend.CallRe
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PhlareDatasource) labelNames(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
func (d *PyroscopeDatasource) labelNames(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||||
res, err := d.client.LabelNames(ctx)
|
res, err := d.client.LabelNames(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error calling LabelNames: %v", err)
|
return fmt.Errorf("error calling LabelNames: %v", err)
|
||||||
@ -112,7 +112,7 @@ type LabelValuesPayload struct {
|
|||||||
End int64
|
End int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *PhlareDatasource) labelValues(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
func (d *PyroscopeDatasource) labelValues(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
|
||||||
u, err := url.Parse(req.URL)
|
u, err := url.Parse(req.URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -138,7 +138,7 @@ func (d *PhlareDatasource) labelValues(ctx context.Context, req *backend.CallRes
|
|||||||
// req contains the queries []DataQuery (where each query contains RefID as a unique identifier).
|
// req contains the queries []DataQuery (where each query contains RefID as a unique identifier).
|
||||||
// The QueryDataResponse contains a map of RefID to the response for each query, and each response
|
// The QueryDataResponse contains a map of RefID to the response for each query, and each response
|
||||||
// contains Frames ([]*Frame).
|
// contains Frames ([]*Frame).
|
||||||
func (d *PhlareDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
func (d *PyroscopeDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
|
||||||
logger.Debug("QueryData called", "Queries", req.Queries)
|
logger.Debug("QueryData called", "Queries", req.Queries)
|
||||||
|
|
||||||
// create response struct
|
// create response struct
|
||||||
@ -160,7 +160,7 @@ func (d *PhlareDatasource) QueryData(ctx context.Context, req *backend.QueryData
|
|||||||
// The main use case for these health checks is the test button on the
|
// The main use case for these health checks is the test button on the
|
||||||
// datasource configuration page which allows users to verify that
|
// datasource configuration page which allows users to verify that
|
||||||
// a datasource is working as expected.
|
// a datasource is working as expected.
|
||||||
func (d *PhlareDatasource) CheckHealth(ctx context.Context, _ *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
func (d *PyroscopeDatasource) CheckHealth(ctx context.Context, _ *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
||||||
logger.Debug("CheckHealth called")
|
logger.Debug("CheckHealth called")
|
||||||
|
|
||||||
status := backend.HealthStatusOk
|
status := backend.HealthStatusOk
|
||||||
@ -179,7 +179,7 @@ func (d *PhlareDatasource) CheckHealth(ctx context.Context, _ *backend.CheckHeal
|
|||||||
|
|
||||||
// SubscribeStream is called when a client wants to connect to a stream. This callback
|
// SubscribeStream is called when a client wants to connect to a stream. This callback
|
||||||
// allows sending the first message.
|
// allows sending the first message.
|
||||||
func (d *PhlareDatasource) SubscribeStream(_ context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error) {
|
func (d *PyroscopeDatasource) SubscribeStream(_ context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error) {
|
||||||
logger.Debug("SubscribeStream called")
|
logger.Debug("SubscribeStream called")
|
||||||
|
|
||||||
status := backend.SubscribeStreamStatusPermissionDenied
|
status := backend.SubscribeStreamStatusPermissionDenied
|
||||||
@ -194,7 +194,7 @@ func (d *PhlareDatasource) SubscribeStream(_ context.Context, req *backend.Subsc
|
|||||||
|
|
||||||
// RunStream is called once for any open channel. Results are shared with everyone
|
// RunStream is called once for any open channel. Results are shared with everyone
|
||||||
// subscribed to the same channel.
|
// subscribed to the same channel.
|
||||||
func (d *PhlareDatasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
|
func (d *PyroscopeDatasource) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error {
|
||||||
logger.Debug("RunStream called")
|
logger.Debug("RunStream called")
|
||||||
|
|
||||||
// Create the same data frame as for query data.
|
// Create the same data frame as for query data.
|
||||||
@ -231,7 +231,7 @@ func (d *PhlareDatasource) RunStream(ctx context.Context, req *backend.RunStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PublishStream is called when a client sends a message to the stream.
|
// PublishStream is called when a client sends a message to the stream.
|
||||||
func (d *PhlareDatasource) PublishStream(_ context.Context, _ *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error) {
|
func (d *PyroscopeDatasource) PublishStream(_ context.Context, _ *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error) {
|
||||||
logger.Debug("PublishStream called")
|
logger.Debug("PublishStream called")
|
||||||
|
|
||||||
// Do not allow publishing at all.
|
// Do not allow publishing at all.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
// This is where the tests for the datasource backend live.
|
// This is where the tests for the datasource backend live.
|
||||||
func Test_QueryData(t *testing.T) {
|
func Test_QueryData(t *testing.T) {
|
||||||
ds := PhlareDatasource{}
|
ds := PyroscopeDatasource{}
|
||||||
|
|
||||||
resp, err := ds.QueryData(
|
resp, err := ds.QueryData(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
@ -30,7 +30,7 @@ func Test_QueryData(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test_CallResource(t *testing.T) {
|
func Test_CallResource(t *testing.T) {
|
||||||
ds := &PhlareDatasource{
|
ds := &PyroscopeDatasource{
|
||||||
client: &FakeClient{},
|
client: &FakeClient{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
package dataquery
|
package dataquery
|
||||||
|
|
||||||
// Defines values for PhlareQueryType.
|
// Defines values for PyroscopeQueryType.
|
||||||
const (
|
const (
|
||||||
PhlareQueryTypeBoth PhlareQueryType = "both"
|
PyroscopeQueryTypeBoth PyroscopeQueryType = "both"
|
||||||
PhlareQueryTypeMetrics PhlareQueryType = "metrics"
|
PyroscopeQueryTypeMetrics PyroscopeQueryType = "metrics"
|
||||||
PhlareQueryTypeProfile PhlareQueryType = "profile"
|
PyroscopeQueryTypeProfile PyroscopeQueryType = "profile"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These are the common properties available to all queries in all datasources.
|
// These are the common properties available to all queries in all datasources.
|
||||||
@ -81,5 +81,5 @@ type GrafanaPyroscopeDataQuery struct {
|
|||||||
RefId string `json:"refId"`
|
RefId string `json:"refId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// PhlareQueryType defines model for PhlareQueryType.
|
// PyroscopeQueryType defines model for PyroscopeQueryType.
|
||||||
type PhlareQueryType string
|
type PyroscopeQueryType string
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -54,17 +54,17 @@ type SeriesResponse struct {
|
|||||||
Label string
|
Label string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PhlareClient struct {
|
type PyroscopeClient struct {
|
||||||
connectClient querierv1connect.QuerierServiceClient
|
connectClient querierv1connect.QuerierServiceClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPhlareClient(httpClient *http.Client, url string) *PhlareClient {
|
func NewPyroscopeClient(httpClient *http.Client, url string) *PyroscopeClient {
|
||||||
return &PhlareClient{
|
return &PyroscopeClient{
|
||||||
connectClient: querierv1connect.NewQuerierServiceClient(httpClient, url),
|
connectClient: querierv1connect.NewQuerierServiceClient(httpClient, url),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PhlareClient) ProfileTypes(ctx context.Context) ([]*ProfileType, error) {
|
func (c *PyroscopeClient) ProfileTypes(ctx context.Context) ([]*ProfileType, error) {
|
||||||
res, err := c.connectClient.ProfileTypes(ctx, connect.NewRequest(&querierv1.ProfileTypesRequest{}))
|
res, err := c.connectClient.ProfileTypes(ctx, connect.NewRequest(&querierv1.ProfileTypesRequest{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -84,7 +84,7 @@ func (c *PhlareClient) ProfileTypes(ctx context.Context) ([]*ProfileType, error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PhlareClient) GetSeries(ctx context.Context, profileTypeID string, labelSelector string, start int64, end int64, groupBy []string, step float64) (*SeriesResponse, error) {
|
func (c *PyroscopeClient) GetSeries(ctx context.Context, profileTypeID string, labelSelector string, start int64, end int64, groupBy []string, step float64) (*SeriesResponse, error) {
|
||||||
req := connect.NewRequest(&querierv1.SelectSeriesRequest{
|
req := connect.NewRequest(&querierv1.SelectSeriesRequest{
|
||||||
ProfileTypeID: profileTypeID,
|
ProfileTypeID: profileTypeID,
|
||||||
LabelSelector: labelSelector,
|
LabelSelector: labelSelector,
|
||||||
@ -133,7 +133,7 @@ func (c *PhlareClient) GetSeries(ctx context.Context, profileTypeID string, labe
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PhlareClient) GetProfile(ctx context.Context, profileTypeID, labelSelector string, start, end int64, maxNodes *int64) (*ProfileResponse, error) {
|
func (c *PyroscopeClient) GetProfile(ctx context.Context, profileTypeID, labelSelector string, start, end int64, maxNodes *int64) (*ProfileResponse, error) {
|
||||||
req := &connect.Request[querierv1.SelectMergeStacktracesRequest]{
|
req := &connect.Request[querierv1.SelectMergeStacktracesRequest]{
|
||||||
Msg: &querierv1.SelectMergeStacktracesRequest{
|
Msg: &querierv1.SelectMergeStacktracesRequest{
|
||||||
ProfileTypeID: profileTypeID,
|
ProfileTypeID: profileTypeID,
|
||||||
@ -179,7 +179,7 @@ func getUnits(profileTypeID string) string {
|
|||||||
return unit
|
return unit
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PhlareClient) LabelNames(ctx context.Context) ([]string, error) {
|
func (c *PyroscopeClient) LabelNames(ctx context.Context) ([]string, error) {
|
||||||
resp, err := c.connectClient.LabelNames(ctx, connect.NewRequest(&querierv1.LabelNamesRequest{}))
|
resp, err := c.connectClient.LabelNames(ctx, connect.NewRequest(&querierv1.LabelNamesRequest{}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error seding LabelNames request %v", err)
|
return nil, fmt.Errorf("error seding LabelNames request %v", err)
|
||||||
@ -195,7 +195,7 @@ func (c *PhlareClient) LabelNames(ctx context.Context) ([]string, error) {
|
|||||||
return filtered, nil
|
return filtered, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PhlareClient) LabelValues(ctx context.Context, label string) ([]string, error) {
|
func (c *PyroscopeClient) LabelValues(ctx context.Context, label string) ([]string, error) {
|
||||||
resp, err := c.connectClient.LabelValues(ctx, connect.NewRequest(&querierv1.LabelValuesRequest{Name: label}))
|
resp, err := c.connectClient.LabelValues(ctx, connect.NewRequest(&querierv1.LabelValuesRequest{Name: label}))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -11,9 +11,9 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_PhlareClient(t *testing.T) {
|
func Test_PyroscopeClient(t *testing.T) {
|
||||||
connectClient := &FakePhlareConnectClient{}
|
connectClient := &FakePyroscopeConnectClient{}
|
||||||
client := &PhlareClient{
|
client := &PyroscopeClient{
|
||||||
connectClient: connectClient,
|
connectClient: connectClient,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,27 +53,27 @@ func Test_PhlareClient(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type FakePhlareConnectClient struct {
|
type FakePyroscopeConnectClient struct {
|
||||||
Req any
|
Req any
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) ProfileTypes(ctx context.Context, c *connect.Request[querierv1.ProfileTypesRequest]) (*connect.Response[querierv1.ProfileTypesResponse], error) {
|
func (f *FakePyroscopeConnectClient) ProfileTypes(ctx context.Context, c *connect.Request[querierv1.ProfileTypesRequest]) (*connect.Response[querierv1.ProfileTypesResponse], error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) LabelValues(ctx context.Context, c *connect.Request[querierv1.LabelValuesRequest]) (*connect.Response[querierv1.LabelValuesResponse], error) {
|
func (f *FakePyroscopeConnectClient) LabelValues(ctx context.Context, c *connect.Request[querierv1.LabelValuesRequest]) (*connect.Response[querierv1.LabelValuesResponse], error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) LabelNames(context.Context, *connect.Request[querierv1.LabelNamesRequest]) (*connect.Response[querierv1.LabelNamesResponse], error) {
|
func (f *FakePyroscopeConnectClient) LabelNames(context.Context, *connect.Request[querierv1.LabelNamesRequest]) (*connect.Response[querierv1.LabelNamesResponse], error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) Series(ctx context.Context, c *connect.Request[querierv1.SeriesRequest]) (*connect.Response[querierv1.SeriesResponse], error) {
|
func (f *FakePyroscopeConnectClient) Series(ctx context.Context, c *connect.Request[querierv1.SeriesRequest]) (*connect.Response[querierv1.SeriesResponse], error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) SelectMergeStacktraces(ctx context.Context, c *connect.Request[querierv1.SelectMergeStacktracesRequest]) (*connect.Response[querierv1.SelectMergeStacktracesResponse], error) {
|
func (f *FakePyroscopeConnectClient) SelectMergeStacktraces(ctx context.Context, c *connect.Request[querierv1.SelectMergeStacktracesRequest]) (*connect.Response[querierv1.SelectMergeStacktracesResponse], error) {
|
||||||
f.Req = c
|
f.Req = c
|
||||||
return &connect.Response[querierv1.SelectMergeStacktracesResponse]{
|
return &connect.Response[querierv1.SelectMergeStacktracesResponse]{
|
||||||
Msg: &querierv1.SelectMergeStacktracesResponse{
|
Msg: &querierv1.SelectMergeStacktracesResponse{
|
||||||
@ -91,7 +91,7 @@ func (f *FakePhlareConnectClient) SelectMergeStacktraces(ctx context.Context, c
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) SelectSeries(ctx context.Context, req *connect.Request[querierv1.SelectSeriesRequest]) (*connect.Response[querierv1.SelectSeriesResponse], error) {
|
func (f *FakePyroscopeConnectClient) SelectSeries(ctx context.Context, req *connect.Request[querierv1.SelectSeriesRequest]) (*connect.Response[querierv1.SelectSeriesResponse], error) {
|
||||||
f.Req = req
|
f.Req = req
|
||||||
return &connect.Response[querierv1.SelectSeriesResponse]{
|
return &connect.Response[querierv1.SelectSeriesResponse]{
|
||||||
Msg: &querierv1.SelectSeriesResponse{
|
Msg: &querierv1.SelectSeriesResponse{
|
||||||
@ -105,6 +105,6 @@ func (f *FakePhlareConnectClient) SelectSeries(ctx context.Context, req *connect
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FakePhlareConnectClient) SelectMergeProfile(ctx context.Context, c *connect.Request[querierv1.SelectMergeProfileRequest]) (*connect.Response[googlev1.Profile], error) {
|
func (f *FakePyroscopeConnectClient) SelectMergeProfile(ctx context.Context, c *connect.Request[querierv1.SelectMergeProfileRequest]) (*connect.Response[googlev1.Profile], error) {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -27,13 +27,13 @@ type dsJsonModel struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
queryTypeProfile = string(dataquery.PhlareQueryTypeProfile)
|
queryTypeProfile = string(dataquery.PyroscopeQueryTypeProfile)
|
||||||
queryTypeMetrics = string(dataquery.PhlareQueryTypeMetrics)
|
queryTypeMetrics = string(dataquery.PyroscopeQueryTypeMetrics)
|
||||||
queryTypeBoth = string(dataquery.PhlareQueryTypeBoth)
|
queryTypeBoth = string(dataquery.PyroscopeQueryTypeBoth)
|
||||||
)
|
)
|
||||||
|
|
||||||
// query processes single Phlare query transforming the response to data.Frame packaged in DataResponse
|
// query processes single Pyroscope query transforming the response to data.Frame packaged in DataResponse
|
||||||
func (d *PhlareDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse {
|
func (d *PyroscopeDatasource) query(ctx context.Context, pCtx backend.PluginContext, query backend.DataQuery) backend.DataResponse {
|
||||||
var qm queryModel
|
var qm queryModel
|
||||||
response := backend.DataResponse{}
|
response := backend.DataResponse{}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func (d *PhlareDatasource) query(ctx context.Context, pCtx backend.PluginContext
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
// responseToDataFrames turns Phlare response to data.Frame. We encode the data into a nested set format where we have
|
// responseToDataFrames turns Pyroscope response to data.Frame. We encode the data into a nested set format where we have
|
||||||
// [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole
|
// [level, value, label] columns and by ordering the items in a depth first traversal order we can recreate the whole
|
||||||
// tree back.
|
// tree back.
|
||||||
func responseToDataFrames(resp *ProfileResponse) *data.Frame {
|
func responseToDataFrames(resp *ProfileResponse) *data.Frame {
|
||||||
@ -151,7 +151,7 @@ type ProfileTree struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// levelsToTree converts flamebearer format into a tree. This is needed to then convert it into nested set format
|
// levelsToTree converts flamebearer format into a tree. This is needed to then convert it into nested set format
|
||||||
// dataframe. This should be temporary, and ideally we should get some sort of tree struct directly from Phlare API.
|
// dataframe. This should be temporary, and ideally we should get some sort of tree struct directly from Pyroscope API.
|
||||||
func levelsToTree(levels []*Level, names []string) *ProfileTree {
|
func levelsToTree(levels []*Level, names []string) *ProfileTree {
|
||||||
if len(levels) == 0 {
|
if len(levels) == 0 {
|
||||||
return nil
|
return nil
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -13,7 +13,7 @@ import (
|
|||||||
// This is where the tests for the datasource backend live.
|
// This is where the tests for the datasource backend live.
|
||||||
func Test_query(t *testing.T) {
|
func Test_query(t *testing.T) {
|
||||||
client := &FakeClient{}
|
client := &FakeClient{}
|
||||||
ds := &PhlareDatasource{
|
ds := &PyroscopeDatasource{
|
||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package phlare
|
package pyroscope
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -11,7 +11,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Make sure PhlareDatasource implements required interfaces. This is important to do
|
// Make sure PyroscopeDatasource implements required interfaces. This is important to do
|
||||||
// since otherwise we will only get a not implemented error response from plugin in
|
// since otherwise we will only get a not implemented error response from plugin in
|
||||||
// runtime. In this example datasource instance implements backend.QueryDataHandler,
|
// runtime. In this example datasource instance implements backend.QueryDataHandler,
|
||||||
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not
|
// backend.CheckHealthHandler, backend.StreamHandler interfaces. Plugin should not
|
||||||
@ -27,18 +27,18 @@ var (
|
|||||||
_ backend.StreamHandler = (*Service)(nil)
|
_ backend.StreamHandler = (*Service)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
var logger = log.New("tsdb.phlare")
|
var logger = log.New("tsdb.pyroscope")
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
im instancemgmt.InstanceManager
|
im instancemgmt.InstanceManager
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) getInstance(ctx context.Context, pluginCtx backend.PluginContext) (*PhlareDatasource, error) {
|
func (s *Service) getInstance(ctx context.Context, pluginCtx backend.PluginContext) (*PyroscopeDatasource, error) {
|
||||||
i, err := s.im.Get(ctx, pluginCtx)
|
i, err := s.im.Get(ctx, pluginCtx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
in := i.(*PhlareDatasource)
|
in := i.(*PyroscopeDatasource)
|
||||||
return in, nil
|
return in, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ func ProvideService(httpClientProvider httpclient.Provider, ac accesscontrol.Acc
|
|||||||
|
|
||||||
func newInstanceSettings(httpClientProvider httpclient.Provider, ac accesscontrol.AccessControl) datasource.InstanceFactoryFunc {
|
func newInstanceSettings(httpClientProvider httpclient.Provider, ac accesscontrol.AccessControl) datasource.InstanceFactoryFunc {
|
||||||
return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
return func(settings backend.DataSourceInstanceSettings) (instancemgmt.Instance, error) {
|
||||||
return NewPhlareDatasource(httpClientProvider, settings, ac)
|
return NewPyroscopeDatasource(httpClientProvider, settings, ac)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
|||||||
import { DataSourceHttpSettings, EventsWithValidation, LegacyForms, regexValidation } from '@grafana/ui';
|
import { DataSourceHttpSettings, EventsWithValidation, LegacyForms, regexValidation } from '@grafana/ui';
|
||||||
import { config } from 'app/core/config';
|
import { config } from 'app/core/config';
|
||||||
|
|
||||||
import { PhlareDataSourceOptions } from './types';
|
import { PyroscopeDataSourceOptions } from './types';
|
||||||
|
|
||||||
interface Props extends DataSourcePluginOptionsEditorProps<PhlareDataSourceOptions> {}
|
interface Props extends DataSourcePluginOptionsEditorProps<PyroscopeDataSourceOptions> {}
|
||||||
|
|
||||||
export const ConfigEditor = (props: Props) => {
|
export const ConfigEditor = (props: Props) => {
|
||||||
const { options, onOptionsChange } = props;
|
const { options, onOptionsChange } = props;
|
||||||
@ -53,7 +53,7 @@ export const ConfigEditor = (props: Props) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
tooltip="Minimal step used for metric query. Should be the same or higher as the scrape interval setting in the Phlare database."
|
tooltip="Minimal step used for metric query. Should be the same or higher as the scrape interval setting in the Pyroscope database."
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,7 +4,7 @@ import { useAsync, useLatest } from 'react-use';
|
|||||||
|
|
||||||
import { CodeEditor, Monaco, useStyles2, monacoTypes } from '@grafana/ui';
|
import { CodeEditor, Monaco, useStyles2, monacoTypes } from '@grafana/ui';
|
||||||
|
|
||||||
import { languageDefinition } from '../phlareql';
|
import { languageDefinition } from '../pyroscopeql';
|
||||||
|
|
||||||
import { CompletionProvider } from './autocomplete';
|
import { CompletionProvider } from './autocomplete';
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ export function LabelsEditor(props: Props) {
|
|||||||
bottom: 5,
|
bottom: 5,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onBeforeEditorMount={ensurePhlareQL}
|
onBeforeEditorMount={ensurePyroscopeQL}
|
||||||
onEditorDidMount={(editor, monaco) => {
|
onEditorDidMount={(editor, monaco) => {
|
||||||
setupAutocompleteFn(editor, monaco);
|
setupAutocompleteFn(editor, monaco);
|
||||||
|
|
||||||
@ -125,12 +125,12 @@ function useAutocomplete(getLabelValues: (label: string) => Promise<string[]>, l
|
|||||||
}
|
}
|
||||||
|
|
||||||
// we must only run the setup code once
|
// we must only run the setup code once
|
||||||
let phlareqlSetupDone = false;
|
let pyroscopeqlSetupDone = false;
|
||||||
const langId = 'phlareql';
|
const langId = 'pyroscopeql';
|
||||||
|
|
||||||
function ensurePhlareQL(monaco: Monaco) {
|
function ensurePyroscopeQL(monaco: Monaco) {
|
||||||
if (phlareqlSetupDone === false) {
|
if (pyroscopeqlSetupDone === false) {
|
||||||
phlareqlSetupDone = true;
|
pyroscopeqlSetupDone = true;
|
||||||
const { aliases, extensions, mimetypes, def } = languageDefinition;
|
const { aliases, extensions, mimetypes, def } = languageDefinition;
|
||||||
monaco.languages.register({ id: langId, aliases, extensions, mimetypes });
|
monaco.languages.register({ id: langId, aliases, extensions, mimetypes });
|
||||||
monaco.languages.setMonarchTokensProvider(langId, def.language);
|
monaco.languages.setMonarchTokensProvider(langId, def.language);
|
||||||
|
@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|||||||
|
|
||||||
import { Cascader, CascaderOption } from '@grafana/ui';
|
import { Cascader, CascaderOption } from '@grafana/ui';
|
||||||
|
|
||||||
import { PhlareDataSource } from '../datasource';
|
import { PyroscopeDataSource } from '../datasource';
|
||||||
import { ProfileTypeMessage } from '../types';
|
import { ProfileTypeMessage } from '../types';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
@ -39,14 +39,9 @@ function useCascaderOptions(profileTypes?: ProfileTypeMessage[]): CascaderOption
|
|||||||
// Classify profile types by name then sample type.
|
// Classify profile types by name then sample type.
|
||||||
// The profileTypes are something like cpu:sample:nanoseconds:sample:count or app.something.something
|
// The profileTypes are something like cpu:sample:nanoseconds:sample:count or app.something.something
|
||||||
for (let profileType of profileTypes) {
|
for (let profileType of profileTypes) {
|
||||||
let parts: string[];
|
let parts: string[] = [];
|
||||||
// Phlare uses : as delimiter while Pyro uses .
|
|
||||||
if (profileType.id.indexOf(':') > -1) {
|
if (profileType.id.indexOf(':') > -1) {
|
||||||
parts = profileType.id.split(':');
|
parts = profileType.id.split(':');
|
||||||
} else {
|
|
||||||
parts = profileType.id.split('.');
|
|
||||||
const last = parts.pop()!;
|
|
||||||
parts = [parts.join('.'), last];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const [name, type] = parts;
|
const [name, type] = parts;
|
||||||
@ -74,7 +69,7 @@ function useCascaderOptions(profileTypes?: ProfileTypeMessage[]): CascaderOption
|
|||||||
* the profileTypes before rendering the cascader.
|
* the profileTypes before rendering the cascader.
|
||||||
* @param datasource
|
* @param datasource
|
||||||
*/
|
*/
|
||||||
export function useProfileTypes(datasource: PhlareDataSource) {
|
export function useProfileTypes(datasource: PyroscopeDataSource) {
|
||||||
const [profileTypes, setProfileTypes] = useState<ProfileTypeMessage[]>();
|
const [profileTypes, setProfileTypes] = useState<ProfileTypeMessage[]>();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -4,7 +4,7 @@ import React from 'react';
|
|||||||
|
|
||||||
import { CoreApp, PluginType } from '@grafana/data';
|
import { CoreApp, PluginType } from '@grafana/data';
|
||||||
|
|
||||||
import { PhlareDataSource } from '../datasource';
|
import { PyroscopeDataSource } from '../datasource';
|
||||||
import { ProfileTypeMessage } from '../types';
|
import { ProfileTypeMessage } from '../types';
|
||||||
|
|
||||||
import { Props, QueryEditor } from './QueryEditor';
|
import { Props, QueryEditor } from './QueryEditor';
|
||||||
@ -62,7 +62,7 @@ async function openOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupDs() {
|
function setupDs() {
|
||||||
const ds = new PhlareDataSource({
|
const ds = new PyroscopeDataSource({
|
||||||
name: 'test',
|
name: 'test',
|
||||||
uid: 'test',
|
uid: 'test',
|
||||||
type: PluginType.datasource,
|
type: PluginType.datasource,
|
||||||
|
@ -5,8 +5,8 @@ import { useAsync } from 'react-use';
|
|||||||
import { CoreApp, QueryEditorProps, TimeRange } from '@grafana/data';
|
import { CoreApp, QueryEditorProps, TimeRange } from '@grafana/data';
|
||||||
import { LoadingPlaceholder } from '@grafana/ui';
|
import { LoadingPlaceholder } from '@grafana/ui';
|
||||||
|
|
||||||
import { normalizeQuery, PhlareDataSource } from '../datasource';
|
import { normalizeQuery, PyroscopeDataSource } from '../datasource';
|
||||||
import { PhlareDataSourceOptions, ProfileTypeMessage, Query } from '../types';
|
import { PyroscopeDataSourceOptions, ProfileTypeMessage, Query } from '../types';
|
||||||
|
|
||||||
import { EditorRow } from './EditorRow';
|
import { EditorRow } from './EditorRow';
|
||||||
import { EditorRows } from './EditorRows';
|
import { EditorRows } from './EditorRows';
|
||||||
@ -14,7 +14,7 @@ import { LabelsEditor } from './LabelsEditor';
|
|||||||
import { ProfileTypesCascader, useProfileTypes } from './ProfileTypesCascader';
|
import { ProfileTypesCascader, useProfileTypes } from './ProfileTypesCascader';
|
||||||
import { QueryOptions } from './QueryOptions';
|
import { QueryOptions } from './QueryOptions';
|
||||||
|
|
||||||
export type Props = QueryEditorProps<PhlareDataSource, Query, PhlareDataSourceOptions>;
|
export type Props = QueryEditorProps<PyroscopeDataSource, Query, PyroscopeDataSourceOptions>;
|
||||||
|
|
||||||
export function QueryEditor(props: Props) {
|
export function QueryEditor(props: Props) {
|
||||||
const { onChange, onRunQuery, datasource, query, range, app } = props;
|
const { onChange, onRunQuery, datasource, query, range, app } = props;
|
||||||
@ -106,7 +106,7 @@ function defaultProfileType(profileTypes: ProfileTypeMessage[]): string {
|
|||||||
|
|
||||||
function useLabels(
|
function useLabels(
|
||||||
range: TimeRange | undefined,
|
range: TimeRange | undefined,
|
||||||
datasource: PhlareDataSource,
|
datasource: PyroscopeDataSource,
|
||||||
query: Query,
|
query: Query,
|
||||||
onChange: (value: Query) => void
|
onChange: (value: Query) => void
|
||||||
) {
|
) {
|
||||||
|
@ -4,7 +4,7 @@ import { monacoTypes, Monaco } from '@grafana/ui';
|
|||||||
* Class that implements CompletionItemProvider interface and allows us to provide suggestion for the Monaco
|
* Class that implements CompletionItemProvider interface and allows us to provide suggestion for the Monaco
|
||||||
* autocomplete system.
|
* autocomplete system.
|
||||||
*
|
*
|
||||||
* At this moment we just pass it all the labels/values we get from Phlare backend later on we may do something a bit
|
* At this moment we just pass it all the labels/values we get from Pyroscope backend later on we may do something a bit
|
||||||
* smarter if there will be lots of labels.
|
* smarter if there will be lots of labels.
|
||||||
*/
|
*/
|
||||||
export class CompletionProvider implements monacoTypes.languages.CompletionItemProvider {
|
export class CompletionProvider implements monacoTypes.languages.CompletionItemProvider {
|
||||||
@ -153,7 +153,7 @@ const inLabelNameRegex = new RegExp(/[{,]\s*[a-zA-Z0-9_]*$/);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Figure out where is the cursor and what kind of suggestions are appropriate.
|
* Figure out where is the cursor and what kind of suggestions are appropriate.
|
||||||
* As currently Phlare handles just a simple {foo="bar", baz="zyx"} kind of values we can do with simple regex to figure
|
* As currently Pyroscope handles just a simple {foo="bar", baz="zyx"} kind of values we can do with simple regex to figure
|
||||||
* out where we are with the cursor.
|
* out where we are with the cursor.
|
||||||
* @param text
|
* @param text
|
||||||
* @param offset
|
* @param offset
|
||||||
|
@ -5,8 +5,8 @@ import { DataSourceInstanceSettings } from '@grafana/data';
|
|||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { VariableQueryEditor } from './VariableQueryEditor';
|
import { VariableQueryEditor } from './VariableQueryEditor';
|
||||||
import { PhlareDataSource } from './datasource';
|
import { PyroscopeDataSource } from './datasource';
|
||||||
import { PhlareDataSourceOptions } from './types';
|
import { PyroscopeDataSourceOptions } from './types';
|
||||||
|
|
||||||
describe('VariableQueryEditor', () => {
|
describe('VariableQueryEditor', () => {
|
||||||
it('renders correctly with type profileType', () => {
|
it('renders correctly with type profileType', () => {
|
||||||
@ -69,7 +69,7 @@ describe('VariableQueryEditor', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function getMockDatasource() {
|
function getMockDatasource() {
|
||||||
const ds = new PhlareDataSource({} as DataSourceInstanceSettings<PhlareDataSourceOptions>, new TemplateSrv());
|
const ds = new PyroscopeDataSource({} as DataSourceInstanceSettings<PyroscopeDataSourceOptions>, new TemplateSrv());
|
||||||
ds.getResource = jest.fn();
|
ds.getResource = jest.fn();
|
||||||
(ds.getResource as jest.Mock).mockImplementation(async (type: string) => {
|
(ds.getResource as jest.Mock).mockImplementation(async (type: string) => {
|
||||||
if (type === 'profileTypes') {
|
if (type === 'profileTypes') {
|
||||||
|
@ -4,10 +4,10 @@ import { QueryEditorProps, SelectableValue } from '@grafana/data';
|
|||||||
import { InlineField, InlineFieldRow, LoadingPlaceholder, Select } from '@grafana/ui';
|
import { InlineField, InlineFieldRow, LoadingPlaceholder, Select } from '@grafana/ui';
|
||||||
|
|
||||||
import { ProfileTypesCascader, useProfileTypes } from './QueryEditor/ProfileTypesCascader';
|
import { ProfileTypesCascader, useProfileTypes } from './QueryEditor/ProfileTypesCascader';
|
||||||
import { PhlareDataSource } from './datasource';
|
import { PyroscopeDataSource } from './datasource';
|
||||||
import { Query, VariableQuery } from './types';
|
import { Query, VariableQuery } from './types';
|
||||||
|
|
||||||
export function VariableQueryEditor(props: QueryEditorProps<PhlareDataSource, Query, {}, VariableQuery>) {
|
export function VariableQueryEditor(props: QueryEditorProps<PyroscopeDataSource, Query, {}, VariableQuery>) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InlineFieldRow>
|
<InlineFieldRow>
|
||||||
@ -87,7 +87,7 @@ export function VariableQueryEditor(props: QueryEditorProps<PhlareDataSource, Qu
|
|||||||
}
|
}
|
||||||
|
|
||||||
function LabelRow(props: {
|
function LabelRow(props: {
|
||||||
datasource: PhlareDataSource;
|
datasource: PyroscopeDataSource;
|
||||||
value?: string;
|
value?: string;
|
||||||
profileTypeId?: string;
|
profileTypeId?: string;
|
||||||
from: number;
|
from: number;
|
||||||
@ -128,7 +128,7 @@ function LabelRow(props: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ProfileTypeRow(props: {
|
function ProfileTypeRow(props: {
|
||||||
datasource: PhlareDataSource;
|
datasource: PyroscopeDataSource;
|
||||||
onChange: (val: string) => void;
|
onChange: (val: string) => void;
|
||||||
initialValue?: string;
|
initialValue?: string;
|
||||||
}) {
|
}) {
|
||||||
|
@ -5,7 +5,7 @@ import { CustomVariableSupport, DataQueryRequest, DataQueryResponse, MetricFindV
|
|||||||
import { getTimeSrv, TimeSrv } from '../../../features/dashboard/services/TimeSrv';
|
import { getTimeSrv, TimeSrv } from '../../../features/dashboard/services/TimeSrv';
|
||||||
|
|
||||||
import { VariableQueryEditor } from './VariableQueryEditor';
|
import { VariableQueryEditor } from './VariableQueryEditor';
|
||||||
import { PhlareDataSource } from './datasource';
|
import { PyroscopeDataSource } from './datasource';
|
||||||
import { ProfileTypeMessage, VariableQuery } from './types';
|
import { ProfileTypeMessage, VariableQuery } from './types';
|
||||||
|
|
||||||
export interface DataAPI {
|
export interface DataAPI {
|
||||||
@ -14,7 +14,7 @@ export interface DataAPI {
|
|||||||
getLabelValues(query: string, label: string, start: number, end: number): Promise<string[]>;
|
getLabelValues(query: string, label: string, start: number, end: number): Promise<string[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class VariableSupport extends CustomVariableSupport<PhlareDataSource> {
|
export class VariableSupport extends CustomVariableSupport<PyroscopeDataSource> {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly dataAPI: DataAPI,
|
private readonly dataAPI: DataAPI,
|
||||||
private readonly timeSrv: TimeSrv = getTimeSrv()
|
private readonly timeSrv: TimeSrv = getTimeSrv()
|
||||||
|
@ -37,7 +37,7 @@ composableKinds: DataQuery: {
|
|||||||
groupBy: [...string]
|
groupBy: [...string]
|
||||||
// Sets the maximum number of nodes in the flamegraph.
|
// Sets the maximum number of nodes in the flamegraph.
|
||||||
maxNodes?: int64
|
maxNodes?: int64
|
||||||
#PhlareQueryType: "metrics" | "profile" | *"both" @cuetsy(kind="type")
|
#PyroscopeQueryType: "metrics" | "profile" | *"both" @cuetsy(kind="type")
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
lenses: []
|
lenses: []
|
||||||
|
@ -10,9 +10,9 @@
|
|||||||
|
|
||||||
import * as common from '@grafana/schema';
|
import * as common from '@grafana/schema';
|
||||||
|
|
||||||
export type PhlareQueryType = ('metrics' | 'profile' | 'both');
|
export type PyroscopeQueryType = ('metrics' | 'profile' | 'both');
|
||||||
|
|
||||||
export const defaultPhlareQueryType: PhlareQueryType = 'both';
|
export const defaultPyroscopeQueryType: PyroscopeQueryType = 'both';
|
||||||
|
|
||||||
export interface GrafanaPyroscope extends common.DataQuery {
|
export interface GrafanaPyroscope extends common.DataQuery {
|
||||||
/**
|
/**
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { AbstractLabelOperator, CoreApp, DataSourceInstanceSettings, PluginMetaInfo, PluginType } from '@grafana/data';
|
import { AbstractLabelOperator, CoreApp, DataSourceInstanceSettings, PluginMetaInfo, PluginType } from '@grafana/data';
|
||||||
import { TemplateSrv } from 'app/features/templating/template_srv';
|
import { TemplateSrv } from 'app/features/templating/template_srv';
|
||||||
|
|
||||||
import { defaultPhlareQueryType } from './dataquery.gen';
|
import { defaultPyroscopeQueryType } from './dataquery.gen';
|
||||||
import { normalizeQuery, PhlareDataSource } from './datasource';
|
import { normalizeQuery, PyroscopeDataSource } from './datasource';
|
||||||
import { Query } from './types';
|
import { Query } from './types';
|
||||||
|
|
||||||
describe('Phlare data source', () => {
|
describe('Pyroscope data source', () => {
|
||||||
let ds: PhlareDataSource;
|
let ds: PyroscopeDataSource;
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
ds = new PhlareDataSource(defaultSettings);
|
ds = new PyroscopeDataSource(defaultSettings);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('importing queries', () => {
|
describe('importing queries', () => {
|
||||||
@ -56,7 +56,7 @@ describe('Phlare data source', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not update labelSelector if there are no template variables', () => {
|
it('should not update labelSelector if there are no template variables', () => {
|
||||||
ds = new PhlareDataSource(defaultSettings, templateSrv);
|
ds = new PyroscopeDataSource(defaultSettings, templateSrv);
|
||||||
const query = ds.applyTemplateVariables(defaultQuery({ labelSelector: `no var`, profileTypeId: 'no var' }), {});
|
const query = ds.applyTemplateVariables(defaultQuery({ labelSelector: `no var`, profileTypeId: 'no var' }), {});
|
||||||
expect(query).toMatchObject({
|
expect(query).toMatchObject({
|
||||||
labelSelector: `no var`,
|
labelSelector: `no var`,
|
||||||
@ -65,7 +65,7 @@ describe('Phlare data source', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should update labelSelector if there are template variables', () => {
|
it('should update labelSelector if there are template variables', () => {
|
||||||
ds = new PhlareDataSource(defaultSettings, templateSrv);
|
ds = new PyroscopeDataSource(defaultSettings, templateSrv);
|
||||||
const query = ds.applyTemplateVariables(
|
const query = ds.applyTemplateVariables(
|
||||||
defaultQuery({ labelSelector: `{$var="$var"}`, profileTypeId: '$var' }),
|
defaultQuery({ labelSelector: `{$var="$var"}`, profileTypeId: '$var' }),
|
||||||
{}
|
{}
|
||||||
@ -117,20 +117,20 @@ const defaultQuery = (query: Partial<Query>): Query => {
|
|||||||
groupBy: [],
|
groupBy: [],
|
||||||
labelSelector: '',
|
labelSelector: '',
|
||||||
profileTypeId: '',
|
profileTypeId: '',
|
||||||
queryType: defaultPhlareQueryType,
|
queryType: defaultPyroscopeQueryType,
|
||||||
...query,
|
...query,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaultSettings: DataSourceInstanceSettings = {
|
const defaultSettings: DataSourceInstanceSettings = {
|
||||||
id: 0,
|
id: 0,
|
||||||
uid: 'phlare',
|
uid: 'pyroscope',
|
||||||
type: 'profiling',
|
type: 'profiling',
|
||||||
name: 'phlare',
|
name: 'pyroscope',
|
||||||
access: 'proxy',
|
access: 'proxy',
|
||||||
meta: {
|
meta: {
|
||||||
id: 'phlare',
|
id: 'pyroscope',
|
||||||
name: 'phlare',
|
name: 'pyroscope',
|
||||||
type: PluginType.datasource,
|
type: PluginType.datasource,
|
||||||
info: {} as PluginMetaInfo,
|
info: {} as PluginMetaInfo,
|
||||||
module: '',
|
module: '',
|
||||||
|
@ -14,12 +14,12 @@ import { DataSourceWithBackend, getTemplateSrv, TemplateSrv } from '@grafana/run
|
|||||||
import { extractLabelMatchers, toPromLikeExpr } from '../prometheus/language_utils';
|
import { extractLabelMatchers, toPromLikeExpr } from '../prometheus/language_utils';
|
||||||
|
|
||||||
import { VariableSupport } from './VariableSupport';
|
import { VariableSupport } from './VariableSupport';
|
||||||
import { defaultGrafanaPyroscope, defaultPhlareQueryType } from './dataquery.gen';
|
import { defaultGrafanaPyroscope, defaultPyroscopeQueryType } from './dataquery.gen';
|
||||||
import { PhlareDataSourceOptions, Query, ProfileTypeMessage } from './types';
|
import { PyroscopeDataSourceOptions, Query, ProfileTypeMessage } from './types';
|
||||||
|
|
||||||
export class PhlareDataSource extends DataSourceWithBackend<Query, PhlareDataSourceOptions> {
|
export class PyroscopeDataSource extends DataSourceWithBackend<Query, PyroscopeDataSourceOptions> {
|
||||||
constructor(
|
constructor(
|
||||||
instanceSettings: DataSourceInstanceSettings<PhlareDataSourceOptions>,
|
instanceSettings: DataSourceInstanceSettings<PyroscopeDataSourceOptions>,
|
||||||
private readonly templateSrv: TemplateSrv = getTemplateSrv()
|
private readonly templateSrv: TemplateSrv = getTemplateSrv()
|
||||||
) {
|
) {
|
||||||
super(instanceSettings);
|
super(instanceSettings);
|
||||||
@ -92,11 +92,11 @@ export class PhlareDataSource extends DataSourceWithBackend<Query, PhlareDataSou
|
|||||||
}
|
}
|
||||||
|
|
||||||
exportToAbstractQuery(query: Query): AbstractQuery {
|
exportToAbstractQuery(query: Query): AbstractQuery {
|
||||||
const phlareQuery = query.labelSelector;
|
const pyroscopeQuery = query.labelSelector;
|
||||||
if (!phlareQuery || phlareQuery.length === 0) {
|
if (!pyroscopeQuery || pyroscopeQuery.length === 0) {
|
||||||
return { refId: query.refId, labelMatchers: [] };
|
return { refId: query.refId, labelMatchers: [] };
|
||||||
}
|
}
|
||||||
const tokens = Prism.tokenize(phlareQuery, grammar);
|
const tokens = Prism.tokenize(pyroscopeQuery, grammar);
|
||||||
return {
|
return {
|
||||||
refId: query.refId,
|
refId: query.refId,
|
||||||
labelMatchers: extractLabelMatchers(tokens),
|
labelMatchers: extractLabelMatchers(tokens),
|
||||||
@ -110,7 +110,7 @@ export class PhlareDataSource extends DataSourceWithBackend<Query, PhlareDataSou
|
|||||||
|
|
||||||
export const defaultQuery: Partial<Query> = {
|
export const defaultQuery: Partial<Query> = {
|
||||||
...defaultGrafanaPyroscope,
|
...defaultGrafanaPyroscope,
|
||||||
queryType: defaultPhlareQueryType,
|
queryType: defaultPyroscopeQueryType,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function normalizeQuery(query: Query, app?: CoreApp | string) {
|
export function normalizeQuery(query: Query, app?: CoreApp | string) {
|
||||||
|
@ -2,9 +2,9 @@ import { DataSourcePlugin } from '@grafana/data';
|
|||||||
|
|
||||||
import { ConfigEditor } from './ConfigEditor';
|
import { ConfigEditor } from './ConfigEditor';
|
||||||
import { QueryEditor } from './QueryEditor/QueryEditor';
|
import { QueryEditor } from './QueryEditor/QueryEditor';
|
||||||
import { PhlareDataSource } from './datasource';
|
import { PyroscopeDataSource } from './datasource';
|
||||||
import { Query, PhlareDataSourceOptions } from './types';
|
import { Query, PyroscopeDataSourceOptions } from './types';
|
||||||
|
|
||||||
export const plugin = new DataSourcePlugin<PhlareDataSource, Query, PhlareDataSourceOptions>(PhlareDataSource)
|
export const plugin = new DataSourcePlugin<PyroscopeDataSource, Query, PyroscopeDataSourceOptions>(PyroscopeDataSource)
|
||||||
.setConfigEditor(ConfigEditor)
|
.setConfigEditor(ConfigEditor)
|
||||||
.setQueryEditor(QueryEditor);
|
.setQueryEditor(QueryEditor);
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
import { language, languageConfiguration } from './phlareql';
|
|
||||||
|
|
||||||
export const languageDefinition = {
|
|
||||||
id: 'phlareql',
|
|
||||||
extensions: ['.phlareql'],
|
|
||||||
aliases: ['phlare', 'phlareql'],
|
|
||||||
mimetypes: [],
|
|
||||||
def: {
|
|
||||||
language,
|
|
||||||
languageConfiguration,
|
|
||||||
},
|
|
||||||
};
|
|
@ -0,0 +1,12 @@
|
|||||||
|
import { language, languageConfiguration } from './pyroscopeql';
|
||||||
|
|
||||||
|
export const languageDefinition = {
|
||||||
|
id: 'pyroscopeql',
|
||||||
|
extensions: ['.pyroscopeql'],
|
||||||
|
aliases: ['pyroscope', 'pyroscopeql'],
|
||||||
|
mimetypes: [],
|
||||||
|
def: {
|
||||||
|
language,
|
||||||
|
languageConfiguration,
|
||||||
|
},
|
||||||
|
};
|
@ -20,7 +20,7 @@ export const languageConfiguration: languages.LanguageConfiguration = {
|
|||||||
export const language: languages.IMonarchLanguage = {
|
export const language: languages.IMonarchLanguage = {
|
||||||
ignoreCase: false,
|
ignoreCase: false,
|
||||||
defaultToken: '',
|
defaultToken: '',
|
||||||
tokenPostfix: '.phlareql',
|
tokenPostfix: '.pyroscopeql',
|
||||||
|
|
||||||
keywords: [],
|
keywords: [],
|
||||||
operators: [],
|
operators: [],
|
@ -1,9 +1,9 @@
|
|||||||
import { DataSourceJsonData } from '@grafana/data';
|
import { DataSourceJsonData } from '@grafana/data';
|
||||||
|
|
||||||
import { GrafanaPyroscope, PhlareQueryType } from './dataquery.gen';
|
import { GrafanaPyroscope, PyroscopeQueryType } from './dataquery.gen';
|
||||||
|
|
||||||
export interface Query extends GrafanaPyroscope {
|
export interface Query extends GrafanaPyroscope {
|
||||||
queryType: PhlareQueryType;
|
queryType: PyroscopeQueryType;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ProfileTypeMessage {
|
export interface ProfileTypeMessage {
|
||||||
@ -14,7 +14,7 @@ export interface ProfileTypeMessage {
|
|||||||
/**
|
/**
|
||||||
* These are options configured for each DataSource instance.
|
* These are options configured for each DataSource instance.
|
||||||
*/
|
*/
|
||||||
export interface PhlareDataSourceOptions extends DataSourceJsonData {
|
export interface PyroscopeDataSourceOptions extends DataSourceJsonData {
|
||||||
minStep?: string;
|
minStep?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user