Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
clD11 committed Dec 13, 2023
1 parent c64206a commit afa9189
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions libs/clients/radom/instrumented.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/brave-intl/bat-go/libs/logging"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)

type InstrumentedClient struct {
Expand All @@ -16,17 +16,22 @@ type InstrumentedClient struct {

// newInstrucmentedClient returns an instance of the Client decorated with prometheus summary metric.
func newInstrucmentedClient(name string, cl *Client) *InstrumentedClient {
v := prometheus.NewSummaryVec(prometheus.SummaryOpts{
Name: "client_duration_seconds",
Help: "client runtime duration and result",
MaxAge: time.Minute,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"instance_name", "method", "result"},
)
if err := prometheus.Register(v); err != nil {
logging.FromContext(context.Background()).Err(err).Msg("radom metric")
}

result := &InstrumentedClient{
name: name,
cl: cl,
vec: promauto.NewSummaryVec(prometheus.SummaryOpts{
Name: "client_duration_seconds",
Help: "client runtime duration and result",
MaxAge: time.Minute,
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"instance_name", "method", "result"},
),
vec: v,
}

return result
Expand Down

0 comments on commit afa9189

Please sign in to comment.