Skip to content

Commit d946a62

Browse files
committed
removed transaction-span trace option as tx begin context is not propagated to exec calls
1 parent 6468790 commit d946a62

File tree

2 files changed

+0
-51
lines changed

2 files changed

+0
-51
lines changed

driver.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -334,16 +334,6 @@ func (c *ocConn) BeginTx(ctx context.Context, opts driver.TxOptions) (driver.Tx,
334334
return c.parent.Begin()
335335
}
336336

337-
if c.options.Transaction {
338-
if ctx == nil || ctx == context.TODO() {
339-
var appSpan *trace.Span
340-
ctx, appSpan = trace.StartSpan(context.Background(), "sql:transaction")
341-
appSpan.AddAttributes(attrMissingContext)
342-
} else {
343-
ctx, _ = trace.StartSpan(ctx, "sql:transaction")
344-
}
345-
}
346-
347337
var span *trace.Span
348338
if ctx == nil || ctx == context.TODO() {
349339
ctx = context.Background()
@@ -612,16 +602,6 @@ type ocTx struct {
612602
}
613603

614604
func (t ocTx) Commit() (err error) {
615-
if t.options.Transaction {
616-
defer func() {
617-
if span := trace.FromContext(t.ctx); span != nil {
618-
span.SetStatus(trace.Status{Code: trace.StatusCodeOK})
619-
setSpanStatus(span, err)
620-
span.End()
621-
}
622-
}()
623-
}
624-
625605
_, span := trace.StartSpan(t.ctx, "sql:commit")
626606
defer func() {
627607
setSpanStatus(span, err)
@@ -633,22 +613,6 @@ func (t ocTx) Commit() (err error) {
633613
}
634614

635615
func (t ocTx) Rollback() (err error) {
636-
if t.options.Transaction {
637-
defer func() {
638-
if span := trace.FromContext(t.ctx); span != nil {
639-
if err == nil {
640-
span.SetStatus(trace.Status{
641-
Code: trace.StatusCodeAborted,
642-
Message: "transaction rollback",
643-
})
644-
} else {
645-
setSpanStatus(span, err)
646-
}
647-
span.End()
648-
}
649-
}()
650-
}
651-
652616
_, span := trace.StartSpan(t.ctx, "sql:rollback")
653617
defer func() {
654618
setSpanStatus(span, err)

options.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ type TraceOptions struct {
1414
// in context or when using methods not taking context.
1515
AllowRoot bool
1616

17-
// Transaction, if set to true, will create spans for the duration of db
18-
// transactions. All spans created by the transaction's scoped queries will
19-
// become children of the transaction span.
20-
Transaction bool
21-
2217
// Ping, if set to true, will enable the creation of spans on Ping requests.
2318
Ping bool
2419

@@ -60,7 +55,6 @@ func WithAllTraceOptions() TraceOption {
6055
// AllTraceOptions has all tracing options enabled.
6156
var AllTraceOptions = TraceOptions{
6257
AllowRoot: true,
63-
Transaction: true,
6458
Ping: true,
6559
RowsNext: true,
6660
RowsClose: true,
@@ -88,15 +82,6 @@ func WithAllowRoot(b bool) TraceOption {
8882
}
8983
}
9084

91-
// WithTransaction if set to true, will create spans for the duration of db
92-
// transactions. All spans created by the transaction's scoped queries will
93-
// become children of the transaction span.
94-
func WithTransaction(b bool) TraceOption {
95-
return func(o *TraceOptions) {
96-
o.Transaction = b
97-
}
98-
}
99-
10085
// WithPing if set to true, will enable the creation of spans on Ping requests.
10186
func WithPing(b bool) TraceOption {
10287
return func(o *TraceOptions) {

0 commit comments

Comments
 (0)