Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release/v21.03-slash: chore(tracing): Add ns attribute to doQuery (#7850) #7853

Merged
merged 1 commit into from
May 25, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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