Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Ensure we use the correct timestamp for timeEvents #3

Merged
merged 2 commits into from
Apr 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Stackdriver/SpanConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
]);
}

Expand All @@ -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()
]);
}

Expand Down
9 changes: 7 additions & 2 deletions tests/unit/Stackdriver/SpanConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -179,13 +182,15 @@ 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']);
$this->assertEquals('message-id', $event2['messageEvent']['id']);
$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()
Expand Down