Skip to content

Commit

Permalink
xdsclient: indicate authority serverURI in authority + transport logs (
Browse files Browse the repository at this point in the history
  • Loading branch information
arvindbr8 authored Jun 30, 2023
1 parent 67e881c commit ea492f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion xds/internal/xdsclient/clientimpl_authority.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"

"google.golang.org/grpc/internal/grpclog"
"google.golang.org/grpc/xds/internal/xdsclient/bootstrap"
"google.golang.org/grpc/xds/internal/xdsclient/xdsresource"
)
Expand Down Expand Up @@ -109,7 +110,7 @@ func (c *clientImpl) newAuthorityLocked(config *bootstrap.ServerConfig) (_ *auth
serializer: c.serializer,
resourceTypeGetter: c.resourceTypes.get,
watchExpiryTimeout: c.watchExpiryTimeout,
logger: c.logger,
logger: grpclog.NewPrefixLogger(logger, authorityPrefix(c, config.ServerURI)),
})
if err != nil {
return nil, fmt.Errorf("creating new authority for config %q: %v", config.String(), err)
Expand Down
12 changes: 9 additions & 3 deletions xds/internal/xdsclient/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,16 @@ import (
internalgrpclog "google.golang.org/grpc/internal/grpclog"
)

const prefix = "[xds-client %p] "

var logger = grpclog.Component("xds")

func prefixLogger(p *clientImpl) *internalgrpclog.PrefixLogger {
return internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(prefix, p))
return internalgrpclog.NewPrefixLogger(logger, clientPrefix(p))
}

func clientPrefix(p *clientImpl) string {
return fmt.Sprintf("[xds-client %p] ", p)
}

func authorityPrefix(p *clientImpl, serverURI string) string {
return fmt.Sprintf("%s[%s] ", clientPrefix(p), serverURI)
}

0 comments on commit ea492f5

Please sign in to comment.