Skip to content

Commit

Permalink
add spans in resource_pool.go
Browse files Browse the repository at this point in the history
Signed-off-by: Austen Lacy <austen.lacy@shopify.com>
  • Loading branch information
austenLacy committed Dec 6, 2023
1 parent ab9da01 commit c62c2fa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions go/pools/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (

"vitess.io/vitess/go/sync2"
"vitess.io/vitess/go/timer"
"vitess.io/vitess/go/trace"
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vterrors"

Expand Down Expand Up @@ -252,6 +253,9 @@ func (rp *ResourcePool) reopen() {
// it will wait till the next resource becomes available or a timeout.
// A timeout of 0 is an indefinite wait.
func (rp *ResourcePool) Get(ctx context.Context, setting *Setting) (resource Resource, err error) {
span, ctx := trace.NewSpan(ctx, "ResourcePool.Get")
defer span.Finish()

// If ctx has already expired, avoid racing with rp's resource channel.
if ctx.Err() != nil {
return nil, ErrCtxTimeout
Expand All @@ -263,6 +267,9 @@ func (rp *ResourcePool) Get(ctx context.Context, setting *Setting) (resource Res
}

func (rp *ResourcePool) get(ctx context.Context) (resource Resource, err error) {
span, ctx := trace.NewSpan(ctx, "ResourcePool.get")
defer span.Finish()

rp.getCount.Add(1)
// Fetch
var wrapper resourceWrapper
Expand Down Expand Up @@ -322,6 +329,9 @@ func (rp *ResourcePool) get(ctx context.Context) (resource Resource, err error)
}

func (rp *ResourcePool) getWithSettings(ctx context.Context, setting *Setting) (Resource, error) {
span, ctx := trace.NewSpan(ctx, "ResourcePool.getWithSettings")
defer span.Finish()

rp.getSettingCount.Add(1)
var wrapper resourceWrapper
var ok bool
Expand Down

0 comments on commit c62c2fa

Please sign in to comment.