Skip to content

Commit

Permalink
Add more logging to publish path
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas committed Sep 18, 2023
1 parent 4da3cff commit 0d9e19f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pkg/api/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/message/v1/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 0d9e19f

Please sign in to comment.