Skip to content

Commit

Permalink
use float histogram and seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Oct 24, 2023
1 parent 1fc016d commit c917928
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions p2p/server_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ const headersServedKey = "num_headers_served"

type serverMetrics struct {
headersServedInst metric.Int64Counter
headServeTimeInst metric.Int64Histogram
rangeServeTimeInst metric.Int64Histogram
getServeTimeInst metric.Int64Histogram
headServeTimeInst metric.Float64Histogram
rangeServeTimeInst metric.Float64Histogram
getServeTimeInst metric.Float64Histogram
}

func newServerMetrics() (m *serverMetrics, err error) {
Expand All @@ -26,23 +26,23 @@ func newServerMetrics() (m *serverMetrics, err error) {
if err != nil {
return nil, err
}
m.headServeTimeInst, err = meter.Int64Histogram(
m.headServeTimeInst, err = meter.Float64Histogram(
"hdr_p2p_exch_srvr_head_serve_time_hist",
metric.WithDescription("exchange server head serve time in milliseconds"),
metric.WithDescription("exchange server head serve time in seconds"),
)
if err != nil {
return nil, err
}
m.rangeServeTimeInst, err = meter.Int64Histogram(
m.rangeServeTimeInst, err = meter.Float64Histogram(
"hdr_p2p_exch_srvr_range_serve_time_hist",
metric.WithDescription("exchange server range serve time in milliseconds"),
metric.WithDescription("exchange server range serve time in seconds"),
)
if err != nil {
return nil, err
}
m.getServeTimeInst, err = meter.Int64Histogram(
m.getServeTimeInst, err = meter.Float64Histogram(
"hdr_p2p_exch_srvr_get_serve_time_hist",
metric.WithDescription("exchange server get serve time in milliseconds"),
metric.WithDescription("exchange server get serve time in seconds"),
)
if err != nil {
return nil, err
Expand All @@ -53,15 +53,15 @@ func newServerMetrics() (m *serverMetrics, err error) {
func (m *serverMetrics) headServed(ctx context.Context, duration time.Duration) {
m.observe(ctx, func(ctx context.Context) {
m.headersServedInst.Add(ctx, 1)
m.headServeTimeInst.Record(ctx, duration.Milliseconds())
m.headServeTimeInst.Record(ctx, duration.Seconds())
})
}

func (m *serverMetrics) rangeServed(ctx context.Context, duration time.Duration, headersServed int) {
m.observe(ctx, func(ctx context.Context) {
m.headersServedInst.Add(ctx, int64(headersServed))
m.rangeServeTimeInst.Record(ctx,
duration.Milliseconds(),
duration.Seconds(),
metric.WithAttributes(attribute.Int(headersServedKey, headersServed)),
)
})
Expand All @@ -70,7 +70,7 @@ func (m *serverMetrics) rangeServed(ctx context.Context, duration time.Duration,
func (m *serverMetrics) getServed(ctx context.Context, duration time.Duration) {
m.observe(ctx, func(ctx context.Context) {
m.headersServedInst.Add(ctx, 1)
m.getServeTimeInst.Record(ctx, duration.Milliseconds())
m.getServeTimeInst.Record(ctx, duration.Seconds())
})
}

Expand Down

0 comments on commit c917928

Please sign in to comment.