mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
update thrift, opencensus, others (#893)
* update thrift, opencensus, others * stats: update to opencensus 0.6.0 view api
This commit is contained in:
60
vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go
generated
vendored
60
vendor/go.opencensus.io/plugin/ocgrpc/trace_common.go
generated
vendored
@@ -34,12 +34,14 @@ const traceContextKey = "grpc-trace-bin"
|
||||
// It returns ctx with the new trace span added and a serialization of the
|
||||
// SpanContext added to the outgoing gRPC metadata.
|
||||
func (c *ClientHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
name := "Sent" + strings.Replace(rti.FullMethodName, "/", ".", -1)
|
||||
ctx, _ = trace.StartSpan(ctx, name)
|
||||
traceContextBinary := propagation.Binary(trace.FromContext(ctx).SpanContext())
|
||||
if len(traceContextBinary) == 0 {
|
||||
return ctx
|
||||
}
|
||||
name := strings.TrimPrefix(rti.FullMethodName, "/")
|
||||
name = strings.Replace(name, "/", ".", -1)
|
||||
span := trace.NewSpan(name, trace.FromContext(ctx), trace.StartOptions{
|
||||
Sampler: c.StartOptions.Sampler,
|
||||
SpanKind: trace.SpanKindClient,
|
||||
}) // span is ended by traceHandleRPC
|
||||
ctx = trace.WithSpan(ctx, span)
|
||||
traceContextBinary := propagation.Binary(span.SpanContext())
|
||||
return metadata.AppendToOutgoingContext(ctx, traceContextKey, string(traceContextBinary))
|
||||
}
|
||||
|
||||
@@ -50,35 +52,43 @@ func (c *ClientHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo)
|
||||
//
|
||||
// It returns ctx, with the new trace span added.
|
||||
func (s *ServerHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
|
||||
opts := trace.StartOptions{
|
||||
Sampler: s.StartOptions.Sampler,
|
||||
SpanKind: trace.SpanKindServer,
|
||||
}
|
||||
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
name := "Recv" + strings.Replace(rti.FullMethodName, "/", ".", -1)
|
||||
if s := md[traceContextKey]; len(s) > 0 {
|
||||
if parent, ok := propagation.FromBinary([]byte(s[0])); ok {
|
||||
span := trace.NewSpanWithRemoteParent(name, parent, trace.StartOptions{})
|
||||
name := strings.TrimPrefix(rti.FullMethodName, "/")
|
||||
name = strings.Replace(name, "/", ".", -1)
|
||||
traceContext := md[traceContextKey]
|
||||
var (
|
||||
parent trace.SpanContext
|
||||
haveParent bool
|
||||
)
|
||||
if len(traceContext) > 0 {
|
||||
// Metadata with keys ending in -bin are actually binary. They are base64
|
||||
// encoded before being put on the wire, see:
|
||||
// https://github.com/grpc/grpc-go/blob/08d6261/Documentation/grpc-metadata.md#storing-binary-data-in-metadata
|
||||
traceContextBinary := []byte(traceContext[0])
|
||||
parent, haveParent = propagation.FromBinary(traceContextBinary)
|
||||
if haveParent && !s.IsPublicEndpoint {
|
||||
span := trace.NewSpanWithRemoteParent(name, parent, opts)
|
||||
return trace.WithSpan(ctx, span)
|
||||
}
|
||||
}
|
||||
// TODO(ramonza): should we ignore the in-process parent here?
|
||||
ctx, _ = trace.StartSpan(ctx, name)
|
||||
return ctx
|
||||
span := trace.NewSpan(name, nil, opts)
|
||||
if haveParent {
|
||||
span.AddLink(trace.Link{TraceID: parent.TraceID, SpanID: parent.SpanID, Type: trace.LinkTypeChild})
|
||||
}
|
||||
return trace.WithSpan(ctx, span)
|
||||
}
|
||||
|
||||
// HandleRPC processes the RPC stats, adding information to the current trace span.
|
||||
func (c *ClientHandler) traceHandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
handleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
// HandleRPC processes the RPC stats, adding information to the current trace span.
|
||||
func (s *ServerHandler) traceHandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
handleRPC(ctx, rs)
|
||||
}
|
||||
|
||||
func handleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
func traceHandleRPC(ctx context.Context, rs stats.RPCStats) {
|
||||
span := trace.FromContext(ctx)
|
||||
// TODO: compressed and uncompressed sizes are not populated in every message.
|
||||
switch rs := rs.(type) {
|
||||
case *stats.Begin:
|
||||
span.SetAttributes(
|
||||
span.AddAttributes(
|
||||
trace.BoolAttribute("Client", rs.Client),
|
||||
trace.BoolAttribute("FailFast", rs.FailFast))
|
||||
case *stats.InPayload:
|
||||
|
||||
Reference in New Issue
Block a user