Skip to content

Commit

Permalink
BAAS-28597: Add counter for limiter wait calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvinnix committed Feb 13, 2024
1 parent acea50a commit 0ae652c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ type Runtime struct {

limiter *rate.Limiter
limiterTicksLeft int
limiterWaitCount uint64
ticks uint64

tickMetricTrackingEnabled bool
Expand All @@ -213,6 +214,10 @@ func (self *Runtime) Ticks() uint64 {
return self.ticks
}

func (self *Runtime) LimiterWaitCount() uint64 {
return self.limiterWaitCount
}

// SetStackTraceLimit sets an upper limit to the number of stack frames that
// goja will use when formatting an error's stack trace. By default, the limit
// is 10. This is consistent with V8 and SpiderMonkey.
Expand Down
1 change: 1 addition & 0 deletions vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ func (vm *vm) run() {
ctx = context.Background()
}

vm.r.limiterWaitCount++
if waitErr := vm.r.limiter.WaitN(ctx, vm.r.limiterTicksLeft); waitErr != nil {
if vm.r.vm.ctx == nil {
panic(waitErr)
Expand Down

0 comments on commit 0ae652c

Please sign in to comment.