Skip to content

Commit

Permalink
update call component
Browse files Browse the repository at this point in the history
Signed-off-by: okJiang <[email protected]>
  • Loading branch information
okJiang committed Dec 27, 2024
1 parent e0415dc commit 785a707
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions internal/locate/pd_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type CodecPDClient struct {
// NewCodecPDClient creates a CodecPDClient in API v1.
func NewCodecPDClient(mode apicodec.Mode, client pd.Client) *CodecPDClient {
codec := apicodec.NewCodecV1(mode)
return &CodecPDClient{client, codec}
return &CodecPDClient{client.WithCallerComponent("codec-pd-client"), codec}
}

// NewCodecPDClientWithKeyspace creates a CodecPDClient in API v2 with keyspace name.
Expand All @@ -71,7 +71,7 @@ func NewCodecPDClientWithKeyspace(mode apicodec.Mode, client pd.Client, keyspace
return nil, err
}

return &CodecPDClient{client, codec}, nil
return &CodecPDClient{client.WithCallerComponent("codec-pd-client"), codec}, nil
}

// GetKeyspaceID attempts to retrieve keyspace ID corresponding to the given keyspace name from PD.
Expand Down
2 changes: 1 addition & 1 deletion internal/locate/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ func NewRegionCache(pdClient pd.Client, opt ...RegionCacheOpt) *RegionCache {
}

c := &RegionCache{
pdClient: pdClient,
pdClient: pdClient.WithCallerComponent("region-cache"),
requestHealthFeedbackCallback: options.requestHealthFeedbackCallback,
}

Expand Down
2 changes: 1 addition & 1 deletion internal/locate/store_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type storeCache interface {
}

func newStoreCache(pdClient pd.Client) *storeCacheImpl {
c := &storeCacheImpl{pdClient: pdClient}
c := &storeCacheImpl{pdClient: pdClient.WithCallerComponent("store-cache")}
c.notifyCheckCh = make(chan struct{}, 1)
c.storeMu.stores = make(map[uint64]*Store)
c.tiflashComputeStoreMu.needReload = true
Expand Down
2 changes: 1 addition & 1 deletion oracle/oracles/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func NewPdOracle(pdClient pd.Client, options *PDOracleOptions) (oracle.Oracle, e
}

o := &pdOracle{
c: pdClient,
c: pdClient.WithCallerComponent("oracle"),
quit: make(chan struct{}),
lastTSUpdateInterval: atomic.Int64{},
}
Expand Down
5 changes: 3 additions & 2 deletions rawkv/rawkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const (
rawBatchPutSize = 16 * 1024
// rawBatchPairCount is the maximum limit for rawkv each batch get/delete request.
rawBatchPairCount = 512
componentName = caller.Component("rawkv-client-go")
)

type rawOptions struct {
Expand Down Expand Up @@ -204,7 +205,7 @@ func NewClientWithOpts(ctx context.Context, pdAddrs []string, opts ...ClientOpt)
}

// Use an unwrapped PDClient to obtain keyspace meta.
pdCli, err := pd.NewClientWithContext(ctx, caller.Component("rawkv-client-go"), pdAddrs, pd.SecurityOption{
pdCli, err := pd.NewClientWithContext(ctx, componentName, pdAddrs, pd.SecurityOption{
CAPath: opt.security.ClusterSSLCA,
CertPath: opt.security.ClusterSSLCert,
KeyPath: opt.security.ClusterSSLKey,
Expand Down Expand Up @@ -240,7 +241,7 @@ func NewClientWithOpts(ctx context.Context, pdAddrs []string, opts ...ClientOpt)
apiVersion: opt.apiVersion,
clusterID: pdCli.GetClusterID(ctx),
regionCache: locate.NewRegionCache(pdCli),
pdClient: pdCli,
pdClient: pdCli.WithCallerComponent(componentName),
rpcClient: rpcCli,
}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions tikv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func NewKVStore(uuid string, pdClient pd.Client, spkv SafePointKV, tikvclient Cl
clusterID: pdClient.GetClusterID(context.TODO()),
uuid: uuid,
oracle: o,
pdClient: pdClient,
pdClient: pdClient.WithCallerComponent("kv-store"),
regionCache: regionCache,
kv: spkv,
safePoint: 0,
Expand Down Expand Up @@ -906,7 +906,7 @@ func NewLockResolver(etcdAddrs []string, security config.Security, opts ...opt.C
if err != nil {
return nil, errors.WithStack(err)
}
pdCli = util.InterceptedPDClient{Client: pdCli}
pdCli = util.NewInterceptedPDClient(pdCli)
uuid := fmt.Sprintf("tikv-%v", pdCli.GetClusterID(context.TODO()))

tlsConfig, err := security.ToTLSConfig()
Expand Down
2 changes: 1 addition & 1 deletion txnkv/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func NewClient(pdAddrs []string, opts ...ClientOpt) (*Client, error) {
return nil, errors.WithStack(err)
}

pdClient = util.InterceptedPDClient{Client: pdClient}
pdClient = util.NewInterceptedPDClient(pdClient)

// Construct codec from options.
var codecCli *tikv.CodecPDClient
Expand Down
4 changes: 4 additions & 0 deletions util/pd_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ type InterceptedPDClient struct {
pd.Client
}

func NewInterceptedPDClient(client pd.Client) *InterceptedPDClient {
return &InterceptedPDClient{client.WithCallerComponent("intercepted-pd-client")}
}

// interceptedTsFuture is a PD's wrapper future to record stmt detail.
type interceptedTsFuture struct {
tso.TSFuture
Expand Down

0 comments on commit 785a707

Please sign in to comment.