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

[2.0] Emit transactions, not culprits #638

Merged
merged 1 commit into from
Aug 3, 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: 3 additions & 3 deletions lib/Raven/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,10 @@ public function capture(array $payload)
{
$event = new Event($this->config);

if (isset($payload['culprit'])) {
$event = $event->withCulprit($payload['culprit']);
if (isset($payload['transaction'])) {
$event = $event->withTransaction($payload['transaction']);
} else {
$event = $event->withCulprit($this->transactionStack->peek());
$event = $event->withTransaction($this->transactionStack->peek());
}

if (isset($payload['logger'])) {
Expand Down
18 changes: 9 additions & 9 deletions lib/Raven/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class Event implements \JsonSerializable
/**
* @var string the name of the transaction (or culprit) which caused this exception
*/
private $culprit;
private $transaction;

/**
* @var string The name of the server (e.g. the host name)
Expand Down Expand Up @@ -238,27 +238,27 @@ public function withLogger($logger)
*
* @return string
*/
public function getCulprit()
public function getTransaction()
{
return $this->culprit;
return $this->transaction;
}

/**
* Sets the name of the transaction (or culprit) which caused this
* exception.
*
* @param string $culprit The transaction name
* @param string $transaction The transaction name
*
* @return static
*/
public function withCulprit($culprit)
public function withTransaction($transaction)
{
if ($culprit === $this->culprit) {
if ($transaction === $this->transaction) {
return $this;
}

$new = clone $this;
$new->culprit = $culprit;
$new->transaction = $transaction;

return $new;
}
Expand Down Expand Up @@ -735,8 +735,8 @@ public function toArray()
$data['logger'] = $this->logger;
}

if (null !== $this->culprit) {
$data['culprit'] = $this->culprit;
if (null !== $this->transaction) {
$data['transaction'] = $this->transaction;
}

if (null !== $this->serverName) {
Expand Down
4 changes: 2 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function testCapture()
->getClient();

$inputData = [
'culprit' => 'foo bar',
'transaction' => 'foo bar',
'level' => Client::LEVEL_DEBUG,
'logger' => 'foo',
'tags_context' => ['foo', 'bar'],
Expand All @@ -246,7 +246,7 @@ public function testCapture()
$event = $client->getLastEvent();

$this->assertEquals(str_replace('-', '', $event->getId()->toString()), $eventId);
$this->assertEquals($inputData['culprit'], $event->getCulprit());
$this->assertEquals($inputData['transaction'], $event->getTransaction());
$this->assertEquals($inputData['level'], $event->getLevel());
$this->assertEquals($inputData['logger'], $event->getLogger());
$this->assertEquals($inputData['tags_context'], $event->getTagsContext());
Expand Down
2 changes: 1 addition & 1 deletion tests/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function gettersAndSettersDataProvider()
return [
['level', 'info', ['level' => 'info']],
['logger', 'ruby', ['logger' => 'ruby']],
['culprit', 'foo', ['culprit' => 'foo']],
['transaction', 'foo', ['transaction' => 'foo']],
['serverName', 'local.host', ['server_name' => 'local.host']],
['release', '0.0.1', ['release' => '0.0.1']],
['modules', ['foo' => '0.0.1', 'bar' => '0.0.2'], ['modules' => ['foo' => '0.0.1', 'bar' => '0.0.2']]],
Expand Down