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

Runtime information #564

Merged
merged 6 commits into from
Mar 15, 2018
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ public function capture($data, $stack = null, $vars = null)
unset($data['site']);
}

$data['contexts']['runtime'] = array('version' => PHP_VERSION, 'name' => 'php');
Copy link
Collaborator

@stayallive stayallive Mar 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be merged with a possible user value in the runtime context?

Also there is an extra space character before array, non-important but while you are there 😉


if (!$this->breadcrumbs->is_empty()) {
$data['breadcrumbs'] = $this->breadcrumbs->fetch();
}
Expand Down
14 changes: 14 additions & 0 deletions test/Raven/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,20 @@ public function testCaptureMessageWithUserContext()
), $event['user']);
}

/**
* @covers Raven_Client::capture
*/
public function testRuntimeContext()
{
$client = new Dummy_Raven_Client();

$client->captureMessage('test');
$events = $client->getSentEvents();
$this->assertEquals(PHP_VERSION, $events[0]['contexts']['runtime']['version']);
$event = array_pop($events);
$this->assertEquals('php', $event['contexts']['runtime']['name']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add an test what happens if the context was set by an user (for the runtime) it correctly merges with our runtime context.

}

/**
* @covers Raven_Client::captureMessage
*/
Expand Down