Skip to content

Commit

Permalink
Add hyper add metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Feb 27, 2019
1 parent 0541fec commit 4b0c2ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions balloon/hyper/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"sync"

"github.com/bbva/qed/log"
"github.com/bbva/qed/metrics"

"github.com/bbva/qed/balloon/cache"
"github.com/bbva/qed/hashing"
Expand Down Expand Up @@ -75,6 +76,9 @@ func (t *HyperTree) Add(eventDigest hashing.Digest, version uint64) (hashing.Dig
t.Lock()
defer t.Unlock()

// metrics
metrics.QedHyperAddTotal.Inc()

//log.Debugf("Adding new event digest %x with version %d", eventDigest, version)

versionAsBytes := util.Uint64AsBytes(version)
Expand Down
10 changes: 9 additions & 1 deletion balloon/hyper/tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ package hyper

import (
"encoding/binary"
"net/http"
"testing"

"github.com/bbva/qed/balloon/cache"
"github.com/bbva/qed/hashing"
"github.com/bbva/qed/log"
"github.com/bbva/qed/metrics"
"github.com/bbva/qed/storage"
"github.com/bbva/qed/testutils/rand"
storage_utils "github.com/bbva/qed/testutils/storage"
"github.com/bbva/qed/util"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -294,8 +298,12 @@ func BenchmarkAdd(b *testing.B) {

tree := NewHyperTree(hashing.NewSha256Hasher, store, freeCache)

prometheus.MustRegister(metrics.QedHyperAddTotal)
http.Handle("/metrics", promhttp.Handler())
go http.ListenAndServe(":2112", nil)

b.ResetTimer()
b.N = 100000
b.N = 200000000
for i := 0; i < b.N; i++ {
index := make([]byte, 8)
binary.LittleEndian.PutUint64(index, uint64(i))
Expand Down
13 changes: 12 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
},
)

// BALLOON
Qed_balloon_add_duration_seconds = prometheus.NewSummary(
prometheus.SummaryOpts{
Name: "qed_balloon_add_duration_seconds",
Expand Down Expand Up @@ -106,7 +107,15 @@ var (
},
)

// Sender
// HYPER TREE
QedHyperAddTotal = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "qed_hyper_add_total",
Help: "Number of the events added to the hyper tree.",
},
)

// SENDER
Qed_sender_instances_count = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "qed_sender_instances_count",
Expand Down Expand Up @@ -148,6 +157,8 @@ var (
Qed_instances_count,
Qed_api_healthcheck_requests_total,

QedHyperAddTotal,

Qed_balloon_add_duration_seconds,
Qed_balloon_membership_duration_seconds,
Qed_balloon_digest_membership_duration_seconds,
Expand Down

0 comments on commit 4b0c2ab

Please sign in to comment.