Skip to content

Commit 0ed9738

Browse files
committed
add idempotent flag to trace table OnDoTx
1 parent aa1bb83 commit 0ed9738

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

internal/table/retry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func parseOptions(ctx context.Context, opts ...retryOption) retryOptions {
7878

7979
func doTx(ctx context.Context, c SessionProvider, op table.TxOperation, opts ...retryOption) (err error) {
8080
options := parseOptions(ctx, opts...)
81-
attempts, onIntermediate := 0, trace.TableOnPoolDoTx(options.trace, &ctx)
81+
attempts, onIntermediate := 0, trace.TableOnPoolDoTx(options.trace, &ctx, options.options.Idempotent)
8282
defer func() {
8383
onIntermediate(err)(attempts, err)
8484
}()

log/table.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,35 @@ func Table(log Logger, details trace.Details) trace.Table {
6565
) func(
6666
trace.PoolDoTxDoneInfo,
6767
) {
68-
log.Tracef(`doTx start`)
68+
idempotent := info.Idempotent
69+
log.Tracef(`doTx start {idempotent:%t}`,
70+
idempotent,
71+
)
6972
start := time.Now()
7073
return func(info trace.PoolDoTxInternalInfo) func(trace.PoolDoTxDoneInfo) {
7174
if info.Error == nil {
72-
log.Tracef(`doTx intermediate {latency:"%s"}`,
75+
log.Tracef(`doTx intermediate {latency:"%s",idempotent:%t}`,
7376
time.Since(start),
77+
idempotent,
7478
)
7579
} else {
76-
log.Debugf(`doTx intermediate {latency:"%s",error:"%v"}`,
80+
log.Debugf(`doTx intermediate {latency:"%s",idempotent:%t,error:"%v"}`,
7781
time.Since(start),
82+
idempotent,
7883
info.Error,
7984
)
8085
}
8186
return func(info trace.PoolDoTxDoneInfo) {
8287
if info.Error == nil {
83-
log.Tracef(`doTx done {latency:"%s",attempts:%d}`,
88+
log.Tracef(`doTx done {latency:"%s",idempotent:%t,attempts:%d}`,
8489
time.Since(start),
90+
idempotent,
8591
info.Attempts,
8692
)
8793
} else {
88-
log.Errorf(`doTx failed {latency:"%s",attempts:%d,error:"%v"}`,
94+
log.Errorf(`doTx failed {latency:"%s",idempotent:%t,attempts:%d,error:"%v"}`,
8995
time.Since(start),
96+
idempotent,
9097
info.Attempts,
9198
info.Error,
9299
)

trace/table.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ type (
299299
// Pointer to context provide replacement of context in trace callback function.
300300
// Warning: concurrent access to pointer on client side must be excluded.
301301
// Safe replacement of context are provided only inside callback function
302-
Context *context.Context
302+
Context *context.Context
303+
Idempotent bool
303304
}
304305
PoolDoTxInternalInfo struct {
305306
Error error

trace/table_gtrace.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)