The official PHP SDK for Sentry (sentry.io)
MIT License
Bot releases are visible (Hide)
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.7.0.
metric_bucket
rate limits (#1726) & (#1728)
Published by getsentry-bot 7 months ago
Published by getsentry-bot 8 months ago
Published by getsentry-bot 9 months ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.5.0.
Add before_send_check_in
and before_send_metrics
(#1690)
\Sentry\init([
'before_send_check_in' => function (\Sentry\Event $event) {
$checkIn = $event->getCheckIn(),
// modify the check-in or return null to not send it
},
]);
\Sentry\init([
'before_send_metrics' => function (\Sentry\Event $event) {
$metrics = $event->getMetrics(),
// modify the metrics or return null to not send it
},
]);
Published by getsentry-bot 9 months ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.4.0.
Add metrics()->timing()
(#1670)
This allows you to emit a distribution metric based on the duration of the provided callback.
use function Sentry\metrics;
metrics()->timing(
key: 'my-metric',
callback: fn() => doSomething(),
);
Add withMonitor()
(#1679)
This wraps a callback into monitor check-ins.
use function Sentry\withMonitor;
withMonitor(
slug: 'my-monitor',
callback: fn () => doSomething(),
monitorConfig: new MonitorConfig(...),
);
Add new failure_issue_threshold
and recovery_threshold
configuration to MonitorConfig
(#1685)
Add TransactionContext::make()
and SpanContext::make()
(#1684)
use Sentry\Tracing\SpanContext;
$spanCpntext = SpanContext::make()
->setOp('http.client')
->setDescription('GET https://example.com')
Add support for fluent use of Transaction::setName()
(#1687)
Add support for the W3C traceparent
header (#1680)
Do not send an empty event if no metrics are in the bucket (#1676)
Fix the http_ssl_verify_peer
option to set the correct value to CURLOPT_SSL_VERIFYPEER
(#1686)
UserDataBag::getSegment()
and UserDataBag::setSegment()
. You may use a custom tag or context instead (#1681)
Published by getsentry-bot 10 months ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.3.0.
Add support for Sentry Developer Metrics (#1619)
use function Sentry\metrics;
// Add 4 to a counter named hits
metrics()->increment(key: 'hits', value: 4);
// Add 25 to a distribution named response_time with unit milliseconds
metrics()->distribution(key: 'response_time', value: 25, unit: MetricsUnit::millisecond());
// Add 2 to gauge named parallel_requests, tagged with type: "a"
metrics()->gauge(key: 'parallel_requests, value: 2, tags: ['type': 'a']);
// Add a user's email to a set named users.sessions, tagged with role: "admin"
metrics()->set('users.sessions, '[email protected]', null, ['role' => User::admin()]);
// Add 2 to gauge named `parallel_requests`, tagged with `type: "a"`
Sentry.metrics.gauge('parallel_requests', 2, { tags: { type: 'a' } });
// Flush the metrics to Sentry
metrics()->flush();
// We recommend registering the flushing in a shutdown function
register_shutdown_function(static fn () => metrics()->flush());
To learn more about Sentry Developer Merics, join the discussion at https://github.com/getsentry/sentry-php/discussions/1666.
HubAdapter::class
(#1663)
final
keyword from Hub::class
, Client::class
and Scope::class
(#1665)
Published by getsentry-bot 10 months ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.2.0.
Add a config option to allow overriding the Spotlight url (#1659)
Sentry\init([
'spotlight_url' => 'http://localhost:8969',
]);
Restore setting the logger
value on the event payload (#1657)
Only apply the sample_rate
on error/message events (#1662)
This fixes an issue where Cron Check-Ins were wrongly sampled out if a sample_rate
lower than 1.0
is used.
@internal
annotation from ClientBuilder::class
(#1661)
Published by getsentry-bot 11 months ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v4.1.0.
Add support for Spotlight (#1647)
Spotlight is Sentry for Development. Inspired by an old project, Django Debug Toolbar. Spotlight brings a rich debug overlay into development environments, and it does it by leveraging the existing power of Sentry's SDKs.
To learn more about Spotlight, go to https://spotlightjs.com/.
response
status (#1644)
Published by getsentry-bot 12 months ago
The Sentry SDK team is thrilled to announce the immediate availability of Sentry PHP SDK v4.0.0.
Please refer to the UPGRADE-4.0.md guide for a complete list of breaking changes.
This version exclusively uses the envelope endpoint to send event data to Sentry.
If you are using sentry.io, no action is needed.
If you are using an on-premise/self-hosted installation of Sentry, the minimum requirement is now version >= v20.6.0
.
You need to have ext-curl
installed to use the SDK.
The IgnoreErrorsIntegration
integration was removed. Use the ignore_exceptions
option instead.
Sentry\init([
'ignore_exceptions' => [BadThingsHappenedException::class],
]);
This option performs an is_a
check now, so you can also ignore more generic exceptions.
Add new fluent APIs (#1601)
// Before
$transactionContext = new TransactionContext();
$transactionContext->setName('GET /example');
$transactionContext->setOp('http.server');
// After
$transactionContext = (new TransactionContext())
->setName('GET /example');
->setOp('http.server');
Simplify the breadcrumb API (#1603)
// Before
\Sentry\addBreadcrumb(
new \Sentry\Breadcrumb(
\Sentry\Breadcrumb::LEVEL_INFO,
\Sentry\Breadcrumb::TYPE_DEFAULT,
'auth', // category
'User authenticated', // message (optional)
['user_id' => $userId] // data (optional)
)
);
// After
\Sentry\addBreadcrumb(
category: 'auth',
message: 'User authenticated', // optional
metadata: ['user_id' => $userId], // optional
level: Breadcrumb::LEVEL_INFO, // set by default
type: Breadcrumb::TYPE_DEFAULT, // set by default
);
New logger
option (#1625)
To make it easier to debug the internals of the SDK, the logger
option now accepts a Psr\Log\LoggerInterface
instance.
We do provide two implementations, Sentry\Logger\DebugFileLogger
and Sentry\Logger\DebugStdOutLogger
.
// This logs messages to the provided file path
Sentry\init([
'logger' => new DebugFileLogger(filePath: ROOT . DS . 'sentry.log'),
]);
// This logs messages to stdout
Sentry\init([
'logger' => new DebugStdOutLogger(),
]);
New default cURL HTTP client (#1589)
The SDK now ships with its own HTTP client based on cURL. A few new options were added.
Sentry\init([
'http_proxy_authentication' => 'username:password', // user name and password to use for proxy authentication
'http_ssl_verify_peer' => false, // default true, verify the peer's SSL certificate
'http_compression' => false, // default true, http request body compression
]);
To use a different client, you may use the http_client
option.
use Sentry\Client;
use Sentry\HttpClient\HttpClientInterface;
use Sentry\HttpClient\Request;
use Sentry\HttpClient\Response;
use Sentry\Options;
$httpClient = new class() implements HttpClientInterface {
public function sendRequest(Request $request, Options $options): Response
{
// your custom implementation
return new Response($response->getStatusCode(), $response->getHeaders(), '');
}
};
Sentry\init([
'http_client' => $httpClient,
]);
To use a different transport, you may use the transport
option. A custom transport must implement the TransportInterface
.
If you use the transport
option, the http_client
option has no effect.
php-http/message-factory
was removed.Published by getsentry-bot 12 months ago
Published by getsentry-bot about 1 year ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v3.21.0.
Add Sentry::captureCheckIn()
(#1573)
Sending check-ins from the SDK is now simplified.
$checkInId = Sentry\captureCheckIn(
slug: 'monitor-slug',
status: CheckInStatus::inProgress()
);
// do something
Sentry\captureCheckIn(
checkInId: $checkInId,
slug: 'monitor-slug',
status: CheckInStatus::ok()
);
You can also pass in a monitorConfig
object as well as the duration
.
Undeprecate the tags
option (#1561)
You can now set tags that are applied to each event when calling Sentry::init()
.
Sentry\init([
'tags' => [
'foo' => 'bar',
],
])
Apply the prefixes
option to profiling frames (#1568)
If you added the prefixes
option when calling Sentry::init()
, this option will now also apply to profile frames.
Sentry\init([
'prefixes' => ['/var/www/html'],
])
Published by getsentry-bot over 1 year ago
Published by getsentry-bot over 1 year ago
The Sentry SDK team is happy to announce the immediate availability of Sentry PHP SDK v3.20.0.
Tracing without Performance (#1516)
You can now set up distributed tracing without the need to use the performance APIs.
This allows you to connect your errors that hail from other Sentry instrumented applications to errors in your PHP application.
To continue a trace, fetch the incoming Sentry tracing headers and call \Sentry\continueTrace()
as early as possible in the request cycle.
$sentryTraceHeader = $request->getHeaderLine('sentry-trace');
$baggageHeader = $request->getHeaderLine('baggage');
continueTrace($sentryTraceHeader, $baggageHeader);
To continue a trace outward, you may attach the Sentry tracing headers to any HTTP client request.
You can fetch the required header values by calling \Sentry\getBaggage()
and \Sentry\getTraceparent()
.
Upserting Cron Monitors (#1511)
You can now create and update your Cron Monitors programmatically with code.
Read more about this in our docs.