Plugins: Add tracing to pipeline (#115448)
This commit is contained in:
@@ -3,9 +3,14 @@ package validation
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.opentelemetry.io/otel"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
"github.com/grafana/grafana/pkg/plugins/config"
|
||||
"github.com/grafana/grafana/pkg/plugins/log"
|
||||
"github.com/grafana/grafana/pkg/semconv"
|
||||
)
|
||||
|
||||
// Validator is responsible for the Validation stage of the plugin loader pipeline.
|
||||
@@ -20,6 +25,7 @@ type Validate struct {
|
||||
cfg *config.PluginManagementCfg
|
||||
validateSteps []ValidateFunc
|
||||
log log.Logger
|
||||
tracer trace.Tracer
|
||||
}
|
||||
|
||||
type Opts struct {
|
||||
@@ -36,11 +42,17 @@ func New(cfg *config.PluginManagementCfg, opts Opts) *Validate {
|
||||
cfg: cfg,
|
||||
validateSteps: opts.ValidateFuncs,
|
||||
log: log.New("plugins.validation"),
|
||||
tracer: otel.Tracer("github.com/grafana/grafana/pkg/plugins/manager/pipeline/validation"),
|
||||
}
|
||||
}
|
||||
|
||||
// Validate will execute the Validate steps of the Validation stage.
|
||||
func (v *Validate) Validate(ctx context.Context, ps *plugins.Plugin) error {
|
||||
ctx, span := v.tracer.Start(ctx, "validation.Validate", trace.WithAttributes(
|
||||
semconv.GrafanaPluginId(ps.ID),
|
||||
))
|
||||
defer span.End()
|
||||
|
||||
if len(v.validateSteps) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -49,7 +61,7 @@ func (v *Validate) Validate(ctx context.Context, ps *plugins.Plugin) error {
|
||||
err := validate(ctx, ps)
|
||||
if err != nil {
|
||||
v.log.Error("Plugin validation failed", "pluginId", ps.ID, "error", err)
|
||||
return err
|
||||
return tracing.Error(span, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user