Skip to content

Commit

Permalink
Use a histogram for end-to-end latency
Browse files Browse the repository at this point in the history
  • Loading branch information
mkuratczyk committed Feb 23, 2024
1 parent b2c348b commit dd27944
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pkg/amqp10_client/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/rabbitmq/omq/pkg/config"
"github.com/rabbitmq/omq/pkg/log"
"github.com/rabbitmq/omq/pkg/topic"
"github.com/rabbitmq/omq/pkg/utils"
"github.com/relvacode/iso8601"

"github.com/rabbitmq/omq/pkg/metrics"
Expand Down Expand Up @@ -73,8 +74,7 @@ func (c Amqp10Consumer) Start(ctx context.Context, subscribed chan bool) {
close(subscribed)
log.Debug("consumer subscribed", "protocol", "amqp-1.0", "consumerId", c.Id, "terminus", c.Topic, "durability", durability)

// TODO: disabled due to performance issues
// m := metrics.EndToEndLatency.With(prometheus.Labels{"protocol": "amqp-1.0"})
m := metrics.EndToEndLatency.With(prometheus.Labels{"protocol": "amqp-1.0"})

log.Info("consumer started", "protocol", "amqp-1.0", "consumerId", c.Id, "terminus", c.Topic)

Expand All @@ -91,7 +91,7 @@ func (c Amqp10Consumer) Start(ctx context.Context, subscribed chan bool) {
}

payload := msg.GetData()
// m.Observe(utils.CalculateEndToEndLatency(c.Config.UseMillis, &payload))
m.Observe(utils.CalculateEndToEndLatency(c.Config.UseMillis, &payload))

log.Debug("message received", "protocol", "amqp-1.0", "consumerId", c.Id, "terminus", c.Topic, "size", len(payload))

Expand Down
6 changes: 3 additions & 3 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
MessagesPublished *prometheus.CounterVec
MessagesConsumed *prometheus.CounterVec
PublishingLatency *prometheus.SummaryVec
EndToEndLatency *prometheus.SummaryVec
EndToEndLatency *prometheus.HistogramVec
)

func RegisterMetrics(globalLabels prometheus.Labels) {
Expand All @@ -58,10 +58,10 @@ func RegisterMetrics(globalLabels prometheus.Labels) {
}, []string{"protocol"})
}
if EndToEndLatency == nil {
EndToEndLatency = promauto.NewSummaryVec(prometheus.SummaryOpts{
EndToEndLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{
Name: "omq_end_to_end_latency_seconds",
Help: "Time from sending a message to receiving the message",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.95: 0.005, 0.99: 0.001},
Buckets: []float64{.001, .002, .003, .004, .005, .006, .007, 0.008, .009, 0.01, 0.025, 0.05, 0.1, 0.5, 1, 2, 3, 4, 5, 10, 20, 30, 60},
ConstLabels: globalLabels,
}, []string{"protocol"})
}
Expand Down

0 comments on commit dd27944

Please sign in to comment.