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

monitoring: max transcoding price #1943

Merged
merged 1 commit into from
Jul 8, 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.
Jump to
Jump to file
Failed to load files.
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 @@ -19,6 +19,7 @@
- \#1908 Prevent Broadcaster from sending low face value PM tickets (@kyriediculous)
- \#1934 http push: return 422 for non-retryable errors (@darkdarkdragon)
- \#1933 server: Return 0 video frame segments unchanged
- \#1943 log maximum transcoding price when monitoring is enabled (@kyriediculous)

#### Orchestrator

Expand Down
32 changes: 25 additions & 7 deletions monitor/census.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ type (
mOrchestratorSwaps *stats.Int64Measure

// Metrics for sending payments
mTicketValueSent *stats.Float64Measure
mTicketsSent *stats.Int64Measure
mPaymentCreateError *stats.Int64Measure
mDeposit *stats.Float64Measure
mReserve *stats.Float64Measure

mTicketValueSent *stats.Float64Measure
mTicketsSent *stats.Int64Measure
mPaymentCreateError *stats.Int64Measure
mDeposit *stats.Float64Measure
mReserve *stats.Float64Measure
mMaxTranscodingPrice *stats.Float64Measure
// Metrics for receiving payments
mTicketValueRecv *stats.Float64Measure
mTicketsRecv *stats.Int64Measure
Expand Down Expand Up @@ -266,7 +266,8 @@ func InitCensus(nodeType NodeType, version string) {
census.mTicketsSent = stats.Int64("tickets_sent", "TicketsSent", "tot")
census.mPaymentCreateError = stats.Int64("payment_create_errors", "PaymentCreateError", "tot")
census.mDeposit = stats.Float64("broadcaster_deposit", "Current remaining deposit for the broadcaster node", "gwei")
census.mReserve = stats.Float64("broadcaster_reserve", "Current remaiing reserve for the broadcaster node", "gwei")
census.mReserve = stats.Float64("broadcaster_reserve", "Current remaing reserve for the broadcaster node", "gwei")
census.mMaxTranscodingPrice = stats.Float64("max_transcoding_price", "MaxTranscodingPrice", "wei")

// Metrics for receiving payments
census.mTicketValueRecv = stats.Float64("ticket_value_recv", "TicketValueRecv", "gwei")
Expand Down Expand Up @@ -643,6 +644,13 @@ func InitCensus(nodeType NodeType, version string) {
TagKeys: baseTags,
Aggregation: view.LastValue(),
},
{
Name: "max_transcoding_price",
Measure: census.mMaxTranscodingPrice,
Description: "Maximum price per pixel to pay for transcoding",
TagKeys: baseTags,
Aggregation: view.LastValue(),
},

// Metrics for receiving payments
{
Expand Down Expand Up @@ -1336,6 +1344,16 @@ func Reserve(sender string, reserve *big.Int) {
stats.Record(census.ctx, census.mReserve.M(wei2gwei(reserve)))
}

func MaxTranscodingPrice(maxPrice *big.Rat) {
census.lock.Lock()
defer census.lock.Unlock()

floatWei, ok := maxPrice.Float64()
if ok {
stats.Record(census.ctx, census.mTranscodingPrice.M(floatWei))
}
}

// TicketValueRecv records the ticket value received from a sender for a manifestID
func TicketValueRecv(value *big.Rat) {
census.lock.Lock()
Expand Down
4 changes: 4 additions & 0 deletions server/broadcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (cfg *BroadcastConfig) SetMaxPrice(price *big.Rat) {
cfg.mu.Lock()
defer cfg.mu.Unlock()
cfg.maxPrice = price

if monitor.Enabled {
monitor.MaxTranscodingPrice(price)
}
}

type BroadcastSessionsManager struct {
Expand Down