Skip to content

Commit

Permalink
PS: Improve logging
Browse files Browse the repository at this point in the history
Print destination for remote requests
  • Loading branch information
lukedirtwalker committed Jan 3, 2019
1 parent 15bea85 commit 24ef8c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
9 changes: 4 additions & 5 deletions go/path_srv/internal/handlers/segreq.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/scionproto/scion/go/lib/revcache"
"github.com/scionproto/scion/go/lib/scrypto"
"github.com/scionproto/scion/go/lib/scrypto/trc"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/path_srv/internal/segutil"
"github.com/scionproto/scion/go/proto"
)
Expand Down Expand Up @@ -111,6 +110,8 @@ func (h *segReqHandler) fetchDownSegs(ctx context.Context, msger infra.Messenger
if err != nil {
return nil, err
}
logger := log.FromCtx(ctx)
logger.Debug("[segReqHandler] Fetch down segments", "dst", dst, "remote", cAddr)
if err = h.fetchAndSaveSegs(ctx, msger, addr.IA{}, dst, cAddr); err != nil {
return nil, err
}
Expand All @@ -124,9 +125,6 @@ func (h *segReqHandler) fetchAndSaveSegs(ctx context.Context, msger infra.Messen
logger := log.FromCtx(ctx)
queryTime := time.Now()
r := &path_mgmt.SegReq{RawSrcIA: src.IAInt(), RawDstIA: dst.IAInt()}
if snetAddr, ok := cPSAddr.(*snet.Addr); ok {
logger.Trace("[segReqHandler] Sending segment request", "NextHop", snetAddr.NextHop)
}
segs, err := h.getSegsFromNetwork(ctx, r, cPSAddr, messenger.NextId())
if err != nil {
return err
Expand Down Expand Up @@ -194,7 +192,8 @@ func (h *segReqHandler) sendReply(ctx context.Context, msger infra.Messenger,
if err != nil {
logger.Error("[segReqHandler] Failed to send reply!", "err", err)
}
logger.Debug("[segReqHandler] reply sent", "id", h.request.ID)
logger.Debug("[segReqHandler] reply sent", "id", h.request.ID,
"ups", len(upSegs), "cores", len(coreSegs), "downs", len(downSegs))
}

func (h *segReqHandler) collectSegs(upSegs, coreSegs, downSegs []*seg.PathSegment) []*seg.Meta {
Expand Down
3 changes: 1 addition & 2 deletions go/path_srv/internal/handlers/segreqnoncore.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package handlers

import (
"context"
"fmt"
"math/rand"
"net"
"time"
Expand Down Expand Up @@ -232,7 +231,6 @@ func (h *segReqNonCoreHandler) fetchCoreSegs(ctx context.Context,
msger infra.Messenger, src, dst addr.IA, dbOnly bool) ([]*seg.PathSegment, error) {

logger := log.FromCtx(ctx)
logger.Debug("[segReqHanlder:fetchCoreSegs]", "query", fmt.Sprintf("%v->%v", src, dst))
// try local cache first, inverse query since core segs are stored in inverse direction.
q := &query.Params{
SegTypes: []proto.PathSegType{proto.PathSegType_core},
Expand Down Expand Up @@ -260,6 +258,7 @@ func (h *segReqNonCoreHandler) fetchCoreSegs(ctx context.Context,
if err != nil {
return nil, err
}
logger.Debug("[segReqHandler] Request core segments", "src", src, "dst", dst, "remote", cPS)
if err = h.fetchAndSaveSegs(ctx, msger, src, dst, cPS); err != nil {
return nil, err
}
Expand Down

0 comments on commit 24ef8c8

Please sign in to comment.