mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-14 09:17:35 -06:00
feat: initial tracing support (#1623)
This commit is contained in:
parent
878ed48de3
commit
6392e00653
472 changed files with 102600 additions and 12 deletions
38
vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/tx.go
generated
vendored
Normal file
38
vendor/github.com/uptrace/opentelemetry-go-extra/otelsql/tx.go
generated
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
package otelsql
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql/driver"
|
||||
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
)
|
||||
|
||||
type otelTx struct {
|
||||
ctx context.Context
|
||||
tx driver.Tx
|
||||
instrum *dbInstrum
|
||||
}
|
||||
|
||||
var _ driver.Tx = (*otelTx)(nil)
|
||||
|
||||
func newTx(ctx context.Context, tx driver.Tx, instrum *dbInstrum) *otelTx {
|
||||
return &otelTx{
|
||||
ctx: ctx,
|
||||
tx: tx,
|
||||
instrum: instrum,
|
||||
}
|
||||
}
|
||||
|
||||
func (tx *otelTx) Commit() error {
|
||||
return tx.instrum.withSpan(tx.ctx, "tx.Commit", "",
|
||||
func(ctx context.Context, span trace.Span) error {
|
||||
return tx.tx.Commit()
|
||||
})
|
||||
}
|
||||
|
||||
func (tx *otelTx) Rollback() error {
|
||||
return tx.instrum.withSpan(tx.ctx, "tx.Rollback", "",
|
||||
func(ctx context.Context, span trace.Span) error {
|
||||
return tx.tx.Rollback()
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue