Skip to content

Commit d571897

Browse files
committed
remove trace.ContextDriver and trace.WithDriver
1 parent bb2565c commit d571897

File tree

6 files changed

+7
-25
lines changed

6 files changed

+7
-25
lines changed

config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func defaultConfig() (c *config) {
342342
return builder.New(
343343
ctx,
344344
address,
345-
trace.ContextDriver(ctx).Compose(c.trace),
345+
c.trace,
346346
)
347347
},
348348
),

internal/conn/conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (c *conn) GetState() (s State) {
176176

177177
func (c *conn) take(ctx context.Context) (cc *grpc.ClientConn, err error) {
178178
onDone := trace.DriverOnConnTake(
179-
trace.ContextDriver(ctx).Compose(c.config.Trace()),
179+
c.config.Trace(),
180180
&ctx,
181181
c.endpoint.Copy(),
182182
)
@@ -328,7 +328,7 @@ func (c *conn) Invoke(
328328
issues []trace.Issue
329329
wrapping = needWrapping(ctx)
330330
onDone = trace.DriverOnConnInvoke(
331-
trace.ContextDriver(ctx).Compose(c.config.Trace()),
331+
c.config.Trace(),
332332
&ctx,
333333
c.endpoint,
334334
trace.Method(method),
@@ -395,7 +395,7 @@ func (c *conn) NewStream(
395395
) (_ grpc.ClientStream, err error) {
396396
var (
397397
streamRecv = trace.DriverOnConnNewStream(
398-
trace.ContextDriver(ctx).Compose(c.config.Trace()),
398+
c.config.Trace(),
399399
&ctx,
400400
c.endpoint.Copy(),
401401
trace.Method(method),

internal/conn/pool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (p *pool) Pessimize(ctx context.Context, cc Conn, cause error) {
9191
}
9292

9393
trace.DriverOnPessimizeNode(
94-
trace.ContextDriver(ctx).Compose(p.config.Trace()),
94+
p.config.Trace(),
9595
&ctx,
9696
e,
9797
cc.GetState(),

internal/db/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func New(
5151
opts ...discoveryConfig.Option,
5252
) (_ Connection, err error) {
5353
onDone := trace.DriverOnInit(
54-
trace.ContextDriver(ctx).Compose(c.Trace()),
54+
c.Trace(),
5555
&ctx,
5656
c.Endpoint(),
5757
c.Database(),

internal/meta/meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (m *meta) meta(ctx context.Context) (_ metadata.MD, err error) {
120120

121121
var token string
122122

123-
getCredentialsDone := trace.DriverOnGetCredentials(trace.ContextDriver(ctx).Compose(m.trace), &ctx)
123+
getCredentialsDone := trace.DriverOnGetCredentials(m.trace, &ctx)
124124
defer func() {
125125
getCredentialsDone(token, err)
126126
}()

trace/context.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,6 @@ package trace
22

33
import "context"
44

5-
type driverContextKey struct{}
6-
7-
// WithDriver returns deadline which has associated Driver with it.
8-
func WithDriver(ctx context.Context, t Driver) context.Context {
9-
return context.WithValue(ctx,
10-
driverContextKey{},
11-
ContextDriver(ctx).Compose(t),
12-
)
13-
}
14-
15-
// ContextDriver returns Driver associated with ctx.
16-
// If there is no Driver associated with ctx then zero value
17-
// of Driver is returned.
18-
func ContextDriver(ctx context.Context) Driver {
19-
t, _ := ctx.Value(driverContextKey{}).(Driver)
20-
return t
21-
}
22-
235
type retryContextKey struct{}
246

257
// WithRetry returns deadline which has associated Retry with it.

0 commit comments

Comments
 (0)