Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Pass original context to trace volume create steps across grpc nodes.
Browse files Browse the repository at this point in the history
Pass the original context to the runStepOn() function so that it can be
used by the opensensus grpc plugin to trace the calls on other nodes in
the gluster cluster. Also, append the requestID to the span info in
addition to the associated function name so that the operation can be
identified on the tracing UI application.

Signed-off-by: Sridhar Seshasayee <sseshasa@redhat.com>
  • Loading branch information
sseshasa authored and kshlm committed Aug 8, 2018
1 parent b51f725 commit 065fe80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions glusterd2/transaction/rpc-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

// runStepOn will run the step on the specified node
func runStepOn(step string, node uuid.UUID, c TxnCtx) error {
func runStepOn(origCtx netctx.Context, step string, node uuid.UUID, c TxnCtx) error {
// TODO: I'm creating connections on demand. This should be changed so that
// we have long term connections.
p, err := peer.GetPeerF(node.String())
Expand Down Expand Up @@ -73,7 +73,7 @@ func runStepOn(step string, node uuid.UUID, c TxnCtx) error {

var rsp *TxnStepResp

rsp, err = client.RunStep(netctx.TODO(), req)
rsp, err = client.RunStep(origCtx, req)
if err != nil {
logger.WithFields(log.Fields{
"error": err,
Expand Down
8 changes: 8 additions & 0 deletions glusterd2/transaction/rpc-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/gluster/glusterd2/glusterd2/servers/peerrpc"

log "github.com/sirupsen/logrus"
"go.opencensus.io/trace"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
Expand Down Expand Up @@ -37,6 +38,13 @@ func (p *txnSvc) RunStep(rpcCtx context.Context, req *TxnStepReq) (*TxnStepResp,
logger = ctx.Logger().WithField("stepfunc", req.StepFunc)
logger.Debug("RunStep request received")

if rpcCtx != nil {
reqID := ctx.GetTxnReqID()
spanName := req.StepFunc + " ReqID:" + reqID
_, span := trace.StartSpan(rpcCtx, spanName)
defer span.End()
}

f, ok = getStepFunc(req.StepFunc)
if !ok {
err = errors.New("step function not found in registry")
Expand Down
2 changes: 1 addition & 1 deletion glusterd2/transaction/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func runStepFuncOnNode(origCtx context.Context, stepName string, ctx TxnCtx, nod
err = runStepFuncLocally(origCtx, stepName, ctx)
} else {
// remote node
err = runStepOn(stepName, node, ctx)
err = runStepOn(origCtx, stepName, node, ctx)
}

respCh <- stepPeerResp{node, err}
Expand Down

0 comments on commit 065fe80

Please sign in to comment.