Skip to content

Commit

Permalink
Fix latency metrics, seconds -> nanoseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
HannahMarsh committed Oct 11, 2024
1 parent 51d0c81 commit f714069
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
34 changes: 17 additions & 17 deletions internal/model/bulletin_board/metrics/prometheus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,65 +3,65 @@ global:
external_labels:
monitor: pi_t
scrape_configs:
- job_name: client-1
scrape_interval: 5s
static_configs:
- targets:
- localhost:61073
- job_name: client-2
scrape_interval: 5s
static_configs:
- targets:
- localhost:61079
- localhost:62174
- job_name: client-3
scrape_interval: 5s
static_configs:
- targets:
- localhost:61084
- localhost:62183
- job_name: client-4
scrape_interval: 5s
static_configs:
- targets:
- localhost:61092
- localhost:62188
- job_name: client-5
scrape_interval: 5s
static_configs:
- targets:
- localhost:61097
- localhost:62194
- job_name: client-6
scrape_interval: 5s
static_configs:
- targets:
- localhost:61102
- job_name: relay-1
- localhost:62199
- job_name: client-1
scrape_interval: 5s
static_configs:
- targets:
- localhost:61107
- localhost:62161
- job_name: relay-2
scrape_interval: 5s
static_configs:
- targets:
- localhost:61112
- localhost:62209
- job_name: relay-3
scrape_interval: 5s
static_configs:
- targets:
- localhost:61117
- localhost:62214
- job_name: relay-4
scrape_interval: 5s
static_configs:
- targets:
- localhost:61125
- localhost:62219
- job_name: relay-5
scrape_interval: 5s
static_configs:
- targets:
- localhost:61130
- localhost:62224
- job_name: relay-6
scrape_interval: 5s
static_configs:
- targets:
- localhost:61135
- localhost:62232
- job_name: relay-1
scrape_interval: 5s
static_configs:
- targets:
- localhost:62204
rule_files:
- /Users/hanma/Documents/GitHub/pi_t-experiment/internal/model/bulletin_board/metrics/rules.yml
12 changes: 6 additions & 6 deletions internal/model/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,21 +361,21 @@ func (c *Client) startRun(start structs.ClientStartRunApi) error {

slog.Info("Client sending onions", "num_onions", numToSend)

var wg sync.WaitGroup // WaitGroup to manage concurrent sending of onions.
wg.Add(numToSend)
//var wg sync.WaitGroup // WaitGroup to manage concurrent sending of onions.
//wg.Add(numToSend)
for _, onion := range toSend {
go func(onion queuedOnion) {
defer wg.Done()
//defer wg.Done()
timeSent := time.Now()
if err = api_functions.SendOnion(onion.to, c.Address, onion.onion, 0); err != nil {
slog.Error("failed to send onions", err)
}
metrics.Set(metrics.MSG_SENT, float64(timeSent.Unix()), onion.msg.Hash) // Record the time when the onion was sent.
metrics.Set(metrics.MSG_SENT, float64(timeSent.Nanosecond()), onion.msg.Hash) // Record the time when the onion was sent.

}(onion)
}

wg.Wait() // Wait for all onions to be sent.
//wg.Wait() // Wait for all onions to be sent.

//c.Messages = make([]structs.Message, 0) // Clear the client's messages after sending.
return nil
Expand All @@ -398,7 +398,7 @@ func (c *Client) Receive(oApi structs.OnionApi) error {

// Record the received message in the client's status.
c.status.AddReceived(msg)
metrics.Set(metrics.MSG_RECEIVED, float64(timeReceived.Unix()), msg.Hash) // Record the time when the message was received.
metrics.Set(metrics.MSG_RECEIVED, float64(timeReceived.Nanosecond()), msg.Hash) // Record the time when the message was received.

return nil
}
Expand Down

0 comments on commit f714069

Please sign in to comment.