@@ -60,9 +60,9 @@ func TestPayloadIntegrity(t *testing.T) {
60
60
}
61
61
}
62
62
63
- // TestPayloadDecode ensures that whatever we push into the payload can
63
+ // TestPayloadV04Decode ensures that whatever we push into a v0.4 payload can
64
64
// be decoded by the codec.
65
- func TestPayloadDecode (t * testing.T ) {
65
+ func TestPayloadV04Decode (t * testing.T ) {
66
66
for _ , n := range []int {10 , 1 << 10 } {
67
67
t .Run (strconv .Itoa (n ), func (t * testing.T ) {
68
68
assert := assert .New (t )
@@ -77,6 +77,46 @@ func TestPayloadDecode(t *testing.T) {
77
77
}
78
78
}
79
79
80
+ // TestPayloadV1Decode ensures that whatever we push into a v1 payload can
81
+ // be decoded by the codec, and that it matches the original payload.
82
+ func TestPayloadV1Decode (t * testing.T ) {
83
+ for _ , n := range []int {10 , 1 << 10 } {
84
+ t .Run (strconv .Itoa (n ), func (t * testing.T ) {
85
+ assert := assert .New (t )
86
+ p := newPayloadV1 ()
87
+
88
+ p .containerID = "containerID"
89
+ p .languageName = "languageName"
90
+ p .languageVersion = "languageVersion"
91
+ p .tracerVersion = "tracerVersion"
92
+ p .runtimeID = "runtimeID"
93
+ p .env = "env"
94
+ p .hostname = "hostname"
95
+ p .appVersion = "appVersion"
96
+
97
+ for i := 0 ; i < n ; i ++ {
98
+ _ , _ = p .push (newSpanList (i % 5 + 1 ))
99
+ }
100
+
101
+ encoded , err := io .ReadAll (p )
102
+ assert .NoError (err )
103
+
104
+ got := newPayloadV1 ()
105
+ _ , err = got .Decode (encoded )
106
+ assert .NoError (err )
107
+
108
+ assert .Equal (p .containerID , got .containerID )
109
+ assert .Equal (p .languageName , got .languageName )
110
+ assert .Equal (p .languageVersion , got .languageVersion )
111
+ assert .Equal (p .tracerVersion , got .tracerVersion )
112
+ assert .Equal (p .runtimeID , got .runtimeID )
113
+ assert .Equal (p .env , got .env )
114
+ assert .Equal (p .hostname , got .hostname )
115
+ assert .Equal (p .appVersion , got .appVersion )
116
+ })
117
+ }
118
+ }
119
+
80
120
func BenchmarkPayloadThroughput (b * testing.B ) {
81
121
b .Run ("10K" , benchmarkPayloadThroughput (1 ))
82
122
b .Run ("100K" , benchmarkPayloadThroughput (10 ))
0 commit comments