@@ -28,7 +28,6 @@ import (
2828 "github.com/stretchr/testify/assert"
2929 "github.com/stretchr/testify/require"
3030 "google.golang.org/protobuf/testing/protocmp"
31- "google.golang.org/protobuf/types/known/timestamppb"
3231
3332 "github.com/elastic/apm-data/input/elasticapm/internal/decoder"
3433 "github.com/elastic/apm-data/input/elasticapm/internal/modeldecoder"
@@ -47,9 +46,9 @@ func TestResetTransactionOnRelease(t *testing.T) {
4746
4847func TestDecodeNestedTransaction (t * testing.T ) {
4948 t .Run ("decode" , func (t * testing.T ) {
50- now := time .Now (). UTC ( )
49+ now := modelpb . FromTime ( time .Now ())
5150 eventBase := initializedMetadata ()
52- eventBase .Timestamp = timestamppb . New ( now )
51+ eventBase .Timestamp = now
5352 input := modeldecoder.Input {Base : eventBase }
5453 str := `{"x":{"n":"tr-a","d":100,"id":"100","tid":"1","t":"request","yc":{"sd":2},"y":[{"n":"a","d":10,"t":"http","id":"123","s":20}],"me":[{"sa":{"ysc":{"v":5}},"y":{"t":"span_type","su":"span_subtype"}}]}}`
5554 dec := decoder .NewJSONDecoder (strings .NewReader (str ))
@@ -62,7 +61,7 @@ func TestDecodeNestedTransaction(t *testing.T) {
6261
6362 assert .Equal (t , "request" , batch [0 ].Transaction .Type )
6463 // fall back to request time
65- assert .Equal (t , now , batch [0 ].Timestamp . AsTime () )
64+ assert .Equal (t , now , batch [0 ].Timestamp )
6665
6766 // Ensure nested metricsets are decoded. RUMv3 only sends
6867 // breakdown metrics, so the Metricsets will be empty and
@@ -78,11 +77,11 @@ func TestDecodeNestedTransaction(t *testing.T) {
7877 Subtype : "span_subtype" ,
7978 SelfTime : & modelpb.AggregatedDuration {Count : 5 },
8079 }, batch [1 ].Span , protocmp .Transform ()))
81- assert .Equal (t , now , batch [1 ].Timestamp . AsTime () )
80+ assert .Equal (t , now , batch [1 ].Timestamp )
8281
8382 // ensure nested spans are decoded
84- start := time .Duration (20 * 1000 * 1000 )
85- assert .Equal (t , now . Add ( start ) , batch [2 ].Timestamp . AsTime () ) // add start to timestamp
83+ start := uint64 ( time .Duration (20 * 1000 * 1000 ). Nanoseconds () )
84+ assert .Equal (t , now + start , batch [2 ].Timestamp ) // add start to timestamp
8685 assert .Equal (t , "100" , batch [2 ].Transaction .Id )
8786 assert .Equal (t , "1" , batch [2 ].Trace .Id )
8887 assert .Equal (t , "100" , batch [2 ].ParentId )
@@ -93,8 +92,8 @@ func TestDecodeNestedTransaction(t *testing.T) {
9392 })
9493
9594 t .Run ("decode-marks" , func (t * testing.T ) {
96- now := time .Now ()
97- eventBase := modelpb.APMEvent {Timestamp : timestamppb . New ( now ) }
95+ now := modelpb . FromTime ( time .Now () )
96+ eventBase := modelpb.APMEvent {Timestamp : now }
9897 input := modeldecoder.Input {Base : & eventBase }
9998 str := `{"x":{"d":100,"id":"100","tid":"1","t":"request","yc":{"sd":2},"k":{"a":{"dc":0.1,"di":0.2,"ds":0.3,"de":0.4,"fb":0.5,"fp":0.6,"lp":0.7,"long":0.8},"nt":{"fs":0.1,"ls":0.2,"le":0.3,"cs":0.4,"ce":0.5,"qs":0.6,"rs":0.7,"re":0.8,"dl":0.9,"di":0.11,"ds":0.21,"de":0.31,"dc":0.41,"es":0.51,"ee":6,"long":0.99},"long":{"long":0.1}}}}`
10099 dec := decoder .NewJSONDecoder (strings .NewReader (str ))
@@ -215,16 +214,16 @@ func TestDecodeMapToTransactionModel(t *testing.T) {
215214
216215 var input transaction
217216 var out1 , out2 modelpb.APMEvent
218- reqTime := time .Now ().Add (time .Second )
219- out1 .Timestamp = timestamppb . New ( reqTime )
217+ reqTime := modelpb . FromTime ( time .Now ().Add (time .Second ) )
218+ out1 .Timestamp = reqTime
220219 defaultVal := modeldecodertest .DefaultValues ()
221220 modeldecodertest .SetStructValues (& input , defaultVal )
222221 mapToTransactionModel (& input , & out1 )
223222 input .Reset ()
224223 modeldecodertest .AssertStructValues (t , out1 .Transaction , exceptions , defaultVal )
225224
226225 // ensure memory is not shared by reusing input model
227- out2 .Timestamp = timestamppb . New ( reqTime )
226+ out2 .Timestamp = reqTime
228227 otherVal := modeldecodertest .NonDefaultValues ()
229228 modeldecodertest .SetStructValues (& input , otherVal )
230229 mapToTransactionModel (& input , & out2 )
@@ -267,16 +266,16 @@ func TestDecodeMapToTransactionModel(t *testing.T) {
267266
268267 var input span
269268 var out1 , out2 modelpb.APMEvent
270- reqTime := time .Now ().Add (time .Second )
271- out1 .Timestamp = timestamppb . New ( reqTime )
269+ reqTime := modelpb . FromTime ( time .Now ().Add (time .Second ) )
270+ out1 .Timestamp = reqTime
272271 defaultVal := modeldecodertest .DefaultValues ()
273272 modeldecodertest .SetStructValues (& input , defaultVal )
274273 mapToSpanModel (& input , & out1 )
275274 input .Reset ()
276275 modeldecodertest .AssertStructValues (t , out1 .Span , exceptions , defaultVal )
277276
278277 // ensure memory is not shared by reusing input model
279- out2 .Timestamp = timestamppb . New ( reqTime )
278+ out2 .Timestamp = reqTime
280279 otherVal := modeldecodertest .NonDefaultValues ()
281280 modeldecodertest .SetStructValues (& input , otherVal )
282281 mapToSpanModel (& input , & out2 )
0 commit comments