diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index da1868574a..aa4f45c4c3 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -9,6 +9,7 @@ - \#1911 [Experimental] Enable scene classification for Adult/Soccer (@jailuthra, @yondonfu) - \#1915 Use gas price monitor for gas price suggestions for all Ethereum transactions (@kyriediculous) - \#1930 Support custom minimum gas price (@yondonfu) +- \#1942 Log min and max gas price when monitoring is enabled (@kyriediculous) #### Broadcaster diff --git a/eth/backend.go b/eth/backend.go index 3e6a28ac9c..e6d0e53a47 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -16,6 +16,7 @@ import ( "github.com/ethereum/go-ethereum/params" "github.com/golang/glog" "github.com/livepeer/go-livepeer/eth/contracts" + "github.com/livepeer/go-livepeer/monitor" ) var abis = []string{ @@ -129,6 +130,10 @@ func (b *backend) SetMaxGasPrice(gp *big.Int) { b.Lock() defer b.Unlock() b.maxGasPrice = gp + + if monitor.Enabled { + monitor.MaxGasPrice(gp) + } } func (b *backend) MaxGasPrice() *big.Int { diff --git a/eth/gaspricemonitor.go b/eth/gaspricemonitor.go index c8028207d7..3cdfcbb123 100644 --- a/eth/gaspricemonitor.go +++ b/eth/gaspricemonitor.go @@ -46,6 +46,9 @@ func NewGasPriceMonitor(gpo GasPriceOracle, pollingInterval time.Duration, minGa if minGasPrice != nil { minGasP = minGasPrice } + if monitor.Enabled { + monitor.MinGasPrice(minGasP) + } return &GasPriceMonitor{ gpo: gpo, pollingInterval: pollingInterval, @@ -70,6 +73,10 @@ func (gpm *GasPriceMonitor) SetMinGasPrice(minGasPrice *big.Int) { gpm.gasPriceMu.Lock() defer gpm.gasPriceMu.Unlock() gpm.minGasPrice = minGasPrice + + if monitor.Enabled { + monitor.MinGasPrice(minGasPrice) + } } func (gpm *GasPriceMonitor) MinGasPrice() *big.Int { diff --git a/monitor/census.go b/monitor/census.go index efe3a59db9..e9c617c842 100644 --- a/monitor/census.go +++ b/monitor/census.go @@ -149,6 +149,8 @@ type ( mValueRedeemed *stats.Float64Measure mTicketRedemptionError *stats.Int64Measure mSuggestedGasPrice *stats.Float64Measure + mMinGasPrice *stats.Float64Measure + mMaxGasPrice *stats.Float64Measure mTranscodingPrice *stats.Float64Measure // Metrics for pixel accounting @@ -276,6 +278,8 @@ func InitCensus(nodeType NodeType, version string) { census.mValueRedeemed = stats.Float64("value_redeemed", "ValueRedeemed", "gwei") census.mTicketRedemptionError = stats.Int64("ticket_redemption_errors", "TicketRedemptionError", "tot") census.mSuggestedGasPrice = stats.Float64("suggested_gas_price", "SuggestedGasPrice", "gwei") + census.mMinGasPrice = stats.Float64("min_gas_price", "MinGasPrice", "gwei") + census.mMaxGasPrice = stats.Float64("max_gas_price", "MaxGasPrice", "gwei") census.mTranscodingPrice = stats.Float64("transcoding_price", "TranscodingPrice", "wei") // Metrics for pixel accounting @@ -687,6 +691,21 @@ func InitCensus(nodeType NodeType, version string) { TagKeys: baseTags, Aggregation: view.Sum(), }, + { + Name: "min_gas_price", + Measure: census.mMinGasPrice, + Description: "Minimum gas price to use for gas price suggestions", + TagKeys: baseTags, + Aggregation: view.LastValue(), + }, + { + Name: "max_gas_price", + Measure: census.mMaxGasPrice, + Description: "Maximum gas price to use for gas price suggestions", + TagKeys: baseTags, + Aggregation: view.LastValue(), + }, + // Metrics for pixel accounting { Name: "mil_pixels_processed", @@ -1436,6 +1455,20 @@ func SuggestedGasPrice(gasPrice *big.Int) { stats.Record(census.ctx, census.mSuggestedGasPrice.M(wei2gwei(gasPrice))) } +func MinGasPrice(minGasPrice *big.Int) { + census.lock.Lock() + defer census.lock.Unlock() + + stats.Record(census.ctx, census.mMinGasPrice.M(wei2gwei(minGasPrice))) +} + +func MaxGasPrice(maxGasPrice *big.Int) { + census.lock.Lock() + defer census.lock.Unlock() + + stats.Record(census.ctx, census.mMaxGasPrice.M(wei2gwei(maxGasPrice))) +} + // TranscodingPrice records the last transcoding price func TranscodingPrice(sender string, price *big.Rat) { census.lock.Lock()