Skip to content

Commit

Permalink
add metrics for active requests and req count
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Apr 3, 2024
1 parent 0c71475 commit 09a888f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
* Fix a panic on tier2 when not using any wasm extension.
* Fix a thread leak on metering GRPC emitter
* Rollback scheduler optimisation: different stages can run concurrently if they are schedulable. This will prevent taking much time to execute when restarting close to HEAD.
* Add `substreams_tier2_active_requests` and `substreams_tier2_request_counter` prometheus metrics

## v1.5.0

Expand Down
3 changes: 3 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ var SquashersEnded = MetricSet.NewCounter("substreams_total_squash_processes_clo
var Tier1ActiveWorkerRequest = MetricSet.NewGauge("substreams_tier1_active_worker_requests", "Number of active Substreams worker requests a tier1 app is currently doing against tier2 nodes")
var Tier1WorkerRequestCounter = MetricSet.NewCounter("substreams_tier1_worker_request_counter", "Counter for total Substreams worker requests a tier1 app made against tier2 nodes")

var Tier2ActiveRequests = MetricSet.NewGauge("substreams_tier2_active_requests", "Number of active Substreams requests the tier2 is currently serving")
var Tier2RequestCounter = MetricSet.NewCounter("substreams_tier2_request_counter", "Counter for total Substreams requests the tier2 served")

var AppReadinessTier1 = MetricSet.NewAppReadiness("substreams_tier1")
var AppReadinessTier2 = MetricSet.NewAppReadiness("substreams_tier2")

Expand Down
4 changes: 4 additions & 0 deletions service/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ func (s *Tier2Service) setOverloaded() {
}

func (s *Tier2Service) ProcessRange(request *pbssinternal.ProcessRangeRequest, streamSrv pbssinternal.Substreams_ProcessRangeServer) (grpcError error) {
metrics.Tier2ActiveRequests.Inc()
metrics.Tier2RequestCounter.Inc()
defer metrics.Tier2ActiveRequests.Dec()

// We keep `err` here as the unaltered error from `blocks` call, this is used in the EndSpan to record the full error
// and not only the `grpcError` one which is a subset view of the full `err`.
var err error
Expand Down

0 comments on commit 09a888f

Please sign in to comment.