Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Wondertan committed Oct 24, 2023
1 parent e6e33f1 commit 5bfe72a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions p2p/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ var (
type ExchangeServer[H header.Header[H]] struct {
protocolID protocol.ID

host host.Host
store header.Store[H]
host host.Host
store header.Store[H]
metrics *serverMetrics

ctx context.Context
Expand Down Expand Up @@ -66,7 +66,7 @@ func NewExchangeServer[H header.Header[H]](
protocolID: protocolID(params.networkID),
host: host,
store: store,
metrics: metrics,
metrics: metrics,
Params: params,
}, nil
}
Expand Down
16 changes: 8 additions & 8 deletions p2p/server_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
const headersServedKey = "num_headers_served"

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

func newServerMetrics() (m *serverMetrics, err error) {
m = new(serverMetrics)
m.headersServed, err = meter.Int64Counter(
m.headersServedInst, err = meter.Int64Counter(
"hdr_p2p_exch_srvr_headers_served",
metric.WithDescription("number of headers served"),
)
Expand Down Expand Up @@ -52,14 +52,14 @@ func newServerMetrics() (m *serverMetrics, err error) {

func (m *serverMetrics) headServed(ctx context.Context, duration time.Duration) {
m.observe(ctx, func(ctx context.Context) {
m.headersServed.Add(ctx, 1)
m.headersServedInst.Add(ctx, 1)
m.headServeTimeInst.Record(ctx, duration.Milliseconds())
})
}

func (m *serverMetrics) rangeServed(ctx context.Context, duration time.Duration, headersServed int) {
m.observe(ctx, func(ctx context.Context) {
m.headersServed.Add(ctx, int64(headersServed))
m.headersServedInst.Add(ctx, int64(headersServed))
m.rangeServeTimeInst.Record(ctx,
duration.Milliseconds(),
metric.WithAttributes(attribute.Int(headersServedKey, headersServed)),
Expand All @@ -69,7 +69,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.headersServed.Add(ctx, 1)
m.headersServedInst.Add(ctx, 1)
m.getServeTimeInst.Record(ctx, duration.Milliseconds())
})
}
Expand All @@ -84,4 +84,4 @@ func (m *serverMetrics) observe(ctx context.Context, f func(context.Context)) {
}

f(ctx)
}
}

0 comments on commit 5bfe72a

Please sign in to comment.