Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/trace: add support for meta_struct span proto field #10366

Merged
merged 14 commits into from
Feb 18, 2022
2 changes: 1 addition & 1 deletion pkg/trace/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ func TestHandleTraces(t *testing.T) {
ts, ok := rs.Stats[info.Tags{Lang: lang, EndpointVersion: "v0.4"}]
assert.True(ok)
assert.Equal(int64(20), ts.TracesReceived)
assert.Equal(int64(59222), ts.TracesBytes)
assert.Equal(int64(61822), ts.TracesBytes)
}
// make sure we have all our languages registered
assert.Equal("C#|go|java|python|ruby", receiver.Languages())
Expand Down
28 changes: 15 additions & 13 deletions pkg/trace/api/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,22 @@ func (r *HTTPReceiver) makeInfoHandler() (hash string, handler http.HandlerFunc)
oconf.Memcached = o.Memcached.Enabled
}
txt, err := json.MarshalIndent(struct {
Version string `json:"version"`
GitCommit string `json:"git_commit"`
BuildDate string `json:"build_date"`
Endpoints []string `json:"endpoints"`
FeatureFlags []string `json:"feature_flags,omitempty"`
ClientDropP0s bool `json:"client_drop_p0s"`
Config reducedConfig `json:"config"`
Version string `json:"version"`
GitCommit string `json:"git_commit"`
BuildDate string `json:"build_date"`
Endpoints []string `json:"endpoints"`
FeatureFlags []string `json:"feature_flags,omitempty"`
ClientDropP0s bool `json:"client_drop_p0s"`
SpanMetaStructs bool `json:"span_meta_structs"`
Config reducedConfig `json:"config"`
}{
Version: info.Version,
GitCommit: info.GitCommit,
BuildDate: info.BuildDate,
Endpoints: all,
FeatureFlags: features.All(),
ClientDropP0s: true,
Version: info.Version,
GitCommit: info.GitCommit,
BuildDate: info.BuildDate,
Endpoints: all,
FeatureFlags: features.All(),
ClientDropP0s: true,
SpanMetaStructs: true,
Config: reducedConfig{
DefaultEnv: r.conf.DefaultEnv,
TargetTPS: r.conf.TargetTPS,
Expand Down
2 changes: 2 additions & 0 deletions pkg/trace/api/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func TestInfoHandler(t *testing.T) {
"feature_flag"
],
"client_drop_p0s": true,
"span_meta_structs": true,
"config": {
"default_env": "prod",
"target_tps": 11,
Expand Down Expand Up @@ -195,6 +196,7 @@ func TestInfoHandler(t *testing.T) {
"config_endpoint"
],
"client_drop_p0s": true,
"span_meta_structs": true,
"config": {
"default_env": "prod",
"target_tps": 11,
Expand Down
17 changes: 17 additions & 0 deletions pkg/trace/pb/decoder_bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,20 @@ func parseInt32Bytes(bts []byte) (int32, []byte, error) {
return 0, bts, msgp.TypeError{Encoded: t, Method: msgp.IntType}
}
}

// parseBytes reads the next BinType in the msgpack payload.
func parseBytes(bts []byte) ([]byte, []byte, error) {
if msgp.IsNil(bts) {
bts, err := msgp.ReadNilBytes(bts)
return nil, bts, err
}
// read the generic representation type without decoding
t := msgp.NextType(bts)

switch t {
case msgp.BinType:
return msgp.ReadBytesZC(bts)
default:
return nil, bts, msgp.TypeError{Encoded: t, Method: msgp.BinType}
}
}
252 changes: 208 additions & 44 deletions pkg/trace/pb/span.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/trace/pb/span.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ message Span {
map<string, string> meta = 10 [(gogoproto.jsontag) = "meta", (gogoproto.moretags) = "msg:\"meta\""];
map<string, double> metrics = 11 [(gogoproto.jsontag) = "metrics", (gogoproto.moretags) = "msg:\"metrics\""];
string type = 12 [(gogoproto.jsontag) = "type", (gogoproto.moretags) = "msg:\"type\""];
map<string, bytes> meta_struct = 13 [(gogoproto.jsontag) = "meta_struct,omitempty", (gogoproto.moretags) = "msg:\"meta_struct\""];
}
Loading