The opencensus API changes between 0.6.0 and 0.9.0 (#980)

We get some useful features in later versions; update so as to not
pin downstream consumers (extensions) to an older version.
This commit is contained in:
jan grant
2018-05-09 14:55:00 +01:00
committed by GitHub
parent feab2f0e0f
commit 91e58afa55
109 changed files with 2924 additions and 2344 deletions

View File

@@ -58,8 +58,8 @@ func TestClientDefaultCollections(t *testing.T) {
}
tcs := []testCase{
{
"1",
[]*rpc{
label: "1",
rpcs: []*rpc{
{
[]tagPair{{k1, "v1"}},
&stats.RPCTagInfo{FullMethodName: "/package.service/method"},
@@ -72,46 +72,46 @@ func TestClientDefaultCollections(t *testing.T) {
&stats.End{Error: nil},
},
},
[]*wantData{
wants: []*wantData{
{
func() *view.View { return ClientRequestCountView },
func() *view.View { return ClientSentMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1, 1, 1, 1, 0),
},
},
},
{
func() *view.View { return ClientResponseCountView },
func() *view.View { return ClientReceivedMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1, 1, 1, 1, 0),
},
},
},
{
func() *view.View { return ClientRequestBytesView },
func() *view.View { return ClientSentBytesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1, 10, 10, 10, 0),
},
},
},
{
func() *view.View { return ClientResponseBytesView },
func() *view.View { return ClientReceivedBytesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 1, 10, 10, 10, 0),
},
@@ -120,8 +120,8 @@ func TestClientDefaultCollections(t *testing.T) {
},
},
{
"2",
[]*rpc{
label: "2",
rpcs: []*rpc{
{
[]tagPair{{k1, "v1"}},
&stats.RPCTagInfo{FullMethodName: "/package.service/method"},
@@ -149,36 +149,24 @@ func TestClientDefaultCollections(t *testing.T) {
&stats.End{Error: status.Error(codes.Canceled, "canceled")},
},
},
[]*wantData{
wants: []*wantData{
{
func() *view.View { return ClientErrorCountView },
func() *view.View { return ClientSentMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyStatus, Value: "Canceled"},
{Key: KeyMethod, Value: "package.service/method"},
},
Data: newMeanData(1, 1),
},
},
},
{
func() *view.View { return ClientRequestCountView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2, 2, 3, 2.5, 0.5),
},
},
},
{
func() *view.View { return ClientResponseCountView },
func() *view.View { return ClientReceivedMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2, 1, 2, 1.5, 0.5),
},
@@ -187,8 +175,8 @@ func TestClientDefaultCollections(t *testing.T) {
},
},
{
"3",
[]*rpc{
label: "3",
rpcs: []*rpc{
{
[]tagPair{{k1, "v1"}},
&stats.RPCTagInfo{FullMethodName: "/package.service/method"},
@@ -229,67 +217,48 @@ func TestClientDefaultCollections(t *testing.T) {
&stats.End{Error: status.Error(codes.Aborted, "aborted")},
},
},
[]*wantData{
wants: []*wantData{
{
func() *view.View { return ClientErrorCountView },
func() *view.View { return ClientSentMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyStatus, Value: "Canceled"},
{Key: KeyMethod, Value: "package.service/method"},
},
Data: newMeanData(1, 1),
},
{
Tags: []tag.Tag{
{Key: KeyStatus, Value: "Aborted"},
{Key: KeyMethod, Value: "package.service/method"},
},
Data: newMeanData(1, 1),
},
},
},
{
func() *view.View { return ClientRequestCountView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 3, 2, 3, 2.666666666, 0.333333333*2),
},
},
},
{
func() *view.View { return ClientResponseCountView },
func() *view.View { return ClientReceivedMessagesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 3, 1, 2, 1.333333333, 0.333333333*2),
},
},
},
{
func() *view.View { return ClientRequestBytesView },
func() *view.View { return ClientSentBytesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 1, 1, 1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0}, 8, 1, 65536, 13696.125, 481423542.982143*7),
Data: newDistributionData([]int64{0, 0, 0, 0, 0, 2 /*16384*/, 1 /*65536*/, 0, 0, 0, 0, 0, 0, 0, 0}, 3, 20480, 66561, 36523, 1.355519318e+09),
},
},
},
{
func() *view.View { return ClientResponseBytesView },
func() *view.View { return ClientReceivedBytesPerRPCView },
[]*view.Row{
{
Tags: []tag.Tag{
{Key: KeyMethod, Value: "package.service/method"},
{Key: KeyClientMethod, Value: "package.service/method"},
},
Data: newDistributionData([]int64{0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 4, 1, 16384, 4864.25, 59678208.25*3),
Data: newDistributionData([]int64{0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 3, 1, 18432, 6485.666667, 2.1459558466666666e+08),
},
},
},
@@ -297,16 +266,25 @@ func TestClientDefaultCollections(t *testing.T) {
},
}
views := []*view.View{
ClientSentBytesPerRPCView,
ClientReceivedBytesPerRPCView,
ClientRoundtripLatencyView,
ClientCompletedRPCsView,
ClientSentMessagesPerRPCView,
ClientReceivedMessagesPerRPCView,
}
for _, tc := range tcs {
// Register views.
if err := view.Subscribe(DefaultClientViews...); err != nil {
if err := view.Register(views...); err != nil {
t.Error(err)
}
h := &ClientHandler{}
h.StartOptions.Sampler = trace.NeverSample()
for _, rpc := range tc.rpcs {
mods := []tag.Mutator{}
var mods []tag.Mutator
for _, t := range rpc.tags {
mods = append(mods, tag.Upsert(t.k, t.v))
}
@@ -318,11 +296,14 @@ func TestClientDefaultCollections(t *testing.T) {
ctx = stats.SetTags(context.Background(), encoded)
ctx = h.TagRPC(ctx, rpc.tagInfo)
for _, out := range rpc.outPayloads {
out.Client = true
h.HandleRPC(ctx, out)
}
for _, in := range rpc.inPayloads {
in.Client = true
h.HandleRPC(ctx, in)
}
rpc.end.Client = true
h.HandleRPC(ctx, rpc.end)
}
@@ -349,7 +330,7 @@ func TestClientDefaultCollections(t *testing.T) {
}
// Unregister views to cleanup.
view.Unsubscribe(DefaultClientViews...)
view.Unregister(views...)
}
}