Skip to content

Commit

Permalink
fix: add more resource manager log
Browse files Browse the repository at this point in the history
  • Loading branch information
will-2012 committed Aug 29, 2023
1 parent b26e281 commit de698b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/gfspapp/app_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ func DefaultGfSpResourceManagerOption(app *GfSpBaseApp, cfg *gfspconfig.GfSpConf
}
if cfg.Customize.Rcmgr == nil {
cfg.Customize.Rcmgr = gfsprcmgr.NewResourceManager(cfg.Customize.RcLimiter)
log.Infow("succeed to init resource manager", "limit", cfg.Customize.RcLimiter.String())
}
if !cfg.Rcmgr.DisableRcmgr {
app.rcmgr = cfg.Customize.Rcmgr
Expand Down
12 changes: 12 additions & 0 deletions base/gfsprcmgr/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ func (s *resourceScope) BeginSpan() (corercmgr.ResourceScopeSpan, error) {
func (s *resourceScope) Done() {
s.Lock()
defer s.Unlock()
log.Debugw("begin to release resources",
"span_id", s.spanID, "reserved_stat", s.owner.rc.stat().String(), "release_stat", s.rc.stat().String())
defer func() {
log.Debugw("end to release resources",
"span_id", s.spanID, "reserved_stat", s.owner.rc.stat().String(), "release_stat", s.rc.stat().String())
}()
if s.done {
return
}
Expand Down Expand Up @@ -448,6 +454,12 @@ func (s *resourceScope) ReleaseForChild(st corercmgr.ScopeStat) {
func (s *resourceScope) ReserveResources(st *corercmgr.ScopeStat) error {
s.Lock()
defer s.Unlock()
log.Debugw("begin to reserve resources",
"span_id", s.spanID, "reserved_stat", s.rc.stat().String(), "alloc_stat", st.String())
defer func() {
log.Debugw("end to reserve resources",
"span_id", s.spanID, "reserved_stat", s.rc.stat().String(), "alloced_stat", st.String())
}()
if s.done {
return s.wrapError(ErrResourceScopeClosed)
}
Expand Down

0 comments on commit de698b6

Please sign in to comment.