Skip to content

Commit 4ae4d8d

Browse files
committed
fix trace usage
1 parent 78dbb5f commit 4ae4d8d

File tree

39 files changed

+120
-85
lines changed

39 files changed

+120
-85
lines changed

config/config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919
type Config struct {
2020
config.Common
2121

22-
trace trace.Driver
22+
trace *trace.Driver
2323
dialTimeout time.Duration
2424
connectionTTL time.Duration
2525
balancerConfig *balancerConfig.Config
@@ -93,7 +93,7 @@ func (c Config) Database() string {
9393
}
9494

9595
// Trace contains driver tracing options.
96-
func (c Config) Trace() trace.Driver {
96+
func (c Config) Trace() *trace.Driver {
9797
return c.trace
9898
}
9999

@@ -151,7 +151,7 @@ func WithTLSConfig(tlsConfig *tls.Config) Option {
151151

152152
func WithTrace(t trace.Driver, opts ...trace.DriverComposeOption) Option {
153153
return func(c *Config) {
154-
c.trace = c.trace.Compose(t, opts...)
154+
c.trace = c.trace.Compose(&t, opts...)
155155
}
156156
}
157157

config/defaults.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
}
3030
)
3131

32-
func defaultGrpcOptions(t trace.Driver, secure bool, tlsConfig *tls.Config) (opts []grpc.DialOption) {
32+
func defaultGrpcOptions(t *trace.Driver, secure bool, tlsConfig *tls.Config) (opts []grpc.DialOption) {
3333
opts = append(opts,
3434
// keep-aliving all connections
3535
grpc.WithKeepaliveParams(
@@ -89,5 +89,6 @@ func defaultConfig() (c Config) {
8989
balancerConfig: balancers.Default(),
9090
tlsConfig: defaultTLSConfig(),
9191
dialTimeout: DefaultDialTimeout,
92+
trace: &trace.Driver{},
9293
}
9394
}

internal/conn/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
type Config interface {
1212
DialTimeout() time.Duration
13-
Trace() trace.Driver
13+
Trace() *trace.Driver
1414
ConnectionTTL() time.Duration
1515
GrpcDialOptions() []grpc.DialOption
1616
}

internal/coordination/config/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
type Config struct {
1212
config.Common
1313

14-
trace trace.Coordination
14+
trace *trace.Coordination
1515
}
1616

1717
// Trace returns trace over coordination client calls
18-
func (c Config) Trace() trace.Coordination {
18+
func (c Config) Trace() *trace.Coordination {
1919
return c.trace
2020
}
2121

@@ -24,7 +24,7 @@ type Option func(c *Config)
2424
// WithTrace appends coordination trace to early defined traces
2525
func WithTrace(trace trace.Coordination, opts ...trace.CoordinationComposeOption) Option {
2626
return func(c *Config) {
27-
c.trace = c.trace.Compose(trace, opts...)
27+
c.trace = c.trace.Compose(&trace, opts...)
2828
}
2929
}
3030

@@ -36,7 +36,9 @@ func With(config config.Common) Option {
3636
}
3737

3838
func New(opts ...Option) Config {
39-
c := Config{}
39+
c := Config{
40+
trace: &trace.Coordination{},
41+
}
4042
for _, o := range opts {
4143
if o != nil {
4244
o(&c)

internal/discovery/config/config.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ type Config struct {
2121
meta meta.Meta
2222

2323
interval time.Duration
24-
trace trace.Discovery
24+
trace *trace.Discovery
2525
}
2626

2727
func New(opts ...Option) Config {
2828
c := Config{
2929
interval: DefaultInterval,
30+
trace: &trace.Discovery{},
3031
}
3132
for _, o := range opts {
3233
if o != nil {
@@ -56,7 +57,7 @@ func (c Config) Secure() bool {
5657
return c.secure
5758
}
5859

59-
func (c Config) Trace() trace.Discovery {
60+
func (c Config) Trace() *trace.Discovery {
6061
return c.trace
6162
}
6263

@@ -102,7 +103,7 @@ func WithMeta(meta meta.Meta) Option {
102103
// WithTrace configures discovery client calls tracing
103104
func WithTrace(trace trace.Discovery, opts ...trace.DiscoveryComposeOption) Option {
104105
return func(c *Config) {
105-
c.trace = c.trace.Compose(trace, opts...)
106+
c.trace = c.trace.Compose(&trace, opts...)
106107
}
107108
}
108109

internal/meta/meta.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func New(
1515
database string,
1616
credentials credentials.Credentials,
17-
trace trace.Driver,
17+
trace *trace.Driver,
1818
opts ...Option,
1919
) Meta {
2020
m := Meta{
@@ -64,7 +64,7 @@ func ForbidOption(feature string) Option {
6464
}
6565

6666
type Meta struct {
67-
trace trace.Driver
67+
trace *trace.Driver
6868
credentials credentials.Credentials
6969
database string
7070
requestsType string

internal/meta/test/meta_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestMetaRequiredHeaders(t *testing.T) {
1717
m := internal.New(
1818
"database",
1919
credentials.NewAccessTokenCredentials("token", "TestMetaRequiredHeaders"),
20-
trace.Driver{},
20+
&trace.Driver{},
2121
internal.WithRequestTypeOption("requestType"),
2222
internal.WithUserAgentOption("user-agent"),
2323
)

internal/ratelimiter/config/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import (
1111
type Config struct {
1212
config.Common
1313

14-
trace trace.Ratelimiter
14+
trace *trace.Ratelimiter
1515
}
1616

1717
// Trace returns trace over ratelimiter calls
18-
func (c Config) Trace() trace.Ratelimiter {
18+
func (c Config) Trace() *trace.Ratelimiter {
1919
return c.trace
2020
}
2121

@@ -24,7 +24,7 @@ type Option func(c *Config)
2424
// WithTrace appends ratelimiter trace to early defined traces
2525
func WithTrace(trace trace.Ratelimiter, opts ...trace.RatelimiterComposeOption) Option {
2626
return func(c *Config) {
27-
c.trace = c.trace.Compose(trace, opts...)
27+
c.trace = c.trace.Compose(&trace, opts...)
2828
}
2929
}
3030

@@ -36,7 +36,9 @@ func With(config config.Common) Option {
3636
}
3737

3838
func New(opts ...Option) Config {
39-
c := Config{}
39+
c := Config{
40+
trace: &trace.Ratelimiter{},
41+
}
4042
for _, o := range opts {
4143
if o != nil {
4244
o(&c)

internal/repeater/repeater.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type repeater struct {
2323
interval time.Duration
2424

2525
name string
26-
trace trace.Driver
26+
trace *trace.Driver
2727

2828
// Task is a function that must be executed periodically.
2929
task func(context.Context) error
@@ -43,7 +43,7 @@ func WithName(name string) option {
4343
}
4444
}
4545

46-
func WithTrace(trace trace.Driver) option {
46+
func WithTrace(trace *trace.Driver) option {
4747
return func(r *repeater) {
4848
r.trace = trace
4949
}
@@ -84,6 +84,7 @@ func New(
8484
stopped: make(chan struct{}),
8585
force: make(chan struct{}, 1),
8686
clock: clockwork.NewRealClock(),
87+
trace: &trace.Driver{},
8788
}
8889

8990
for _, o := range opts {

internal/scheme/config/config.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ type Config struct {
1212
config.Common
1313

1414
databaseName string
15-
trace trace.Scheme
15+
trace *trace.Scheme
1616
}
1717

1818
// Trace returns trace over scheme client calls
19-
func (c Config) Trace() trace.Scheme {
19+
func (c Config) Trace() *trace.Scheme {
2020
return c.trace
2121
}
2222

@@ -30,7 +30,7 @@ type Option func(c *Config)
3030
// WithTrace appends scheme trace to early defined traces
3131
func WithTrace(trace trace.Scheme, opts ...trace.SchemeComposeOption) Option {
3232
return func(c *Config) {
33-
c.trace = c.trace.Compose(trace, opts...)
33+
c.trace = c.trace.Compose(&trace, opts...)
3434
}
3535
}
3636

@@ -49,7 +49,9 @@ func With(config config.Common) Option {
4949
}
5050

5151
func New(opts ...Option) Config {
52-
c := Config{}
52+
c := Config{
53+
trace: &trace.Scheme{},
54+
}
5355
for _, o := range opts {
5456
if o != nil {
5557
o(&c)

0 commit comments

Comments
 (0)