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

Improve Span API #1764

Closed
wants to merge 3 commits into from
Closed

Improve Span API #1764

wants to merge 3 commits into from

Conversation

stayallive
Copy link
Collaborator

Add trace() helper directly on SpanContext:

// Old:
\Sentry\trace(function (\Sentry\State\Scope $scope) use ($processedUsers) {
    // ...
}, \Sentry\Tracing\SpanContext::make()
       ->setOp('function')
       ->setDescription('processing-users')
);

// New:
\Sentry\Tracing\SpanContext::make()
    ->setOp('function')
    ->setDescription('processing-users')
    ->trace(function (\Sentry\State\Scope $scope) use ($processedUsers) {
        // ...
    });

Add data get helper:

// Old:
$span->setData([
    'failure' => $span->getData()['failure'] + 1,
]);

// New:
$span->setData([
    'failure' => $span->getData('failure', 0) + 1,
]);

@cleptric
Copy link
Member

Could we split this into two PRs mabye?

@stayallive
Copy link
Collaborator Author

Yes, split into #1766 & #1767

@stayallive stayallive closed this Aug 1, 2024
@stayallive stayallive deleted the span-api-improvements branch August 1, 2024 07:17
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.

2 participants