Skip to content

Commit

Permalink
chore(tracing): Add ns attribute to doQuery (#7850)
Browse files Browse the repository at this point in the history
(cherry picked from commit b80efb6)
  • Loading branch information
ajeetdsouza committed May 25, 2021
1 parent e7fe20d commit 9f0d378
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,12 @@ func (s *Server) Alter(ctx context.Context, op *api.Operation) (*api.Payload, er
return empty, nil
}

func annotateNamespace(span *otrace.Span, ns uint64) {
span.AddAttributes(otrace.Int64Attribute("ns", int64(ns)))
}

func annotateStartTs(span *otrace.Span, ts uint64) {
span.Annotate([]otrace.Attribute{otrace.Int64Attribute("startTs", int64(ts))}, "")
span.AddAttributes(otrace.Int64Attribute("startTs", int64(ts)))
}

func (s *Server) doMutate(ctx context.Context, qc *queryContext, resp *api.Response) error {
Expand Down Expand Up @@ -1175,6 +1179,10 @@ func (s *Server) doQuery(ctx context.Context, req *Request) (resp *api.Response,

var measurements []ostats.Measurement
ctx, span := otrace.StartSpan(ctx, methodRequest)
if ns, err := x.ExtractNamespace(ctx); err == nil {
annotateNamespace(span, ns)
}

ctx = x.WithMethod(ctx, methodRequest)
defer func() {
span.End()
Expand Down Expand Up @@ -1540,6 +1548,9 @@ func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.Tx
return &api.TxnContext{}, errors.Errorf(
"StartTs cannot be zero while committing a transaction")
}
if ns, err := x.ExtractJWTNamespace(ctx); err == nil {
annotateNamespace(span, ns)
}
annotateStartTs(span, tc.StartTs)

if err := validateNamespace(ctx, tc); err != nil {
Expand Down

0 comments on commit 9f0d378

Please sign in to comment.