mirror of
https://github.com/grafana/grafana.git
synced 2025-09-28 10:33:45 +08:00
Plugins: Update collect metrics handler to latest signature (#45166)
* use updated collect metrics handler * use proto helper
This commit is contained in:
@ -64,7 +64,7 @@ func (cp *corePlugin) IsDecommissioned() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (cp *corePlugin) CollectMetrics(ctx context.Context) (*backend.CollectMetricsResult, error) {
|
||||
func (cp *corePlugin) CollectMetrics(_ context.Context, _ *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error) {
|
||||
return nil, backendplugin.ErrMethodNotImplemented
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ func TestCorePlugin(t *testing.T) {
|
||||
require.True(t, p.IsManaged())
|
||||
require.False(t, p.Exited())
|
||||
|
||||
_, err = p.CollectMetrics(context.Background())
|
||||
_, err = p.CollectMetrics(context.Background(), &backend.CollectMetricsRequest{})
|
||||
require.Equal(t, backendplugin.ErrMethodNotImplemented, err)
|
||||
|
||||
_, err = p.CheckHealth(context.Background(), nil)
|
||||
@ -55,7 +55,7 @@ func TestCorePlugin(t *testing.T) {
|
||||
require.True(t, p.IsManaged())
|
||||
require.False(t, p.Exited())
|
||||
|
||||
_, err = p.CollectMetrics(context.Background())
|
||||
_, err = p.CollectMetrics(context.Background(), &backend.CollectMetricsRequest{})
|
||||
require.Equal(t, backendplugin.ErrMethodNotImplemented, err)
|
||||
|
||||
_, err = p.CheckHealth(context.Background(), &backend.CheckHealthRequest{})
|
||||
|
@ -92,12 +92,12 @@ func newClientV2(descriptor PluginDescriptor, logger log.Logger, rpcClient plugi
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (c *ClientV2) CollectMetrics(ctx context.Context) (*backend.CollectMetricsResult, error) {
|
||||
func (c *ClientV2) CollectMetrics(ctx context.Context, req *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error) {
|
||||
if c.DiagnosticsClient == nil {
|
||||
return &backend.CollectMetricsResult{}, nil
|
||||
}
|
||||
|
||||
protoResp, err := c.DiagnosticsClient.CollectMetrics(ctx, &pluginv2.CollectMetricsRequest{})
|
||||
protoResp, err := c.DiagnosticsClient.CollectMetrics(ctx, backend.ToProto().CollectMetricsRequest(req))
|
||||
if err != nil {
|
||||
if status.Code(err) == codes.Unimplemented {
|
||||
return &backend.CollectMetricsResult{}, nil
|
||||
|
@ -131,12 +131,12 @@ func (p *grpcPlugin) getPluginClient() (pluginClient, bool) {
|
||||
return pluginClient, true
|
||||
}
|
||||
|
||||
func (p *grpcPlugin) CollectMetrics(ctx context.Context) (*backend.CollectMetricsResult, error) {
|
||||
func (p *grpcPlugin) CollectMetrics(ctx context.Context, req *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error) {
|
||||
pluginClient, ok := p.getPluginClient()
|
||||
if !ok {
|
||||
return nil, backendplugin.ErrPluginUnavailable
|
||||
}
|
||||
return pluginClient.CollectMetrics(ctx)
|
||||
return pluginClient.CollectMetrics(ctx, req)
|
||||
}
|
||||
|
||||
func (p *grpcPlugin) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error) {
|
||||
|
Reference in New Issue
Block a user