Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitor+server: Record million pixels processed metric #1899

Merged
merged 3 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- \#1877 Refresh TicketParams for the active session before expiry (@kyriediculous)
- \#1879 Add mp4 download of recorded stream (@darkdarkdragon)
- \#1899 Record million pixels processed metric (@yondonfu)

#### Orchestrator

Expand Down
21 changes: 21 additions & 0 deletions monitor/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ type (
mSuggestedGasPrice *stats.Float64Measure
mTranscodingPrice *stats.Float64Measure

// Metrics for pixel accounting
mMilPixelsProcessed *stats.Float64Measure

lock sync.Mutex
emergeTimes map[uint64]map[uint64]time.Time // nonce:seqNo
success map[uint64]*segmentsAverager
Expand Down Expand Up @@ -275,6 +278,9 @@ func InitCensus(nodeType NodeType, version string) {
census.mSuggestedGasPrice = stats.Float64("suggested_gas_price", "SuggestedGasPrice", "gwei")
census.mTranscodingPrice = stats.Float64("transcoding_price", "TranscodingPrice", "wei")

// Metrics for pixel accounting
census.mMilPixelsProcessed = stats.Float64("mil_pixels_processed", "MilPixelsProcessed", "mil pixels")

glog.Infof("Compiler: %s Arch %s OS %s Go version %s", runtime.Compiler, runtime.GOARCH, runtime.GOOS, runtime.Version())
glog.Infof("Livepeer version: %s", version)
glog.Infof("Node type %s node ID %s", nodeType, NodeID)
Expand Down Expand Up @@ -681,6 +687,14 @@ func InitCensus(nodeType NodeType, version string) {
TagKeys: baseTags,
Aggregation: view.Sum(),
},
// Metrics for pixel accounting
{
Name: "mil_pixels_processed",
Measure: census.mMilPixelsProcessed,
Description: "Million pixels processed",
TagKeys: baseTags,
Aggregation: view.Sum(),
},
{
Name: "suggested_gas_price",
Measure: census.mSuggestedGasPrice,
Expand Down Expand Up @@ -1407,6 +1421,13 @@ func TicketRedemptionError() {
stats.Record(census.ctx, census.mTicketRedemptionError.M(1))
}

func MilPixelsProcessed(milPixels float64) {
census.lock.Lock()
defer census.lock.Unlock()

stats.Record(census.ctx, census.mMilPixelsProcessed.M(milPixels))
}

// SuggestedGasPrice records the last suggested gas price
func SuggestedGasPrice(gasPrice *big.Int) {
census.lock.Lock()
Expand Down
4 changes: 4 additions & 0 deletions server/segment_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,10 @@ func SubmitSegment(sess *BroadcastSession, seg *stream.HLSSegment, nonce uint64)
}

balUpdate.Debit.Mul(new(big.Rat).SetInt64(pixelCount), priceInfo)

if monitor.Enabled {
monitor.MilPixelsProcessed(float64(pixelCount) / 1000000.0)
}
}

// transcode succeeded; continue processing response
Expand Down