mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Update dskit for gRPC interface change * Update vendor * Update vendor * bump dskit * update go.sum * manifest --------- Co-authored-by: javiermolinar <[email protected]>
30 lines
1.1 KiB
Go
30 lines
1.1 KiB
Go
package grpcclient
|
|
|
|
import (
|
|
otgrpc "github.com/opentracing-contrib/go-grpc"
|
|
"github.com/opentracing/opentracing-go"
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
"google.golang.org/grpc"
|
|
|
|
"github.com/grafana/dskit/middleware"
|
|
)
|
|
|
|
func Instrument(requestDuration *prometheus.HistogramVec, instrumentationLabelOptions ...middleware.InstrumentationOption) ([]grpc.UnaryClientInterceptor, []grpc.StreamClientInterceptor) {
|
|
var (
|
|
unary []grpc.UnaryClientInterceptor
|
|
stream []grpc.StreamClientInterceptor
|
|
)
|
|
if opentracing.IsGlobalTracerRegistered() {
|
|
unary = append(unary, otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer()))
|
|
stream = append(stream, otgrpc.OpenTracingStreamClientInterceptor(opentracing.GlobalTracer()))
|
|
}
|
|
return append(unary,
|
|
middleware.ClientUserHeaderInterceptor,
|
|
middleware.UnaryClientInstrumentInterceptor(requestDuration, instrumentationLabelOptions...),
|
|
),
|
|
append(stream,
|
|
middleware.StreamClientUserHeaderInterceptor,
|
|
middleware.StreamClientInstrumentInterceptor(requestDuration, instrumentationLabelOptions...),
|
|
)
|
|
}
|