phase 2: mattes/migrate -> migratex (#848)

* move mattes migrations to migratex

* changes format of migrations to migratex format
* updates test runner to use new interface (double checked this with printlns,
the tests go fully down and then up, and work on pg/mysql)

* remove mattes/migrate

* update tests from deps

* update readme

* fix other file extensions
This commit is contained in:
Reed Allman
2018-03-13 14:12:34 -07:00
committed by GitHub
parent 1f43545b63
commit 4084b727c0
697 changed files with 16924 additions and 35406 deletions

View File

@@ -17,29 +17,23 @@ package ocgrpc
import (
"strings"
"google.golang.org/grpc/codes"
"go.opencensus.io/trace"
"go.opencensus.io/trace/propagation"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/status"
)
// clientTraceHandler is a an implementation of grpc.StatsHandler
// that can be passed to grpc.Dial
// using grpc.WithStatsHandler to enable trace context propagation and
// automatic span creation for outgoing gRPC requests.
type clientTraceHandler struct{}
type serverTraceHandler struct{}
const traceContextKey = "grpc-trace-bin"
// TagRPC creates a new trace span for the client side of the RPC.
//
// It returns ctx with the new trace span added and a serialization of the
// SpanContext added to the outgoing gRPC metadata.
func (c *clientTraceHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
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())
@@ -55,26 +49,27 @@ func (c *clientTraceHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo)
// it finds one, uses that SpanContext as the parent context of the new span.
//
// It returns ctx, with the new trace span added.
func (s *serverTraceHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
func (s *ServerHandler) traceTagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context {
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 {
ctx, _ = trace.StartSpanWithRemoteParent(ctx, name, parent, trace.StartOptions{})
return ctx
span := trace.NewSpanWithRemoteParent(name, parent, trace.StartOptions{})
return trace.WithSpan(ctx, span)
}
}
// TODO(ramonza): should we ignore the in-process parent here?
ctx, _ = trace.StartSpan(ctx, name)
return ctx
}
// HandleRPC processes the RPC stats, adding information to the current trace span.
func (c *clientTraceHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
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 *serverTraceHandler) HandleRPC(ctx context.Context, rs stats.RPCStats) {
func (s *ServerHandler) traceHandleRPC(ctx context.Context, rs stats.RPCStats) {
handleRPC(ctx, rs)
}
@@ -84,16 +79,20 @@ func handleRPC(ctx context.Context, rs stats.RPCStats) {
switch rs := rs.(type) {
case *stats.Begin:
span.SetAttributes(
trace.BoolAttribute{Key: "Client", Value: rs.Client},
trace.BoolAttribute{Key: "FailFast", Value: rs.FailFast})
trace.BoolAttribute("Client", rs.Client),
trace.BoolAttribute("FailFast", rs.FailFast))
case *stats.InPayload:
span.AddMessageReceiveEvent(0 /* TODO: messageID */, int64(rs.Length), int64(rs.WireLength))
case *stats.OutPayload:
span.AddMessageSendEvent(0, int64(rs.Length), int64(rs.WireLength))
case *stats.End:
if rs.Error != nil {
code, desc := grpc.Code(rs.Error), grpc.ErrorDesc(rs.Error)
span.SetStatus(trace.Status{Code: int32(code), Message: desc})
s, ok := status.FromError(rs.Error)
if ok {
span.SetStatus(trace.Status{Code: int32(s.Code()), Message: s.Message()})
} else {
span.SetStatus(trace.Status{Code: int32(codes.Internal), Message: rs.Error.Error()})
}
}
span.End()
}