1
- package phlare
1
+ package pyroscope
2
2
3
3
import (
4
4
"context"
@@ -16,10 +16,10 @@ import (
16
16
)
17
17
18
18
var (
19
- _ backend.QueryDataHandler = (* PhlareDatasource )(nil )
20
- _ backend.CallResourceHandler = (* PhlareDatasource )(nil )
21
- _ backend.CheckHealthHandler = (* PhlareDatasource )(nil )
22
- _ backend.StreamHandler = (* PhlareDatasource )(nil )
19
+ _ backend.QueryDataHandler = (* PyroscopeDatasource )(nil )
20
+ _ backend.CallResourceHandler = (* PyroscopeDatasource )(nil )
21
+ _ backend.CheckHealthHandler = (* PyroscopeDatasource )(nil )
22
+ _ backend.StreamHandler = (* PyroscopeDatasource )(nil )
23
23
)
24
24
25
25
type ProfilingClient interface {
@@ -30,16 +30,16 @@ type ProfilingClient interface {
30
30
GetProfile (ctx context.Context , profileTypeID string , labelSelector string , start int64 , end int64 , maxNodes * int64 ) (* ProfileResponse , error )
31
31
}
32
32
33
- // PhlareDatasource is a datasource for querying application performance profiles.
34
- type PhlareDatasource struct {
33
+ // PyroscopeDatasource is a datasource for querying application performance profiles.
34
+ type PyroscopeDatasource struct {
35
35
httpClient * http.Client
36
36
client ProfilingClient
37
37
settings backend.DataSourceInstanceSettings
38
38
ac accesscontrol.AccessControl
39
39
}
40
40
41
- // NewPhlareDatasource creates a new datasource instance.
42
- func NewPhlareDatasource (httpClientProvider httpclient.Provider , settings backend.DataSourceInstanceSettings , ac accesscontrol.AccessControl ) (instancemgmt.Instance , error ) {
41
+ // NewPyroscopeDatasource creates a new datasource instance.
42
+ func NewPyroscopeDatasource (httpClientProvider httpclient.Provider , settings backend.DataSourceInstanceSettings , ac accesscontrol.AccessControl ) (instancemgmt.Instance , error ) {
43
43
opt , err := settings .HTTPClientOptions ()
44
44
if err != nil {
45
45
return nil , err
@@ -49,15 +49,15 @@ func NewPhlareDatasource(httpClientProvider httpclient.Provider, settings backen
49
49
return nil , err
50
50
}
51
51
52
- return & PhlareDatasource {
52
+ return & PyroscopeDatasource {
53
53
httpClient : httpClient ,
54
- client : NewPhlareClient (httpClient , settings .URL ),
54
+ client : NewPyroscopeClient (httpClient , settings .URL ),
55
55
settings : settings ,
56
56
ac : ac ,
57
57
}, nil
58
58
}
59
59
60
- func (d * PhlareDatasource ) CallResource (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
60
+ func (d * PyroscopeDatasource ) CallResource (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
61
61
logger .Debug ("CallResource" , "Path" , req .Path , "Method" , req .Method , "Body" , req .Body )
62
62
if req .Path == "profileTypes" {
63
63
return d .profileTypes (ctx , req , sender )
@@ -73,7 +73,7 @@ func (d *PhlareDatasource) CallResource(ctx context.Context, req *backend.CallRe
73
73
})
74
74
}
75
75
76
- func (d * PhlareDatasource ) profileTypes (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
76
+ func (d * PyroscopeDatasource ) profileTypes (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
77
77
types , err := d .client .ProfileTypes (ctx )
78
78
if err != nil {
79
79
return err
@@ -89,7 +89,7 @@ func (d *PhlareDatasource) profileTypes(ctx context.Context, req *backend.CallRe
89
89
return nil
90
90
}
91
91
92
- func (d * PhlareDatasource ) labelNames (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
92
+ func (d * PyroscopeDatasource ) labelNames (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
93
93
res , err := d .client .LabelNames (ctx )
94
94
if err != nil {
95
95
return fmt .Errorf ("error calling LabelNames: %v" , err )
@@ -112,7 +112,7 @@ type LabelValuesPayload struct {
112
112
End int64
113
113
}
114
114
115
- func (d * PhlareDatasource ) labelValues (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
115
+ func (d * PyroscopeDatasource ) labelValues (ctx context.Context , req * backend.CallResourceRequest , sender backend.CallResourceResponseSender ) error {
116
116
u , err := url .Parse (req .URL )
117
117
if err != nil {
118
118
return err
@@ -138,7 +138,7 @@ func (d *PhlareDatasource) labelValues(ctx context.Context, req *backend.CallRes
138
138
// req contains the queries []DataQuery (where each query contains RefID as a unique identifier).
139
139
// The QueryDataResponse contains a map of RefID to the response for each query, and each response
140
140
// contains Frames ([]*Frame).
141
- func (d * PhlareDatasource ) QueryData (ctx context.Context , req * backend.QueryDataRequest ) (* backend.QueryDataResponse , error ) {
141
+ func (d * PyroscopeDatasource ) QueryData (ctx context.Context , req * backend.QueryDataRequest ) (* backend.QueryDataResponse , error ) {
142
142
logger .Debug ("QueryData called" , "Queries" , req .Queries )
143
143
144
144
// create response struct
@@ -160,7 +160,7 @@ func (d *PhlareDatasource) QueryData(ctx context.Context, req *backend.QueryData
160
160
// The main use case for these health checks is the test button on the
161
161
// datasource configuration page which allows users to verify that
162
162
// a datasource is working as expected.
163
- func (d * PhlareDatasource ) CheckHealth (ctx context.Context , _ * backend.CheckHealthRequest ) (* backend.CheckHealthResult , error ) {
163
+ func (d * PyroscopeDatasource ) CheckHealth (ctx context.Context , _ * backend.CheckHealthRequest ) (* backend.CheckHealthResult , error ) {
164
164
logger .Debug ("CheckHealth called" )
165
165
166
166
status := backend .HealthStatusOk
@@ -179,7 +179,7 @@ func (d *PhlareDatasource) CheckHealth(ctx context.Context, _ *backend.CheckHeal
179
179
180
180
// SubscribeStream is called when a client wants to connect to a stream. This callback
181
181
// allows sending the first message.
182
- func (d * PhlareDatasource ) SubscribeStream (_ context.Context , req * backend.SubscribeStreamRequest ) (* backend.SubscribeStreamResponse , error ) {
182
+ func (d * PyroscopeDatasource ) SubscribeStream (_ context.Context , req * backend.SubscribeStreamRequest ) (* backend.SubscribeStreamResponse , error ) {
183
183
logger .Debug ("SubscribeStream called" )
184
184
185
185
status := backend .SubscribeStreamStatusPermissionDenied
@@ -194,7 +194,7 @@ func (d *PhlareDatasource) SubscribeStream(_ context.Context, req *backend.Subsc
194
194
195
195
// RunStream is called once for any open channel. Results are shared with everyone
196
196
// subscribed to the same channel.
197
- func (d * PhlareDatasource ) RunStream (ctx context.Context , req * backend.RunStreamRequest , sender * backend.StreamSender ) error {
197
+ func (d * PyroscopeDatasource ) RunStream (ctx context.Context , req * backend.RunStreamRequest , sender * backend.StreamSender ) error {
198
198
logger .Debug ("RunStream called" )
199
199
200
200
// Create the same data frame as for query data.
@@ -231,7 +231,7 @@ func (d *PhlareDatasource) RunStream(ctx context.Context, req *backend.RunStream
231
231
}
232
232
233
233
// PublishStream is called when a client sends a message to the stream.
234
- func (d * PhlareDatasource ) PublishStream (_ context.Context , _ * backend.PublishStreamRequest ) (* backend.PublishStreamResponse , error ) {
234
+ func (d * PyroscopeDatasource ) PublishStream (_ context.Context , _ * backend.PublishStreamRequest ) (* backend.PublishStreamResponse , error ) {
235
235
logger .Debug ("PublishStream called" )
236
236
237
237
// Do not allow publishing at all.
0 commit comments