Skip to content

Commit

Permalink
Merge branch 'main' into mpetrun5/network-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
mpetrun5 committed Oct 23, 2024
2 parents ef0a65f + 070af99 commit 1800bcd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions observability/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func initGasView() sdkmetric.View {

type RelayerMetrics struct {
*metrics.SystemMetrics
*metrics.NetworkMetrics
*metrics.ChainMetrics

Opts api.MeasurementOption
}
Expand All @@ -126,14 +126,14 @@ func NewRelayerMetrics(ctx context.Context, meter metric.Meter, attributes ...at
return nil, err
}

networkMetrics, err := metrics.NewNetworkMetrics(ctx, meter, opts)
chainMetrics, err := metrics.NewChainMetrics(ctx, meter, opts)
if err != nil {
return nil, err
}

return &RelayerMetrics{
SystemMetrics: systemMetrics,
NetworkMetrics: networkMetrics,
Opts: opts,
SystemMetrics: systemMetrics,
ChainMetrics: chainMetrics,
Opts: opts,
}, err
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"go.opentelemetry.io/otel/metric"
)

type NetworkMetrics struct {
type ChainMetrics struct {
opts metric.MeasurementOption

blockDeltaGauge metric.Int64ObservableGauge
Expand All @@ -24,8 +24,8 @@ type NetworkMetrics struct {
gasPriceHistogram metric.Int64Histogram
}

// NewNetworkMetrics initializes metrics that provide insight into consensus and network activity
func NewNetworkMetrics(ctx context.Context, meter metric.Meter, opts metric.MeasurementOption) (*NetworkMetrics, error) {
// NewChainMetrics initializes metrics that provide insight into chain processing and activity
func NewChainMetrics(ctx context.Context, meter metric.Meter, opts metric.MeasurementOption) (*ChainMetrics, error) {
blockDeltaMap := make(map[uint8]*big.Int)
blockDeltaGauge, err := meter.Int64ObservableGauge(
"relayer.BlockDelta",
Expand Down Expand Up @@ -97,7 +97,7 @@ func NewNetworkMetrics(ctx context.Context, meter metric.Meter, opts metric.Meas
return nil, err
}

return &NetworkMetrics{
return &ChainMetrics{
opts: opts,
blockDeltaMap: blockDeltaMap,
chainHeadMap: chainHeadMap,
Expand All @@ -110,7 +110,7 @@ func NewNetworkMetrics(ctx context.Context, meter metric.Meter, opts metric.Meas
}, nil
}

func (m *NetworkMetrics) TrackBlockDelta(domainID uint8, head *big.Int, current *big.Int) {
func (m *ChainMetrics) TrackBlockDelta(domainID uint8, head *big.Int, current *big.Int) {
m.lock.Lock()
defer m.lock.Unlock()

Expand All @@ -119,7 +119,7 @@ func (m *NetworkMetrics) TrackBlockDelta(domainID uint8, head *big.Int, current
m.chainHeadMap[domainID] = new(big.Int).Set(head)
}

func (m *NetworkMetrics) TrackGasUsage(domainID uint8, gasUsed uint64, gasPrice *big.Int) {
func (m *ChainMetrics) TrackGasUsage(domainID uint8, gasUsed uint64, gasPrice *big.Int) {
m.gasPriceHistogram.Record(
context.Background(),
gasPrice.Int64(),
Expand Down

0 comments on commit 1800bcd

Please sign in to comment.