Skip to content

Commit b80efb6

Browse files
authored
chore(tracing): Add ns attribute to doQuery (#7850)
1 parent 5595f9c commit b80efb6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Diff for: edgraph/server.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,12 @@ func validateDQLSchemaForGraphQL(ctx context.Context,
693693
return nil
694694
}
695695

696+
func annotateNamespace(span *otrace.Span, ns uint64) {
697+
span.AddAttributes(otrace.Int64Attribute("ns", int64(ns)))
698+
}
699+
696700
func annotateStartTs(span *otrace.Span, ts uint64) {
697-
span.Annotate([]otrace.Attribute{otrace.Int64Attribute("startTs", int64(ts))}, "")
701+
span.AddAttributes(otrace.Int64Attribute("startTs", int64(ts)))
698702
}
699703

700704
func (s *Server) doMutate(ctx context.Context, qc *queryContext, resp *api.Response) error {
@@ -1331,6 +1335,10 @@ func (s *Server) doQuery(ctx context.Context, req *Request) (
13311335

13321336
var measurements []ostats.Measurement
13331337
ctx, span := otrace.StartSpan(ctx, methodRequest)
1338+
if ns, err := x.ExtractNamespace(ctx); err == nil {
1339+
annotateNamespace(span, ns)
1340+
}
1341+
13341342
ctx = x.WithMethod(ctx, methodRequest)
13351343
defer func() {
13361344
span.End()
@@ -1691,6 +1699,9 @@ func (s *Server) CommitOrAbort(ctx context.Context, tc *api.TxnContext) (*api.Tx
16911699
return &api.TxnContext{}, errors.Errorf(
16921700
"StartTs cannot be zero while committing a transaction")
16931701
}
1702+
if ns, err := x.ExtractJWTNamespace(ctx); err == nil {
1703+
annotateNamespace(span, ns)
1704+
}
16941705
annotateStartTs(span, tc.StartTs)
16951706

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

0 commit comments

Comments
 (0)