Update dependenciess

Exclude minio-go for now (pin to 3.x.y).
This commit is contained in:
Alexander Neumann
2017-12-03 21:01:25 +01:00
parent 9d0f13c4c0
commit 946c8399e2
2985 changed files with 1008107 additions and 118934 deletions

View File

@@ -14,15 +14,16 @@
// AUTO-GENERATED CODE. DO NOT EDIT.
// Package trace is an experimental, auto-generated package for the
// Package trace is an auto-generated package for the
// Stackdriver Trace API.
//
// NOTE: This package is in alpha. It is not stable, and is likely to be subject to changes.
//
// Send and retrieve trace data from Stackdriver Trace. Data is generated and
// available by default for all App Engine applications. Data from other
// applications can be written to Stackdriver Trace for display, reporting,
// and analysis.
//
// Use the client at cloud.google.com/go/trace in preference to this.
// and
// analysis.
package trace // import "cloud.google.com/go/trace/apiv1"
import (
@@ -30,11 +31,15 @@ import (
"google.golang.org/grpc/metadata"
)
func insertXGoog(ctx context.Context, val []string) context.Context {
md, _ := metadata.FromOutgoingContext(ctx)
md = md.Copy()
md["x-goog-api-client"] = val
return metadata.NewOutgoingContext(ctx, md)
func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context {
out, _ := metadata.FromOutgoingContext(ctx)
out = out.Copy()
for _, md := range mds {
for k, v := range md {
out[k] = append(out[k], v...)
}
}
return metadata.NewOutgoingContext(ctx, out)
}
// DefaultAuthScopes reports the default set of authentication scopes to use with this package.

View File

@@ -126,127 +126,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
func TestTraceServicePatchTraces(t *testing.T) {
var expectedResponse *emptypb.Empty = &emptypb.Empty{}
mockTrace.err = nil
mockTrace.reqs = nil
mockTrace.resps = append(mockTrace.resps[:0], expectedResponse)
var projectId string = "projectId-1969970175"
var traces *cloudtracepb.Traces = &cloudtracepb.Traces{}
var request = &cloudtracepb.PatchTracesRequest{
ProjectId: projectId,
Traces: traces,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.PatchTraces(context.Background(), request)
if err != nil {
t.Fatal(err)
}
if want, got := request, mockTrace.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
}
func TestTraceServicePatchTracesError(t *testing.T) {
errCode := codes.PermissionDenied
mockTrace.err = gstatus.Error(errCode, "test error")
var projectId string = "projectId-1969970175"
var traces *cloudtracepb.Traces = &cloudtracepb.Traces{}
var request = &cloudtracepb.PatchTracesRequest{
ProjectId: projectId,
Traces: traces,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.PatchTraces(context.Background(), request)
if st, ok := gstatus.FromError(err); !ok {
t.Errorf("got error %v, expected grpc error", err)
} else if c := st.Code(); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
}
func TestTraceServiceGetTrace(t *testing.T) {
var projectId2 string = "projectId2939242356"
var traceId2 string = "traceId2987826376"
var expectedResponse = &cloudtracepb.Trace{
ProjectId: projectId2,
TraceId: traceId2,
}
mockTrace.err = nil
mockTrace.reqs = nil
mockTrace.resps = append(mockTrace.resps[:0], expectedResponse)
var projectId string = "projectId-1969970175"
var traceId string = "traceId1270300245"
var request = &cloudtracepb.GetTraceRequest{
ProjectId: projectId,
TraceId: traceId,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.GetTrace(context.Background(), request)
if err != nil {
t.Fatal(err)
}
if want, got := request, mockTrace.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
if want, got := expectedResponse, resp; !proto.Equal(want, got) {
t.Errorf("wrong response %q, want %q)", got, want)
}
}
func TestTraceServiceGetTraceError(t *testing.T) {
errCode := codes.PermissionDenied
mockTrace.err = gstatus.Error(errCode, "test error")
var projectId string = "projectId-1969970175"
var traceId string = "traceId1270300245"
var request = &cloudtracepb.GetTraceRequest{
ProjectId: projectId,
TraceId: traceId,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.GetTrace(context.Background(), request)
if st, ok := gstatus.FromError(err); !ok {
t.Errorf("got error %v, expected grpc error", err)
} else if c := st.Code(); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
_ = resp
}
func TestTraceServiceListTraces(t *testing.T) {
var nextPageToken string = ""
var tracesElement *cloudtracepb.Trace = &cloudtracepb.Trace{}
@@ -319,3 +198,124 @@ func TestTraceServiceListTracesError(t *testing.T) {
}
_ = resp
}
func TestTraceServiceGetTrace(t *testing.T) {
var projectId2 string = "projectId2939242356"
var traceId2 string = "traceId2987826376"
var expectedResponse = &cloudtracepb.Trace{
ProjectId: projectId2,
TraceId: traceId2,
}
mockTrace.err = nil
mockTrace.reqs = nil
mockTrace.resps = append(mockTrace.resps[:0], expectedResponse)
var projectId string = "projectId-1969970175"
var traceId string = "traceId1270300245"
var request = &cloudtracepb.GetTraceRequest{
ProjectId: projectId,
TraceId: traceId,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.GetTrace(context.Background(), request)
if err != nil {
t.Fatal(err)
}
if want, got := request, mockTrace.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
if want, got := expectedResponse, resp; !proto.Equal(want, got) {
t.Errorf("wrong response %q, want %q)", got, want)
}
}
func TestTraceServiceGetTraceError(t *testing.T) {
errCode := codes.PermissionDenied
mockTrace.err = gstatus.Error(errCode, "test error")
var projectId string = "projectId-1969970175"
var traceId string = "traceId1270300245"
var request = &cloudtracepb.GetTraceRequest{
ProjectId: projectId,
TraceId: traceId,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
resp, err := c.GetTrace(context.Background(), request)
if st, ok := gstatus.FromError(err); !ok {
t.Errorf("got error %v, expected grpc error", err)
} else if c := st.Code(); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
_ = resp
}
func TestTraceServicePatchTraces(t *testing.T) {
var expectedResponse *emptypb.Empty = &emptypb.Empty{}
mockTrace.err = nil
mockTrace.reqs = nil
mockTrace.resps = append(mockTrace.resps[:0], expectedResponse)
var projectId string = "projectId-1969970175"
var traces *cloudtracepb.Traces = &cloudtracepb.Traces{}
var request = &cloudtracepb.PatchTracesRequest{
ProjectId: projectId,
Traces: traces,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.PatchTraces(context.Background(), request)
if err != nil {
t.Fatal(err)
}
if want, got := request, mockTrace.reqs[0]; !proto.Equal(want, got) {
t.Errorf("wrong request %q, want %q", got, want)
}
}
func TestTraceServicePatchTracesError(t *testing.T) {
errCode := codes.PermissionDenied
mockTrace.err = gstatus.Error(errCode, "test error")
var projectId string = "projectId-1969970175"
var traces *cloudtracepb.Traces = &cloudtracepb.Traces{}
var request = &cloudtracepb.PatchTracesRequest{
ProjectId: projectId,
Traces: traces,
}
c, err := NewClient(context.Background(), clientOpt)
if err != nil {
t.Fatal(err)
}
err = c.PatchTraces(context.Background(), request)
if st, ok := gstatus.FromError(err); !ok {
t.Errorf("got error %v, expected grpc error", err)
} else if c := st.Code(); c != errCode {
t.Errorf("got error code %q, want %q", c, errCode)
}
}

View File

@@ -29,13 +29,14 @@ import (
cloudtracepb "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
)
// CallOptions contains the retry settings for each method of Client.
type CallOptions struct {
PatchTraces []gax.CallOption
GetTrace []gax.CallOption
ListTraces []gax.CallOption
GetTrace []gax.CallOption
PatchTraces []gax.CallOption
}
func defaultClientOptions() []option.ClientOption {
@@ -61,9 +62,9 @@ func defaultCallOptions() *CallOptions {
},
}
return &CallOptions{
PatchTraces: retry[[2]string{"default", "idempotent"}],
GetTrace: retry[[2]string{"default", "idempotent"}],
ListTraces: retry[[2]string{"default", "idempotent"}],
GetTrace: retry[[2]string{"default", "idempotent"}],
PatchTraces: retry[[2]string{"write_sink", "non_idempotent"}],
}
}
@@ -79,7 +80,7 @@ type Client struct {
CallOptions *CallOptions
// The metadata to be sent with each request.
xGoogHeader []string
Metadata metadata.MD
}
// NewClient creates a new trace service client.
@@ -100,7 +101,7 @@ func NewClient(ctx context.Context, opts ...option.ClientOption) (*Client, error
client: cloudtracepb.NewTraceServiceClient(conn),
}
c.SetGoogleClientInfo()
c.setGoogleClientInfo()
return c, nil
}
@@ -115,50 +116,18 @@ func (c *Client) Close() error {
return c.conn.Close()
}
// SetGoogleClientInfo sets the name and version of the application in
// setGoogleClientInfo sets the name and version of the application in
// the `x-goog-api-client` header passed on each request. Intended for
// use by Google-written clients.
func (c *Client) SetGoogleClientInfo(keyval ...string) {
func (c *Client) setGoogleClientInfo(keyval ...string) {
kv := append([]string{"gl-go", version.Go()}, keyval...)
kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
c.xGoogHeader = []string{gax.XGoogHeader(kv...)}
}
// PatchTraces sends new traces to Stackdriver Trace or updates existing traces. If the ID
// of a trace that you send matches that of an existing trace, any fields
// in the existing trace and its spans are overwritten by the provided values,
// and any new fields provided are merged with the existing trace data. If the
// ID does not match, a new trace is created.
func (c *Client) PatchTraces(ctx context.Context, req *cloudtracepb.PatchTracesRequest, opts ...gax.CallOption) error {
ctx = insertXGoog(ctx, c.xGoogHeader)
opts = append(c.CallOptions.PatchTraces[0:len(c.CallOptions.PatchTraces):len(c.CallOptions.PatchTraces)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = c.client.PatchTraces(ctx, req, settings.GRPC...)
return err
}, opts...)
return err
}
// GetTrace gets a single trace by its ID.
func (c *Client) GetTrace(ctx context.Context, req *cloudtracepb.GetTraceRequest, opts ...gax.CallOption) (*cloudtracepb.Trace, error) {
ctx = insertXGoog(ctx, c.xGoogHeader)
opts = append(c.CallOptions.GetTrace[0:len(c.CallOptions.GetTrace):len(c.CallOptions.GetTrace)], opts...)
var resp *cloudtracepb.Trace
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.client.GetTrace(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
c.Metadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
}
// ListTraces returns of a list of traces that match the specified filter conditions.
func (c *Client) ListTraces(ctx context.Context, req *cloudtracepb.ListTracesRequest, opts ...gax.CallOption) *TraceIterator {
ctx = insertXGoog(ctx, c.xGoogHeader)
ctx = insertMetadata(ctx, c.Metadata)
opts = append(c.CallOptions.ListTraces[0:len(c.CallOptions.ListTraces):len(c.CallOptions.ListTraces)], opts...)
it := &TraceIterator{}
it.InternalFetch = func(pageSize int, pageToken string) ([]*cloudtracepb.Trace, string, error) {
@@ -191,6 +160,38 @@ func (c *Client) ListTraces(ctx context.Context, req *cloudtracepb.ListTracesReq
return it
}
// GetTrace gets a single trace by its ID.
func (c *Client) GetTrace(ctx context.Context, req *cloudtracepb.GetTraceRequest, opts ...gax.CallOption) (*cloudtracepb.Trace, error) {
ctx = insertMetadata(ctx, c.Metadata)
opts = append(c.CallOptions.GetTrace[0:len(c.CallOptions.GetTrace):len(c.CallOptions.GetTrace)], opts...)
var resp *cloudtracepb.Trace
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
resp, err = c.client.GetTrace(ctx, req, settings.GRPC...)
return err
}, opts...)
if err != nil {
return nil, err
}
return resp, nil
}
// PatchTraces sends new traces to Stackdriver Trace or updates existing traces. If the ID
// of a trace that you send matches that of an existing trace, any fields
// in the existing trace and its spans are overwritten by the provided values,
// and any new fields provided are merged with the existing trace data. If the
// ID does not match, a new trace is created.
func (c *Client) PatchTraces(ctx context.Context, req *cloudtracepb.PatchTracesRequest, opts ...gax.CallOption) error {
ctx = insertMetadata(ctx, c.Metadata)
opts = append(c.CallOptions.PatchTraces[0:len(c.CallOptions.PatchTraces):len(c.CallOptions.PatchTraces)], opts...)
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
var err error
_, err = c.client.PatchTraces(ctx, req, settings.GRPC...)
return err
}, opts...)
return err
}
// TraceIterator manages a stream of *cloudtracepb.Trace.
type TraceIterator struct {
items []*cloudtracepb.Trace

View File

@@ -33,40 +33,6 @@ func ExampleNewClient() {
_ = c
}
func ExampleClient_PatchTraces() {
ctx := context.Background()
c, err := trace.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &cloudtracepb.PatchTracesRequest{
// TODO: Fill request struct fields.
}
err = c.PatchTraces(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func ExampleClient_GetTrace() {
ctx := context.Background()
c, err := trace.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &cloudtracepb.GetTraceRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetTrace(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_ListTraces() {
ctx := context.Background()
c, err := trace.NewClient(ctx)
@@ -90,3 +56,37 @@ func ExampleClient_ListTraces() {
_ = resp
}
}
func ExampleClient_GetTrace() {
ctx := context.Background()
c, err := trace.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &cloudtracepb.GetTraceRequest{
// TODO: Fill request struct fields.
}
resp, err := c.GetTrace(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func ExampleClient_PatchTraces() {
ctx := context.Background()
c, err := trace.NewClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &cloudtracepb.PatchTracesRequest{
// TODO: Fill request struct fields.
}
err = c.PatchTraces(ctx, req)
if err != nil {
// TODO: Handle error.
}
}

View File

@@ -142,7 +142,7 @@ func testGRPCInterceptor(t *testing.T, tc *Client, parent *Span, assert func(t *
}()
addr := <-addrCh
conn, err := grpc.Dial(addr.String(), grpc.WithInsecure(), grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor()))
conn, err := grpc.Dial(addr.String(), grpc.WithInsecure(), grpc.WithBlock(), grpc.WithUnaryInterceptor(tc.GRPCClientInterceptor()))
if err != nil {
t.Fatalf("Did not connect: %v", err)
}

View File

@@ -316,6 +316,7 @@ func TestTraceFromHeaderWithWait(t *testing.T) {
}
func TestNewSpan(t *testing.T) {
t.Skip("flaky")
const traceID = "0123456789ABCDEF0123456789ABCDEF"
rt := newFakeRoundTripper()
@@ -395,11 +396,7 @@ func TestNewSpan(t *testing.T) {
t.Fatal(err)
}
if len(patch.Traces) != len(expected.Traces) || len(patch.Traces[0].Spans) != len(expected.Traces[0].Spans) {
got, _ := json.Marshal(patch)
want, _ := json.Marshal(expected)
t.Fatalf("PatchTraces request: got %s want %s", got, want)
}
checkTraces(t, patch, expected)
n := len(patch.Traces[0].Spans)
rootSpan := patch.Traces[0].Spans[n-1]
@@ -464,6 +461,7 @@ func TestNewSpan(t *testing.T) {
}
func testTrace(t *testing.T, synchronous bool, fromRequest bool) {
t.Skip("flaky")
const header = `0123456789ABCDEF0123456789ABCDEF/42;o=3`
rt := newFakeRoundTripper()
traceClient := newTestClient(rt)
@@ -558,11 +556,7 @@ func testTrace(t *testing.T, synchronous bool, fromRequest bool) {
t.Fatal(err)
}
if len(patch.Traces) != len(expected.Traces) || len(patch.Traces[0].Spans) != len(expected.Traces[0].Spans) {
got, _ := json.Marshal(patch)
want, _ := json.Marshal(expected)
t.Fatalf("PatchTraces request: got %s want %s", got, want)
}
checkTraces(t, patch, expected)
n := len(patch.Traces[0].Spans)
rootSpan := patch.Traces[0].Spans[n-1]
@@ -952,3 +946,24 @@ func TestPropagation(t *testing.T) {
}
}
}
func BenchmarkSpanFromHeader(b *testing.B) {
const header = `0123456789ABCDEF0123456789ABCDEF/42;o=0`
const name = "/foo"
rt := newFakeRoundTripper()
traceClient := newTestClient(rt)
for n := 0; n < b.N; n++ {
traceClient.SpanFromHeader(name, header)
}
}
func checkTraces(t *testing.T, patch, expected api.Traces) {
if len(patch.Traces) != len(expected.Traces) || len(patch.Traces[0].Spans) != len(expected.Traces[0].Spans) {
diff := testutil.Diff(patch.Traces, expected.Traces)
t.Logf("diff:\n%s", diff)
got, _ := json.Marshal(patch)
want, _ := json.Marshal(expected)
t.Fatalf("PatchTraces request: got %s want %s", got, want)
}
}