Skip to content

Commit

Permalink
feat_: log status version in all telemetry calls
Browse files Browse the repository at this point in the history
  • Loading branch information
adklempner committed Jun 12, 2024
1 parent 145d139 commit e514242
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/status-cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func start(name string, port int, apiModules string, telemetryUrl string, useExi
}

if telemetryUrl != "" {
telemetryClient := telemetry.NewClient(nlog.Desugar(), telemetryUrl, backend.SelectedAccountKeyID(), name)
telemetryClient := telemetry.NewClient(nlog.Desugar(), telemetryUrl, backend.SelectedAccountKeyID(), name, "cli")
backend.StatusNode().WakuV2Service().SetStatusTelemetryClient(telemetryClient)
}
wakuAPI := wakuv2ext.NewPublicAPI(wakuService)
Expand Down
3 changes: 2 additions & 1 deletion protocol/messenger.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func NewMessenger(
node types.Node,
installationID string,
peerStore *mailservers.PeerStore,
version string,
opts ...Option,
) (*Messenger, error) {
var messenger *Messenger
Expand Down Expand Up @@ -428,7 +429,7 @@ func NewMessenger(

var telemetryClient *telemetry.Client
if c.telemetryServerURL != "" {
telemetryClient = telemetry.NewClient(logger, c.telemetryServerURL, c.account.KeyUID, nodeName)
telemetryClient = telemetry.NewClient(logger, c.telemetryServerURL, c.account.KeyUID, nodeName, version)
if c.wakuService != nil {
c.wakuService.SetStatusTelemetryClient(telemetryClient)
}
Expand Down
1 change: 1 addition & 0 deletions protocol/messenger_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func newTestMessenger(waku types.Waku, config testMessengerConfig) (*Messenger,
&testNode{shh: waku},
uuid.New().String(),
nil,
"testVersion",
options...,
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions services/ext/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func (s *Service) InitProtocol(nodeName string, identity *ecdsa.PrivateKey, appD
s.n,
s.config.ShhextConfig.InstallationID,
s.peerStore,
params.Version,
options...,
)
if err != nil {
Expand Down
7 changes: 6 additions & 1 deletion telemetry/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ type Client struct {
logger *zap.Logger
keyUID string
nodeName string
version string
}

func NewClient(logger *zap.Logger, serverURL string, keyUID string, nodeName string) *Client {
func NewClient(logger *zap.Logger, serverURL string, keyUID string, nodeName string, version string) *Client {
return &Client{
serverURL: serverURL,
httpClient: &http.Client{Timeout: time.Minute},
logger: logger,
keyUID: keyUID,
nodeName: nodeName,
version: version,
}
}

Expand All @@ -51,6 +53,7 @@ func (c *Client) PushReceivedMessages(filter transport.Filter, sshMessage *types
"receiverKeyUID": c.keyUID,
"nodeName": c.nodeName,
"messageSize": len(sshMessage.Payload),
"statusVersion": c.version,
})
}
body, _ := json.Marshal(postBody)
Expand All @@ -71,6 +74,7 @@ func (c *Client) PushReceivedEnvelope(envelope *v2protocol.Envelope) {
"topic": envelope.Message().ContentTopic,
"receiverKeyUID": c.keyUID,
"nodeName": c.nodeName,
"statusVersion": c.version,
}
body, _ := json.Marshal(postBody)
_, err := c.httpClient.Post(url, "application/json", bytes.NewBuffer(body))
Expand All @@ -91,6 +95,7 @@ func (c *Client) PushSentEnvelope(envelope *v2protocol.Envelope, publishMethod w
"senderKeyUID": c.keyUID,
"nodeName": c.nodeName,
"publishMethod": publishMethod.String(),
"statusVersion": c.version,
}
body, _ := json.Marshal(postBody)
_, err := c.httpClient.Post(url, "application/json", bytes.NewBuffer(body))
Expand Down

0 comments on commit e514242

Please sign in to comment.