Skip to content

Commit 384a41b

Browse files
huangdijiaguandeng
andauthored
refactor(telescope): enhance entry storage and querying (#780)
* refactor(telescope): enhance entry storage and querying - Add query scopes to EntryModel for flexible data filtering - Inject EntriesRepository into EntryController for better dependency management - Simplify controller methods by using injected storage - Add property annotations for better IDE support - Update dependency binding in ConfigProvider * refactor(telescope): optimize entry storage mechanism - Move entry storage logic from TelescopeContext to Telescope class - Add getStorage method to centralize storage access - Use Context::override for safer concurrent entry handling - Optimize async storage by batching entries - Move ENTRIES constant to Telescope class for better organization * refactor(telescope): centralize entry storage logic - Move entry storage logic to DatabaseEntriesRepository - Deprecate IncomingEntry::store() in favor of repository storage - Update Telescope::store() to use repository for both sync and async modes - Simplify entry creation by directly using models * Optimized phpdoc * refactor(telescope): improve repository pattern implementation - Add ClearableRepository and PrunableRepository interfaces - Implement repository interfaces in DatabaseEntriesRepository - Update commands to use repository interfaces: * Refactor ClearCommand to use ClearableRepository * Enhance PruneCommand with keep-exceptions option * Update InstallCommand constructor - Add repository interface bindings in ConfigProvider - Update EntriesController to use ClearableRepository - Add generic type hints to repository interfaces * refactor(telescope): improve type declarations in repository interfaces - Add return type declarations: * void for ClearableRepository::clear() * int for PrunableRepository::prune() - Update DatabaseEntriesRepository implementation with matching return types * feat(telescope): add hyperf/redis dependency Add hyperf/redis package as a required dependency for Redis monitoring functionality * refactor(telescope): remove hyperf/view-engine dependency Remove unnecessary hyperf/view-engine package as it's no longer required for template rendering * refactor(telescope): remove unused Swoole\Process import Remove unnecessary Process class import from FetchRecordingOnBootListener * Updated docs * Add comment * docs(telescope): update listener configuration instructions - Move SetRequestLifecycleListener from ConfigProvider to manual configuration - Update documentation to include SetRequestLifecycleListener in listeners.php - Remove unnecessary use statements in documentation examples - Use fully qualified class names in configuration examples * refactor(telescope): improve type annotations and docblocks - Add property type hints for EntryTagModel - Update and organize EntryModel property annotations: * Fix property types (bool, array, Collection) * Remove redundant properties * Add relationship type hint for tags - Enhance EntryResult type declarations: * Add Collection type support for tags * Update method parameter annotations * Removed useless property * Add property id * Optimized EntryModel * feat(telescope): implement tag monitoring system - Add tag monitoring methods to EntriesRepository interface - Implement TerminableRepository for cleanup operations - Add monitoring functionality to DatabaseEntriesRepository: * Track monitored tags * Add methods for monitoring/unmonitoring tags * Implement tag state management - Enable hasMonitoredTag check in IncomingEntry - Add method annotation for EntryModel::withTelescopeOptions * Optimized parameter type * Add return types * Add return types * Optimized DatabaseEntriesRepository::find * Optimized * Optimized * refactor(telescope): enhance database operations and type safety - Add chunk size configuration for database operations * Add 'chunk' option to telescope config * Implement chunked deletes for better memory management - Improve type declarations in repository interfaces: * Add return type hints to all interface methods * Strengthen parameter type hints - Optimize DatabaseEntriesRepository: * Inject TelescopeConfig for better dependency management * Cache connection and chunk size as properties * Use explicit database connection in model operations * Implement chunked deletes in clear() and prune() - Update config documentation and type hints * refactor(telescope): restructure storage configuration - Move database configuration under 'storage' namespace: * Relocate database settings to storage.database * Keep backward compatibility with old 'database' key * Add deprecation notice for old config path - Update config structure in publish/telescope.php - Update TelescopeConfig to handle both old and new paths * Optimized * Revert "Optimized" This reverts commit f0214b6811dc0b425e3c6c2830217516be0987a0. * refactor(telescope): optimize entry storage mechanism - Implement batch processing for entry storage: * Add chunked inserts for better performance * Separate exception and normal entry handling * Optimize tag storage with bulk inserts - Add exception handling features: * Track exception occurrences * Update family hash visibility * Handle duplicate tag constraints - Improve type hints and documentation - Remove direct model usage in favor of query builder * refactor(telescope): improve database error handling - Replace Doctrine dependency with generic Exception handling - Add custom unique constraint detection: * Implement isUniqueConstraintError method * Use regex to detect MySQL error code 1062 * Only suppress unique constraint violations - Remove unused Telescope import * refactor(telescope): change self to static for store method call Replace self::store with static::store to properly support late static binding * optimization * refactor(telescope): improve property type declarations and defaults - Add proper PHPDoc type annotations for IncomingEntry properties - Remove explicit type declarations for better compatibility - Add default values for EntryQueryOptions properties - Remove unused Request import * Removed phpdoc * Optimized * Optimized * Add tags and appName value * Optimized EntryResult::$tag * Optimized * Removed useless property * Optimized * Optimized * Optimized phpdoc * Optimized --------- Co-authored-by: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Co-authored-by: guandeng <guandeng@hotmail.com>
1 parent 297c829 commit 384a41b

2 files changed

Lines changed: 7 additions & 15 deletions

File tree

en/components/telescope.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ Add the listener in the `config/autoload/listeners.php` configuration file
4242
```php
4343
<?php
4444

45-
use FriendsOfHyperf\Telescope\Listener\RequestHandledListener;
46-
4745
return [
48-
RequestHandledListener::class,
46+
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
47+
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
4948
];
5049
```
5150

@@ -58,11 +57,9 @@ To record HTTP requests, use the `http` middleware
5857
```php
5958
<?php
6059

61-
use FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware;
62-
6360
return [
6461
'http' => [
65-
TelescopeMiddleware::class,
62+
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
6663
],
6764
];
6865
```

zh_CN/components/telescope.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ php bin/hyperf.php migrate
4242
```php
4343
<?php
4444

45-
use FriendsOfHyperf\Telescope\Listener\RequestHandledListener;
46-
4745
return [
48-
RequestHandledListener::class,
46+
FriendsOfHyperf\Telescope\Listener\RequestHandledListener::class,
47+
FriendsOfHyperf\Telescope\Listener\SetRequestLifecycleListener::class,
4948
];
5049

5150
```
@@ -59,11 +58,9 @@ return [
5958
```php
6059
<?php
6160

62-
use FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware;
63-
6461
return [
6562
'http' => [
66-
TelescopeMiddleware::class,
63+
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
6764
],
6865
];
6966
```
@@ -73,11 +70,9 @@ return [
7370
```php
7471
<?php
7572

76-
use FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware;
77-
7873
return [
7974
'grpc' => [
80-
TelescopeMiddleware::class,
75+
FriendsOfHyperf\Telescope\Middleware\TelescopeMiddleware::class,
8176
],
8277
];
8378
```

0 commit comments

Comments
 (0)