Hub
class Hub implements HubInterface
The SDK's Hub with a layer stack per coroutine instead of per instance.
Each coroutine starts from a copy of the baseline scope, and child coroutines inherit a
copy of their parent's stack. Compare this class with Sentry\State\Hub on every SDK update.
Constants
| CONTEXT_STACK_KEY |
|
| CONTEXT_LAST_EVENT_ID_KEY |
|
Properties
| protected Scope | $scope |
Methods
Create a new Hub instance.
Get the client bound to the hub.
Bind a new client to the hub.
Get the ID of the last event captured in the current coroutine.
Push a copy of the current scope onto the current coroutine's stack.
Remove the most recently pushed scope from the current coroutine's stack.
Capture a message event and send it to Sentry.
Capture an exception event and send it to Sentry.
Capture a new event using the provided data.
Capture an event for the last error that occurred.
Record a breadcrumb that will be attached to future events.
Add an attachment to the current scope.
Pass the current scope to the callback, or the baseline scope before the application boots.
Start a new transaction and decide whether it is sampled and profiled.
Get the transaction on the current scope.
Set the span on the current scope.
Get the span on the current scope.
Run the callback with a new scope that is removed afterwards.
Capture a check-in.
Get the client's integration with the given class name.
Get the scope at the top of the current coroutine's stack.
Details
at line 52
__construct(ClientInterface|null $client = null, Scope|null $scope = null)
Create a new Hub instance.
at line 60
ClientInterface|null
getClient()
Get the client bound to the hub.
at line 71
void
bindClient(ClientInterface $client)
Bind a new client to the hub.
On the shared Hub, per-request use races across coroutines, and existing coroutine layer stacks may already hold the previous client.
at line 80
EventId|null
getLastEventId()
Get the ID of the last event captured in the current coroutine.
at line 88
Scope
pushScope()
Push a copy of the current scope onto the current coroutine's stack.
at line 101
bool
popScope()
Remove the most recently pushed scope from the current coroutine's stack.
at line 118
EventId|null
captureMessage(string $message, Severity|null $level = null, EventHint|null $hint = null)
Capture a message event and send it to Sentry.
at line 135
EventId|null
captureException(Throwable $exception, EventHint|null $hint = null)
Capture an exception event and send it to Sentry.
at line 152
EventId|null
captureEvent(Event $event, EventHint|null $hint = null)
Capture a new event using the provided data.
at line 169
EventId|null
captureLastError(EventHint|null $hint = null)
Capture an event for the last error that occurred.
at line 183
bool
addBreadcrumb(Breadcrumb $breadcrumb)
Record a breadcrumb that will be attached to future events.
at line 221
bool
addAttachment(Attachment $attachment)
Add an attachment to the current scope.
at line 235
void
configureScope(callable $callback)
Pass the current scope to the callback, or the baseline scope before the application boots.
at line 254
Transaction
startTransaction(TransactionContext $context, array $customSamplingContext = [])
Start a new transaction and decide whether it is sampled and profiled.
at line 436
Transaction|null
getTransaction()
Get the transaction on the current scope.
at line 444
HubInterface
setSpan(Span|null $span)
Set the span on the current scope.
at line 454
Span|null
getSpan()
Get the span on the current scope.
at line 468
mixed
withScope(callable $callback)
Run the callback with a new scope that is removed afterwards.
at line 484
string|null
captureCheckIn(string $slug, CheckInStatus $status, mixed $duration = null, MonitorConfig|null $monitorConfig = null, string|null $checkInId = null)
Capture a check-in.
at line 523
IntegrationInterface|null
getIntegration(string $className)
Get the client's integration with the given class name.
at line 533
protected Scope
getScope()
Get the scope at the top of the current coroutine's stack.