Skip to content

Commit

Permalink
Track auth messages in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq committed Nov 21, 2023
1 parent 149291e commit ee05c1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions service/domain/relays/relay_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func (r *RelayConnection) handleMessage(messageBytes []byte) (err error) {
r.logger.
Trace().
WithField("subscription", string(*v)).
Message("received EOSE")
Message("received a message (EOSE)")

subscriptionID, err := transport.NewSubscriptionID(string(*v))
if err != nil {
Expand All @@ -233,7 +233,7 @@ func (r *RelayConnection) handleMessage(messageBytes []byte) (err error) {
r.logger.
Trace().
WithField("subscription", *v.SubscriptionID).
Message("received event")
Message("received a message (event)")

subscriptionID, err := transport.NewSubscriptionID(*v.SubscriptionID)
if err != nil {
Expand All @@ -252,7 +252,14 @@ func (r *RelayConnection) handleMessage(messageBytes []byte) (err error) {
r.logger.
Debug().
WithField("message", string(messageBytes)).
Message("received a notice")
Message("received a message (notice)")
return nil
case *nostr.AuthEnvelope:
defer r.metrics.ReportMessageReceived(r.address, MessageTypeAuth, &err)
r.logger.
Debug().
WithField("message", string(messageBytes)).
Message("received a message (auth)")
return nil
default:
defer r.metrics.ReportMessageReceived(r.address, MessageTypeUnknown, &err)
Expand Down
1 change: 1 addition & 0 deletions service/domain/relays/relay_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
MessageTypeNotice = MessageType{"notice"}
MessageTypeEOSE = MessageType{"eose"}
MessageTypeEvent = MessageType{"event"}
MessageTypeAuth = MessageType{"auth"}
MessageTypeUnknown = MessageType{"unknown"}
)

Expand Down

0 comments on commit ee05c1a

Please sign in to comment.