Skip to content

Commit

Permalink
monitoring: max transcoding price
Browse files Browse the repository at this point in the history
  • Loading branch information
kyriediculous committed Jul 8, 2021
1 parent 8ab99c7 commit cfb2916
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,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 @@ -268,7 +268,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 @@ -647,6 +648,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 @@ -1355,6 +1363,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

0 comments on commit cfb2916

Please sign in to comment.