Skip to content
Snippets Groups Projects
Commit 15037876 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Add reports to sendCmix

parent 72a1e554
No related branches found
No related tags found
3 merge requests!23Release,!13Hotfix/no host cooldown + return sende2e TS,!11Client Event Reporting API
...@@ -97,6 +97,7 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard, ...@@ -97,6 +97,7 @@ func NewManager(session *storage.Session, switchboard *switchboard.Switchboard,
Instance: instance, Instance: instance,
TransmissionID: session.User().GetCryptographicIdentity().GetTransmissionID(), TransmissionID: session.User().GetCryptographicIdentity().GetTransmissionID(),
ReceptionID: session.User().GetCryptographicIdentity().GetReceptionID(), ReceptionID: session.User().GetCryptographicIdentity().GetReceptionID(),
Events: events,
} }
// Set up gateway.Sender // Set up gateway.Sender
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
package message package message
import ( import (
"fmt"
"github.com/golang-collections/collections/set" "github.com/golang-collections/collections/set"
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman" jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces"
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/network/gateway" "gitlab.com/elixxir/client/network/gateway"
"gitlab.com/elixxir/client/stoppable" "gitlab.com/elixxir/client/stoppable"
...@@ -32,7 +34,8 @@ func (m *Manager) SendCMIX(sender *gateway.Sender, msg format.Message, ...@@ -32,7 +34,8 @@ func (m *Manager) SendCMIX(sender *gateway.Sender, msg format.Message,
recipient *id.ID, param params.CMIX, stop *stoppable.Single) (id.Round, ephemeral.Id, error) { recipient *id.ID, param params.CMIX, stop *stoppable.Single) (id.Round, ephemeral.Id, error) {
msgCopy := msg.Copy() msgCopy := msg.Copy()
return sendCmixHelper(sender, msgCopy, recipient, param, m.Instance, return sendCmixHelper(sender, msgCopy, recipient, param, m.Instance,
m.Session, m.nodeRegistration, m.Rng, m.TransmissionID, m.Comms, stop) m.Session, m.nodeRegistration, m.Rng, m.Internal.Events,
m.TransmissionID, m.Comms, stop)
} }
// Helper function for sendCmix // Helper function for sendCmix
...@@ -47,7 +50,8 @@ func (m *Manager) SendCMIX(sender *gateway.Sender, msg format.Message, ...@@ -47,7 +50,8 @@ func (m *Manager) SendCMIX(sender *gateway.Sender, msg format.Message,
func sendCmixHelper(sender *gateway.Sender, msg format.Message, func sendCmixHelper(sender *gateway.Sender, msg format.Message,
recipient *id.ID, cmixParams params.CMIX, instance *network.Instance, recipient *id.ID, cmixParams params.CMIX, instance *network.Instance,
session *storage.Session, nodeRegistration chan network.NodeGateway, session *storage.Session, nodeRegistration chan network.NodeGateway,
rng *fastRNG.StreamGenerator, senderId *id.ID, comms sendCmixCommsInterface, rng *fastRNG.StreamGenerator, events interfaces.EventManager,
senderId *id.ID, comms sendCmixCommsInterface,
stop *stoppable.Single) (id.Round, ephemeral.Id, error) { stop *stoppable.Single) (id.Round, ephemeral.Id, error) {
timeStart := netTime.Now() timeStart := netTime.Now()
...@@ -144,8 +148,13 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message, ...@@ -144,8 +148,13 @@ func sendCmixHelper(sender *gateway.Sender, msg format.Message,
// Return if it sends properly // Return if it sends properly
gwSlotResp := result.(*pb.GatewaySlotResponse) gwSlotResp := result.(*pb.GatewaySlotResponse)
if gwSlotResp.Accepted { if gwSlotResp.Accepted {
jww.INFO.Printf("Successfully sent to EphID %v (source: %s) "+ m := fmt.Sprintf("Successfully sent to EphID %v "+
"in round %d (msgDigest: %s)", ephID.Int64(), recipient, bestRound.ID, msg.Digest()) "(source: %s) in round %d (msgDigest: %s), "+
"elapsed: %s numRoundTries: %d", ephID.Int64(),
recipient, bestRound.ID, msg.Digest(),
elapsed, numRoundTries)
jww.INFO.Print(m)
events.Report(1, "MessageSend", "Metric", m)
return id.Round(bestRound.ID), ephID, nil return id.Round(bestRound.ID), ephID, nil
} else { } else {
jww.FATAL.Panicf("Gateway %s returned no error, but failed "+ jww.FATAL.Panicf("Gateway %s returned no error, but failed "+
......
...@@ -26,12 +26,18 @@ import ( ...@@ -26,12 +26,18 @@ import (
"time" "time"
) )
type dummyEvent struct{}
func (e *dummyEvent) Report(priority int, category, evtType, details string) {}
// Unit test // Unit test
func Test_attemptSendCmix(t *testing.T) { func Test_attemptSendCmix(t *testing.T) {
sess1 := storage.InitTestingSession(t) sess1 := storage.InitTestingSession(t)
sess2 := storage.InitTestingSession(t) sess2 := storage.InitTestingSession(t)
events := &dummyEvent{}
sw := switchboard.New() sw := switchboard.New()
l := TestListener{ l := TestListener{
ch: make(chan bool), ch: make(chan bool),
...@@ -113,7 +119,7 @@ func Test_attemptSendCmix(t *testing.T) { ...@@ -113,7 +119,7 @@ func Test_attemptSendCmix(t *testing.T) {
e2e.SetUnencrypted(msgCmix, m.Session.User().GetCryptographicIdentity().GetTransmissionID()) e2e.SetUnencrypted(msgCmix, m.Session.User().GetCryptographicIdentity().GetTransmissionID())
_, _, err = sendCmixHelper(sender, msgCmix, sess2.GetUser().ReceptionID, _, _, err = sendCmixHelper(sender, msgCmix, sess2.GetUser().ReceptionID,
params.GetDefaultCMIX(), m.Instance, m.Session, m.nodeRegistration, params.GetDefaultCMIX(), m.Instance, m.Session, m.nodeRegistration,
m.Rng, m.TransmissionID, &MockSendCMIXComms{t: t}, nil) m.Rng, events, m.TransmissionID, &MockSendCMIXComms{t: t}, nil)
if err != nil { if err != nil {
t.Errorf("Failed to sendcmix: %+v", err) t.Errorf("Failed to sendcmix: %+v", err)
panic("t") panic("t")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment