Skip to content

Conversation

cleptric
Copy link
Member

Another approach to fix #1716.

Compared to other SDKs, like Python, the PHP SDK never exposed the transaction name on the scope.

With these changes, the transaction name will be synced with the scope when set on the transaction and vice versa. If an error happens while the transaction is still unfinished, we now set a proper transaction name on the error instead of relying on the user manually passing the name as part of the EventHint or relying on the TransactionIntegration setting $_SERVER['PATH_INFO'], which is a bad default.

// Before
$hint = EventHint::fromArray([
    'extra' => [
        'transaction' => 'GET /example',
    ],
]);
captureException($e, $hint);

// After
configureScope(function (Scope $scope) {
    $scope->setTransactionName('GET /example');
});
captureException($e);

// After, in case of an active transaction
captureException($e);

Reliably setting the transaction name on all errors allows for some neat features, such as using Discover to create a query to group your transactions by error count.

image

@cleptric cleptric self-assigned this Mar 13, 2024
@cleptric cleptric force-pushed the scope-transaction branch from 253fb04 to ea55d1d Compare March 13, 2024 01:54
@cleptric cleptric changed the title Add Scope:: setTransactionName() Add Scope::setTransactionName() Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant