Added reqtrace spans for fuse ops.
parent
cf9ed934d5
commit
18af108bac
|
@ -19,16 +19,18 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jacobsa/bazilfuse"
|
"github.com/jacobsa/bazilfuse"
|
||||||
|
"github.com/jacobsa/reqtrace"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
// A helper for embedding common behavior.
|
// A helper for embedding common behavior.
|
||||||
type commonOp struct {
|
type commonOp struct {
|
||||||
opType string
|
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
|
opType string
|
||||||
r bazilfuse.Request
|
r bazilfuse.Request
|
||||||
log func(int, string, ...interface{})
|
log func(int, string, ...interface{})
|
||||||
opsInFlight *sync.WaitGroup
|
opsInFlight *sync.WaitGroup
|
||||||
|
report reqtrace.ReportFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func describeOpType(t reflect.Type) (desc string) {
|
func describeOpType(t reflect.Type) (desc string) {
|
||||||
|
@ -42,11 +44,15 @@ func (o *commonOp) init(
|
||||||
r bazilfuse.Request,
|
r bazilfuse.Request,
|
||||||
log func(int, string, ...interface{}),
|
log func(int, string, ...interface{}),
|
||||||
opsInFlight *sync.WaitGroup) {
|
opsInFlight *sync.WaitGroup) {
|
||||||
|
// Initialize basic fields.
|
||||||
o.opType = describeOpType(opType)
|
o.opType = describeOpType(opType)
|
||||||
o.ctx = context.Background()
|
o.ctx = context.Background()
|
||||||
o.r = r
|
o.r = r
|
||||||
o.log = log
|
o.log = log
|
||||||
o.opsInFlight = opsInFlight
|
o.opsInFlight = opsInFlight
|
||||||
|
|
||||||
|
// Set up a trace span for this op.
|
||||||
|
o.ctx, o.report = reqtrace.StartSpan(o.ctx, o.opType)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *commonOp) Header() OpHeader {
|
func (o *commonOp) Header() OpHeader {
|
||||||
|
@ -71,6 +77,8 @@ func (o *commonOp) respondErr(err error) {
|
||||||
panic("Expect non-nil here.")
|
panic("Expect non-nil here.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
o.report(err)
|
||||||
|
|
||||||
o.Logf(
|
o.Logf(
|
||||||
"-> (%s) error: %v",
|
"-> (%s) error: %v",
|
||||||
o.opType,
|
o.opType,
|
||||||
|
@ -84,6 +92,9 @@ func (o *commonOp) respondErr(err error) {
|
||||||
//
|
//
|
||||||
// Special case: nil means o.r.Respond accepts no parameters.
|
// Special case: nil means o.r.Respond accepts no parameters.
|
||||||
func (o *commonOp) respond(resp interface{}) {
|
func (o *commonOp) respond(resp interface{}) {
|
||||||
|
// We were successful.
|
||||||
|
o.report(nil)
|
||||||
|
|
||||||
// Find the Respond method.
|
// Find the Respond method.
|
||||||
v := reflect.ValueOf(o.r)
|
v := reflect.ValueOf(o.r)
|
||||||
respond := v.MethodByName("Respond")
|
respond := v.MethodByName("Respond")
|
||||||
|
|
Loading…
Reference in New Issue