diff --git a/src/Stackdriver/SpanConverter.php b/src/Stackdriver/SpanConverter.php index ead80bb..4bd8beb 100644 --- a/src/Stackdriver/SpanConverter.php +++ b/src/Stackdriver/SpanConverter.php @@ -120,7 +120,8 @@ private static function convertTimeEvents(array $events) private static function convertAnnotation(OCAnnotation $annotation) { return new Annotation($annotation->description(), [ - 'attributes' => $annotation->attributes() + 'attributes' => $annotation->attributes(), + 'time' => $annotation->time() ]); } @@ -129,7 +130,8 @@ private static function convertMessageEvent(OCMessageEvent $messageEvent) return new MessageEvent($messageEvent->id(), [ 'type' => self::MESSAGE_TYPE_MAP[$messageEvent->type()], 'uncompressedSizeBytes' => $messageEvent->uncompressedSize(), - 'compressedSizeBytes' => $messageEvent->compressedSize() + 'compressedSizeBytes' => $messageEvent->compressedSize(), + 'time' => $messageEvent->time() ]); } diff --git a/tests/unit/Stackdriver/SpanConverterTest.php b/tests/unit/Stackdriver/SpanConverterTest.php index caaa8f0..7f10965 100644 --- a/tests/unit/Stackdriver/SpanConverterTest.php +++ b/tests/unit/Stackdriver/SpanConverterTest.php @@ -157,15 +157,18 @@ public function testLinks() public function testTimeEvents() { + $time = 1490737450.484299; $span = new OCSpan([ 'traceId' => 'aaa', 'timeEvents' => [ new OCAnnotation('some-description', [ - 'attributes' => ['foo' => 'bar'] + 'attributes' => ['foo' => 'bar'], + 'time' => $time ]), new OCMessageEvent(OCMessageEvent::TYPE_SENT, 'message-id', [ 'uncompressedSize' => 234, - 'compressedSize' => 123 + 'compressedSize' => 123, + 'time' => $time ]) ], 'startTime' => new \DateTime(), @@ -179,6 +182,7 @@ public function testTimeEvents() $event1 = $timeEvents[0]; $this->assertEquals('some-description', $event1['annotation']['description']['value']); $this->assertRegExp(self::TIMESTAMP_FORMAT_REGEXP, $event1['time']); + $this->assertEquals('2017-03-28T21:44:10.484299000Z', $event1['time']); $event2 = $timeEvents[1]; $this->assertEquals('SENT', $event2['messageEvent']['type']); @@ -186,6 +190,7 @@ public function testTimeEvents() $this->assertEquals(234, $event2['messageEvent']['uncompressedSizeBytes']); $this->assertEquals(123, $event2['messageEvent']['compressedSizeBytes']); $this->assertRegExp(self::TIMESTAMP_FORMAT_REGEXP, $event2['time']); + $this->assertEquals('2017-03-28T21:44:10.484299000Z', $event2['time']); } public function testStatus()