From 0d9e19f3b70314a84dbf34435cab47f09395c8bf Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:51:59 -0400 Subject: [PATCH] Add more logging to publish path --- pkg/api/interceptor.go | 4 ++-- pkg/api/message/v1/service.go | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/api/interceptor.go b/pkg/api/interceptor.go index 81d7c2d3..3c30d59f 100644 --- a/pkg/api/interceptor.go +++ b/pkg/api/interceptor.go @@ -158,7 +158,7 @@ func (wa *WalletAuthorizer) applyLimits(ctx context.Context, fullMethod string, // * for other authorization failure return status.Errorf(codes.PermissionDenied, ...) _, method := splitMethodName(fullMethod) - ip := clientIPFromContext(ctx) + ip := ClientIPFromContext(ctx) if len(ip) == 0 { // requests without an IP address are bucketed together as "ip_unknown" ip = "ip_unknown" @@ -248,7 +248,7 @@ func allowedToPublish(topic string, wallet types.WalletAddr) bool { return true } -func clientIPFromContext(ctx context.Context) string { +func ClientIPFromContext(ctx context.Context) string { md, _ := metadata.FromIncomingContext(ctx) vals := md.Get("x-forwarded-for") if len(vals) == 0 { diff --git a/pkg/api/message/v1/service.go b/pkg/api/message/v1/service.go index 509737e7..b52e951c 100644 --- a/pkg/api/message/v1/service.go +++ b/pkg/api/message/v1/service.go @@ -17,6 +17,7 @@ import ( wakupb "github.com/status-im/go-waku/waku/v2/protocol/pb" wakurelay "github.com/status-im/go-waku/waku/v2/protocol/relay" proto "github.com/xmtp/proto/v3/go/message_api/v1" + api "github.com/xmtp/xmtp-node-go/pkg/api" apicontext "github.com/xmtp/xmtp-node-go/pkg/api/message/v1/context" "github.com/xmtp/xmtp-node-go/pkg/logging" "github.com/xmtp/xmtp-node-go/pkg/metrics" @@ -139,7 +140,7 @@ func (s *Service) Close() { func (s *Service) Publish(ctx context.Context, req *proto.PublishRequest) (*proto.PublishResponse, error) { for _, env := range req.Envelopes { log := s.log.Named("publish").With(zap.String("content_topic", env.ContentTopic)) - log.Debug("received message") + log.Info("received message", zap.String("client_ip", api.ClientIPFromContext(ctx))) if len(env.ContentTopic) > MaxContentTopicNameSize { return nil, status.Errorf(codes.InvalidArgument, "topic length too big")