-
Notifications
You must be signed in to change notification settings - Fork 3
/
tracing.go
61 lines (54 loc) · 1.56 KB
/
tracing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package startup_tracing_pg
import (
"sync"
pt "github.com/flachnetz/startup/v2/startup_postgres"
"github.com/flachnetz/startup/v2/startup_tracing"
)
type PostgresTracingOptions struct {
Inputs struct {
// Extra skip function that skips methods (by name) when guessing the
// transaction span tags.
SkipFrameworkMethod SkipFunc
}
once sync.Once
}
func (opts *PostgresTracingOptions) Initialize(tops *startup_tracing.TracingOptions) {
opts.once.Do(func() {
if tops.IsActive() {
skipFunction := opts.Inputs.SkipFrameworkMethod
if skipFunction == nil {
skipFunction = func(name string) bool { return false }
}
pt.InstallTracer(&tracer{
ServiceName: tops.Inputs.ServiceName + "-db",
SkipFrameworkMethod: skipFunction,
})
}
})
}
//func (opts *PostgresTracingOptions) installTransactionTracingHook(serviceName string) {
// withTransactionContext := pt.WithTransactionContext
//
// skipFunction := opts.Inputs.SkipFrameworkMethod
// if skipFunction == nil {
// skipFunction = func(name string) bool {
// return false
// }
// }
//
// pt.WithTransactionContext = func(ctx context.Context, db pt.TxStarter, operation pt.TransactionCommitFn) (err error) {
// tag := findOutsideCaller(skipFunction)
//
// if tag == "" {
// tag = "transaction"
// }
//
// _, err = startup_tracing.Trace(ctx, tag, func(ctx context.Context, span opentracing.Span) (any, error) {
// span.SetTag("dd.service", serviceName)
// span.SetTag("dd.resource", "tx:"+tag)
// return nil, withTransactionContext(ctx, db, operation)
// })
//
// return err
// }
//}