-
-
Notifications
You must be signed in to change notification settings - Fork 11
Sentry package #222
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
base: main
Are you sure you want to change the base?
Sentry package #222
Changes from all commits
ca200ba
096f8ab
8d39b6b
b0db37c
0a22846
7764694
828a465
5251691
7f17c28
84678ff
18856ec
3db4f07
f8c58a6
9bcd223
ef67e84
a4efed8
bef89ab
3f34a53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Functional Software, Inc. dba Sentry | ||
|
||
Copyright (c) D.J.Hwang | ||
|
||
Copyright (c) Hyperf | ||
|
||
Copyright (c) Hypervel | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sentry; | ||
|
||
use Sentry\State\HubInterface; | ||
|
||
use function Hyperf\Support\make; | ||
|
||
/** | ||
* @see SentrySdk | ||
*/ | ||
class SentrySdk | ||
{ | ||
protected static ?HubInterface $hub = null; | ||
|
||
/** | ||
* Constructor. | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Initializes the SDK with singleton hub. | ||
*/ | ||
public static function init(): HubInterface | ||
{ | ||
if (is_null(static::$hub)) { | ||
static::$hub = make(HubInterface::class); | ||
} | ||
|
||
return static::$hub; | ||
} | ||
|
||
/** | ||
* Gets the current hub. Returns the singleton hub instance. | ||
*/ | ||
public static function getCurrentHub(): HubInterface | ||
{ | ||
if (is_null(static::$hub)) { | ||
static::init(); | ||
} | ||
|
||
return static::$hub; | ||
} | ||
|
||
/** | ||
* Sets the current hub in context but maintains singleton. | ||
*/ | ||
public static function setCurrentHub(HubInterface $hub): HubInterface | ||
{ | ||
static::$hub = $hub; | ||
|
||
return static::$hub; | ||
} | ||
|
||
/** | ||
* Get the singleton hub instance directly. | ||
*/ | ||
public static function getHub(): ?HubInterface | ||
{ | ||
return static::$hub; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "hypervel/sentry", | ||
"type": "library", | ||
"description": "The sentry component for Hypervel framework.", | ||
"license": "MIT", | ||
"keywords": [ | ||
"php", | ||
"hyperf", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this package is designed for Hypervel only |
||
"hypervel", | ||
"sentry", | ||
"error-tracking" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Albert Chen", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"support": { | ||
"issues": "https://github.com/hypervel/components/issues", | ||
"source": "https://github.com/hypervel/components" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Hypervel\\Sentry\\": "src/" | ||
} | ||
}, | ||
"require": { | ||
"php": "^8.2", | ||
"hypervel/cache": "^0.3", | ||
"hypervel/console": "^0.3", | ||
"hypervel/core": "^0.3", | ||
"hypervel/object-pool": "^0.3", | ||
"hypervel/support": "^0.3", | ||
"sentry/sentry": "^4.15.0" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"branch-alias": { | ||
"dev-main": "0.3-dev" | ||
}, | ||
"hypervel": { | ||
"providers": [ | ||
"Hypervel\\Sentry\\SentryServiceProvider" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this section |
||
* This file is part of Hypervel components. | ||
* | ||
* @link https://github.com/hypervel/components | ||
* @document https://github.com/hypervel/components/blob/main/README.md | ||
* @contact [email protected] | ||
*/ | ||
|
||
use Hypervel\Sentry\Features\CacheFeature; | ||
use Hypervel\Sentry\Features\ConsoleSchedulingFeature; | ||
use Hypervel\Sentry\Features\DbQueryFeature; | ||
use Hypervel\Sentry\Features\LogFeature; | ||
use Hypervel\Sentry\Features\NotificationsFeature; | ||
use Hypervel\Sentry\Features\QueueFeature; | ||
use Hypervel\Sentry\Integrations\RequestIntegration; | ||
use Hypervel\Validation\ValidationException; | ||
use Sentry\Integration\EnvironmentIntegration; | ||
use Sentry\Integration\FrameContextifierIntegration; | ||
use Sentry\Integration\TransactionIntegration; | ||
|
||
use function Hyperf\Support\env; | ||
|
||
return [ | ||
'dsn' => env('SENTRY_DSN', ''), | ||
|
||
// Whether to enable default integrations (includes ModulesIntegration) | ||
'default_integrations' => env('SENTRY_DEFAULT_INTEGRATIONS', false), | ||
|
||
// The release version of your application | ||
// Example with dynamic git hash: trim(exec('git log --pretty="%h" -n1 HEAD')) | ||
'release' => env('SENTRY_RELEASE'), | ||
|
||
// When left empty or `null` the environment will be used (usually discovered from `APP_ENV` in your `.env`) | ||
'environment' => env('APP_ENV', 'production'), | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#sample_rate | ||
'sample_rate' => env('SENTRY_SAMPLE_RATE') === null ? 1.0 : (float) env('SENTRY_SAMPLE_RATE'), | ||
|
||
// Switch tracing on/off | ||
'enable_tracing' => env('SENTRY_ENABLE_TRACING', true), | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces_sample_rate | ||
'traces_sample_rate' => env('SENTRY_TRACES_SAMPLE_RATE') === null ? 1.0 : (float) env('SENTRY_TRACES_SAMPLE_RATE'), | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#traces_sampler | ||
// 'traces_sampler' => function (Sentry\Tracing\SamplingContext $context): float { | ||
// if (str_contains($context->getTransactionContext()->getDescription(), '/health')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's no health route in hypervel |
||
// return 0; | ||
// } | ||
// return env('SENTRY_TRACES_SAMPLE_RATE') === null ? 1.0 : (float) env('SENTRY_TRACES_SAMPLE_RATE'); | ||
// }, | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#profiles_sample_rate | ||
'profiles_sample_rate' => env('SENTRY_PROFILES_SAMPLE_RATE') === null ? null : (float) env( | ||
'SENTRY_PROFILES_SAMPLE_RATE' | ||
), | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#enable_logs | ||
'enable_logs' => env('SENTRY_ENABLE_LOGS', false), | ||
|
||
// @see: https://docs.sentry.io/platforms/php/guides/laravel/configuration/options/#send_default_pii | ||
'send_default_pii' => env('SENTRY_SEND_DEFAULT_PII', false), | ||
|
||
// Must instanceof Psr\Log\LoggerInterface | ||
// 'logger' => Hyperf\Contract\StdoutLoggerInterface::class, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check |
||
|
||
'breadcrumbs' => [ | ||
// Capture Hypervel cache events (hits, writes etc.) as breadcrumbs | ||
'cache' => env('SENTRY_BREADCRUMBS_CACHE', true), | ||
// Capture SQL queries as breadcrumbs | ||
'sql_queries' => env('SENTRY_BREADCRUMBS_SQL_QUERIES', true), | ||
// Capture SQL query bindings (parameters) in SQL query breadcrumbs | ||
'sql_bindings' => env('SENTRY_BREADCRUMBS_SQL_BINDINGS', false), | ||
// Capture SQL transactions (begin, commit, rollbacks) as breadcrumbs | ||
'sql_transaction' => env('SENTRY_BREADCRUMBS_SQL_TRANSACTION', false), | ||
// Capture queue job information as breadcrumbs | ||
'queue_info' => env('SENTRY_BREADCRUMBS_QUEUE_INFO_ENABLED', true), | ||
// Capture send notifications as breadcrumbs | ||
'notifications' => env('SENTRY_BREADCRUMBS_NOTIFICATIONS_ENABLED', true), | ||
// Capture Guzzle HTTP client requests as breadcrumbs | ||
'guzzle' => env('SENTRY_BREADCRUMBS_GUZZLE', true), | ||
], | ||
|
||
'integrations' => [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check |
||
RequestIntegration::class, | ||
TransactionIntegration::class, | ||
FrameContextifierIntegration::class, | ||
EnvironmentIntegration::class, | ||
], | ||
|
||
'features' => [ | ||
CacheFeature::class, | ||
QueueFeature::class, | ||
NotificationsFeature::class, | ||
LogFeature::class, | ||
ConsoleSchedulingFeature::class, | ||
DbQueryFeature::class, | ||
], | ||
|
||
'ignore_exceptions' => [ | ||
ValidationException::class, | ||
], | ||
|
||
'ignore_transactions' => [ | ||
'GET /health', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's no health route in hypervel |
||
], | ||
|
||
'ignore_commands' => [ | ||
'crontab:run', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. adding |
||
'gen:*', | ||
'migrate*', | ||
'tinker', | ||
'vendor:publish', | ||
], | ||
|
||
// Performance monitoring specific configuration | ||
'tracing' => [ | ||
// Capture queue jobs as spans when executed on the sync driver | ||
'queue_jobs' => env('SENTRY_TRACE_QUEUE_JOBS_ENABLED', true), | ||
// Trace queue jobs as their own transactions (this enables tracing for queue jobs) | ||
'queue_job_transactions' => env('SENTRY_TRACE_QUEUE_ENABLED', true), | ||
// Capture Hypervel cache events (hits, writes etc.) as spans | ||
'cache' => env('SENTRY_TRACE_CACHE_ENABLED', true), | ||
// Capture send notifications as spans | ||
'notifications' => env('SENTRY_TRACE_NOTIFICATIONS_ENABLED', true), | ||
// Capture Redis operations as spans (this enables Redis events in Hypervel) | ||
'redis_commands' => env('SENTRY_TRACE_REDIS_COMMANDS', false), | ||
// Capture where the Redis command originated from on the Redis command spans | ||
'redis_origin' => env('SENTRY_TRACE_REDIS_ORIGIN_ENABLED', true), | ||
], | ||
|
||
'http_timeout' => (float) env('SENTRY_HTTP_TIMEOUT', 2.0), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need to modify this part?