grpc: remove peer field from logs (#2712)

This commit is contained in:
Caleb Doxsey 2021-10-26 14:43:59 -06:00 committed by GitHub
parent 62d6ce8507
commit b2c76c3816
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 19 deletions

View file

@ -21,7 +21,6 @@ import (
"github.com/pomerium/pomerium/internal/telemetry/trace" "github.com/pomerium/pomerium/internal/telemetry/trace"
"github.com/pomerium/pomerium/pkg/cryptutil" "github.com/pomerium/pomerium/pkg/cryptutil"
"github.com/pomerium/pomerium/pkg/grpc/databroker" "github.com/pomerium/pomerium/pkg/grpc/databroker"
"github.com/pomerium/pomerium/pkg/grpcutil"
"github.com/pomerium/pomerium/pkg/storage" "github.com/pomerium/pomerium/pkg/storage"
"github.com/pomerium/pomerium/pkg/storage/inmemory" "github.com/pomerium/pomerium/pkg/storage/inmemory"
"github.com/pomerium/pomerium/pkg/storage/redis" "github.com/pomerium/pomerium/pkg/storage/redis"
@ -79,7 +78,6 @@ func (srv *Server) AcquireLease(ctx context.Context, req *databroker.AcquireLeas
_, span := trace.StartSpan(ctx, "databroker.grpc.AcquireLease") _, span := trace.StartSpan(ctx, "databroker.grpc.AcquireLease")
defer span.End() defer span.End()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("name", req.GetName()). Str("name", req.GetName()).
Dur("duration", req.GetDuration().AsDuration()). Dur("duration", req.GetDuration().AsDuration()).
Msg("acquire lease") Msg("acquire lease")
@ -107,7 +105,6 @@ func (srv *Server) Get(ctx context.Context, req *databroker.GetRequest) (*databr
_, span := trace.StartSpan(ctx, "databroker.grpc.Get") _, span := trace.StartSpan(ctx, "databroker.grpc.Get")
defer span.End() defer span.End()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("type", req.GetType()). Str("type", req.GetType()).
Str("id", req.GetId()). Str("id", req.GetId()).
Msg("get") Msg("get")
@ -135,7 +132,6 @@ func (srv *Server) Query(ctx context.Context, req *databroker.QueryRequest) (*da
_, span := trace.StartSpan(ctx, "databroker.grpc.Query") _, span := trace.StartSpan(ctx, "databroker.grpc.Query")
defer span.End() defer span.End()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("type", req.GetType()). Str("type", req.GetType()).
Str("query", req.GetQuery()). Str("query", req.GetQuery()).
Int64("offset", req.GetOffset()). Int64("offset", req.GetOffset()).
@ -179,7 +175,6 @@ func (srv *Server) Put(ctx context.Context, req *databroker.PutRequest) (*databr
record := req.GetRecord() record := req.GetRecord()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("type", record.GetType()). Str("type", record.GetType()).
Str("id", record.GetId()). Str("id", record.GetId()).
Msg("put") Msg("put")
@ -204,7 +199,6 @@ func (srv *Server) ReleaseLease(ctx context.Context, req *databroker.ReleaseLeas
_, span := trace.StartSpan(ctx, "databroker.grpc.ReleaseLease") _, span := trace.StartSpan(ctx, "databroker.grpc.ReleaseLease")
defer span.End() defer span.End()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("name", req.GetName()). Str("name", req.GetName()).
Str("id", req.GetId()). Str("id", req.GetId()).
Msg("release lease") Msg("release lease")
@ -227,7 +221,6 @@ func (srv *Server) RenewLease(ctx context.Context, req *databroker.RenewLeaseReq
_, span := trace.StartSpan(ctx, "databroker.grpc.RenewLease") _, span := trace.StartSpan(ctx, "databroker.grpc.RenewLease")
defer span.End() defer span.End()
log.Debug(ctx). log.Debug(ctx).
Str("peer", grpcutil.GetPeerAddr(ctx)).
Str("name", req.GetName()). Str("name", req.GetName()).
Str("id", req.GetId()). Str("id", req.GetId()).
Dur("duration", req.GetDuration().AsDuration()). Dur("duration", req.GetDuration().AsDuration()).
@ -280,7 +273,6 @@ func (srv *Server) Sync(req *databroker.SyncRequest, stream databroker.DataBroke
defer cancel() defer cancel()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(stream.Context())).
Uint64("server_version", req.GetServerVersion()). Uint64("server_version", req.GetServerVersion()).
Uint64("record_version", req.GetRecordVersion()). Uint64("record_version", req.GetRecordVersion()).
Msg("sync") Msg("sync")
@ -318,7 +310,6 @@ func (srv *Server) SyncLatest(req *databroker.SyncLatestRequest, stream databrok
defer cancel() defer cancel()
log.Info(ctx). log.Info(ctx).
Str("peer", grpcutil.GetPeerAddr(stream.Context())).
Str("type", req.GetType()). Str("type", req.GetType()).
Msg("sync latest") Msg("sync latest")

View file

@ -5,7 +5,6 @@ import (
"context" "context"
"google.golang.org/grpc/metadata" "google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
@ -55,15 +54,6 @@ func JWTFromGRPCRequest(ctx context.Context) (rawjwt string, ok bool) {
return rawjwts[0], true return rawjwts[0], true
} }
// GetPeerAddr returns the peer address.
func GetPeerAddr(ctx context.Context) string {
p, ok := peer.FromContext(ctx)
if ok {
return p.Addr.String()
}
return ""
}
// GetTypeURL gets the TypeURL for a protobuf message. // GetTypeURL gets the TypeURL for a protobuf message.
func GetTypeURL(msg proto.Message) string { func GetTypeURL(msg proto.Message) string {
// taken from the anypb package // taken from the anypb package