Tracing: Standardize on otel tracing (#75528)
This commit is contained in:
@@ -70,7 +70,7 @@ func (gm *MathCommand) NeedsVars() []string {
|
||||
// failed to execute.
|
||||
func (gm *MathCommand) Execute(ctx context.Context, _ time.Time, vars mathexp.Vars, tracer tracing.Tracer) (mathexp.Results, error) {
|
||||
_, span := tracer.Start(ctx, "SSE.ExecuteMath")
|
||||
span.SetAttributes("expression", gm.RawExpression, attribute.Key("expression").String(gm.RawExpression))
|
||||
span.SetAttributes(attribute.String("expression", gm.RawExpression))
|
||||
defer span.End()
|
||||
return gm.Expression.Execute(gm.refID, vars, tracer)
|
||||
}
|
||||
@@ -163,7 +163,7 @@ func (gr *ReduceCommand) Execute(ctx context.Context, _ time.Time, vars mathexp.
|
||||
_, span := tracer.Start(ctx, "SSE.ExecuteReduce")
|
||||
defer span.End()
|
||||
|
||||
span.SetAttributes("reducer", gr.Reducer, attribute.Key("reducer").String(gr.Reducer))
|
||||
span.SetAttributes(attribute.String("reducer", gr.Reducer))
|
||||
|
||||
newRes := mathexp.Results{}
|
||||
for i, val := range vars[gr.VarToReduce].Values {
|
||||
|
||||
@@ -61,7 +61,7 @@ func shouldUseDataplane(frames data.Frames, logger log.Logger, disable bool) (dt
|
||||
func handleDataplaneFrames(ctx context.Context, tracer tracing.Tracer, t data.FrameType, frames data.Frames) (mathexp.Results, error) {
|
||||
_, span := tracer.Start(ctx, "SSE.HandleDataPlaneData")
|
||||
defer span.End()
|
||||
span.SetAttributes("dataplane.type", t, attribute.Key("dataplane.type").String(string(t)))
|
||||
span.SetAttributes(attribute.String("dataplane.type", string(t)))
|
||||
|
||||
switch t.Kind() {
|
||||
case data.KindUnknown:
|
||||
|
||||
+2
-2
@@ -99,10 +99,10 @@ func (dp *DataPipeline) execute(c context.Context, now time.Time, s *Service) (m
|
||||
}
|
||||
|
||||
c, span := s.tracer.Start(c, "SSE.ExecuteNode")
|
||||
span.SetAttributes("node.refId", node.RefID(), attribute.Key("node.refId").String(node.RefID()))
|
||||
span.SetAttributes(attribute.String("node.refId", node.RefID()))
|
||||
if len(node.NeedsVars()) > 0 {
|
||||
inputRefIDs := node.NeedsVars()
|
||||
span.SetAttributes("node.inputRefIDs", inputRefIDs, attribute.Key("node.inputRefIDs").StringSlice(inputRefIDs))
|
||||
span.SetAttributes(attribute.StringSlice("node.inputRefIDs", inputRefIDs))
|
||||
}
|
||||
defer span.End()
|
||||
|
||||
|
||||
+13
-15
@@ -10,12 +10,12 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
"github.com/grafana/grafana-plugin-sdk-go/data"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/codes"
|
||||
"gonum.org/v1/gonum/graph/simple"
|
||||
|
||||
"github.com/grafana/grafana/pkg/expr/classic"
|
||||
"github.com/grafana/grafana/pkg/expr/mathexp"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/services/datasources"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
)
|
||||
@@ -236,8 +236,10 @@ func executeDSNodesGrouped(ctx context.Context, now time.Time, vars mathexp.Vars
|
||||
"datasourceVersion", firstNode.datasource.Version,
|
||||
)
|
||||
|
||||
span.SetAttributes("datasource.type", firstNode.datasource.Type, attribute.Key("datasource.type").String(firstNode.datasource.Type))
|
||||
span.SetAttributes("datasource.uid", firstNode.datasource.UID, attribute.Key("datasource.uid").String(firstNode.datasource.UID))
|
||||
span.SetAttributes(
|
||||
attribute.String("datasource.type", firstNode.datasource.Type),
|
||||
attribute.String("datasource.uid", firstNode.datasource.UID),
|
||||
)
|
||||
|
||||
req := &backend.QueryDataRequest{
|
||||
PluginContext: pCtx,
|
||||
@@ -261,11 +263,8 @@ func executeDSNodesGrouped(ctx context.Context, now time.Time, vars mathexp.Vars
|
||||
if e != nil {
|
||||
responseType = "error"
|
||||
respStatus = "failure"
|
||||
span.AddEvents([]string{"error", "message"},
|
||||
[]tracing.EventValue{
|
||||
{Str: fmt.Sprintf("%v", err)},
|
||||
{Str: "failed to query data source"},
|
||||
})
|
||||
span.SetStatus(codes.Error, "failed to query data source")
|
||||
span.RecordError(e)
|
||||
}
|
||||
logger.Debug("Data source queried", "responseType", responseType)
|
||||
useDataplane := strings.HasPrefix(responseType, "dataplane-")
|
||||
@@ -313,8 +312,10 @@ func (dn *DSNode) Execute(ctx context.Context, now time.Time, _ mathexp.Vars, s
|
||||
if err != nil {
|
||||
return mathexp.Results{}, err
|
||||
}
|
||||
span.SetAttributes("datasource.type", dn.datasource.Type, attribute.Key("datasource.type").String(dn.datasource.Type))
|
||||
span.SetAttributes("datasource.uid", dn.datasource.UID, attribute.Key("datasource.uid").String(dn.datasource.UID))
|
||||
span.SetAttributes(
|
||||
attribute.String("datasource.type", dn.datasource.Type),
|
||||
attribute.String("datasource.uid", dn.datasource.UID),
|
||||
)
|
||||
|
||||
req := &backend.QueryDataRequest{
|
||||
PluginContext: pCtx,
|
||||
@@ -337,11 +338,8 @@ func (dn *DSNode) Execute(ctx context.Context, now time.Time, _ mathexp.Vars, s
|
||||
if e != nil {
|
||||
responseType = "error"
|
||||
respStatus = "failure"
|
||||
span.AddEvents([]string{"error", "message"},
|
||||
[]tracing.EventValue{
|
||||
{Str: fmt.Sprintf("%v", err)},
|
||||
{Str: "failed to query data source"},
|
||||
})
|
||||
span.SetStatus(codes.Error, "failed to query data source")
|
||||
span.RecordError(e)
|
||||
}
|
||||
logger.Debug("Data source queried", "responseType", responseType)
|
||||
useDataplane := strings.HasPrefix(responseType, "dataplane-")
|
||||
|
||||
Reference in New Issue
Block a user