Commit 3462ee91 authored by Esad Akar's avatar Esad Akar Committed by GitHub

pss: mining metric (#1509)

parent 5be87619
......@@ -11,6 +11,7 @@ import (
type metrics struct {
TotalMessagesSentCounter prometheus.Counter
MessageMiningDuration prometheus.Gauge
}
func newMetrics() metrics {
......@@ -23,6 +24,12 @@ func newMetrics() metrics {
Name: "total_message_sent",
Help: "Total messages sent.",
}),
MessageMiningDuration: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mining_duration",
Help: "Time duration to mine a message.",
}),
}
}
......
......@@ -15,6 +15,7 @@ import (
"errors"
"io"
"sync"
"time"
"github.com/ethersphere/bee/pkg/logging"
"github.com/ethersphere/bee/pkg/pushsync"
......@@ -86,11 +87,15 @@ type Handler func(context.Context, []byte)
func (p *pss) Send(ctx context.Context, topic Topic, payload []byte, recipient *ecdsa.PublicKey, targets Targets) error {
p.metrics.TotalMessagesSentCounter.Inc()
tStart := time.Now()
tc, err := Wrap(ctx, topic, payload, recipient, targets)
if err != nil {
return err
}
p.metrics.MessageMiningDuration.Set(time.Since(tStart).Seconds())
// push the chunk using push sync so that it reaches it destination in network
if _, err = p.pusher.PushChunkToClosest(ctx, tc); err != nil {
return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment