[VOL-4292] OpenOLT Adapter changes for gRPC migration
Change-Id: I5af2125f2c2f53ffc78c474a94314bba408f8bae
diff --git a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing/options.go b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing/options.go
index e75102b..430fe56 100644
--- a/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing/options.go
+++ b/vendor/github.com/grpc-ecosystem/go-grpc-middleware/tracing/opentracing/options.go
@@ -21,9 +21,18 @@
// If it returns false, the given request will not be traced.
type FilterFunc func(ctx context.Context, fullMethodName string) bool
+// UnaryRequestHandlerFunc is a custom request handler
+type UnaryRequestHandlerFunc func(span opentracing.Span, req interface{})
+
+// OpNameFunc is a func that allows custom operation names instead of the gRPC method.
+type OpNameFunc func(method string) string
+
type options struct {
- filterOutFunc FilterFunc
- tracer opentracing.Tracer
+ filterOutFunc FilterFunc
+ tracer opentracing.Tracer
+ traceHeaderName string
+ unaryRequestHandlerFunc UnaryRequestHandlerFunc
+ opNameFunc OpNameFunc
}
func evaluateOptions(opts []Option) *options {
@@ -35,6 +44,9 @@
if optCopy.tracer == nil {
optCopy.tracer = opentracing.GlobalTracer()
}
+ if optCopy.traceHeaderName == "" {
+ optCopy.traceHeaderName = "uber-trace-id"
+ }
return optCopy
}
@@ -47,9 +59,31 @@
}
}
+// WithTraceHeaderName customizes the trace header name where trace metadata passed with requests.
+// Default one is `uber-trace-id`
+func WithTraceHeaderName(name string) Option {
+ return func(o *options) {
+ o.traceHeaderName = name
+ }
+}
+
// WithTracer sets a custom tracer to be used for this middleware, otherwise the opentracing.GlobalTracer is used.
func WithTracer(tracer opentracing.Tracer) Option {
return func(o *options) {
o.tracer = tracer
}
}
+
+// WithUnaryRequestHandlerFunc sets a custom handler for the request
+func WithUnaryRequestHandlerFunc(f UnaryRequestHandlerFunc) Option {
+ return func(o *options) {
+ o.unaryRequestHandlerFunc = f
+ }
+}
+
+// WithOpName customizes the trace Operation name
+func WithOpName(f OpNameFunc) Option {
+ return func(o *options) {
+ o.opNameFunc = f
+ }
+}