-
-
Notifications
You must be signed in to change notification settings - Fork 27
feat(sentry): support nested spans for console commands #956
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
90bde50
feat(sentry): support nested spans for console commands
huangdijia 034ad93
fix(sentry): improve scope management for console command spans
huangdijia e45ec6a
fix(sentry): update coroutine tracing to use spans instead of transac…
huangdijia baadab2
fix(sentry): update span handling in CoroutineAspect and EventHandleL…
huangdijia 74560b7
fix(sentry): refactor span handling in CoroutineAspect for improved c…
huangdijia c22cac4
fix(sentry): clarify purpose of commented span handling in EventHandl…
huangdijia 6403027
feat(sentry): add CoContainer for managing Sentry context in a weak r…
huangdijia 9e296b2
fix(sentry): refactor CoContainer method to improve span retrieval logic
huangdijia 4d38552
fix(sentry): refactor CoContainer methods for improved clarity and or…
huangdijia a822835
fix(sentry): add sampling check for parent span in EventHandleListener
huangdijia bd15825
fix(sentry): add del method to CoContainer for removing items from th…
huangdijia 472d6b3
fix(sentry): update getContainer method to use getOrSet for better co…
huangdijia 2d62130
fix(sentry): refactor coroutine execution to use trace function for b…
huangdijia de65019
fix(sentry): adjust scope management in EventHandleListener for impro…
huangdijia 29df54b
fix(sentry): ensure parent span is restored after coroutine processing
huangdijia a1219a0
fix(sentry): streamline coroutine span creation by removing unnecessa…
huangdijia 6166452
fix(sentry): refactor callable in trace function to use static closur…
huangdijia 390a5f9
fix(CoContainer): update pull method to require a non-null object key
huangdijia 27e19c2
fix(EventHandleListener): streamline span tag and status setting for …
huangdijia 9c1fbff
fix(EventHandleListener): remove unnecessary parent span sampling che…
huangdijia f4c0470
fix(CoroutineAspect): initialize Sentry SDK before transferring conte…
huangdijia c0cda26
fix(CoroutineAspect): ensure Sentry SDK initialization in new corouti…
huangdijia 714eb36
fix(CoroutineAspect): update operation name to 'coroutine.create' for…
huangdijia 3c0c510
fix(CoroutineAspect): update operation names for better tracing accuracy
huangdijia 1fc3718
fix(EventHandleListener): streamline span handling by consolidating p…
huangdijia f91fa26
fix(EventHandleListener): add check for parent span sampling before p…
huangdijia 77d78fd
fix(EventHandleListener): ensure proper handling of parent span lifec…
huangdijia 306fd08
fix(EventHandleListener): update operation name to 'console.command.e…
huangdijia f807d7c
fix(EventHandleListener): ensure parent span is set in CoContainer on…
huangdijia a831503
fix(EventHandleListener): improve parent span handling by checking sp…
huangdijia 4614ce2
fix(EventHandleListener): ensure parent span is finished before setti…
huangdijia 386369a
fix(EventHandleListener): remove command from CoContainer if parent s…
huangdijia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * This file is part of friendsofhyperf/components. | ||
| * | ||
| * @link https://github.com/friendsofhyperf/components | ||
| * @document https://github.com/friendsofhyperf/components/blob/main/README.md | ||
| * @contact huangdijia@gmail.com | ||
| */ | ||
|
|
||
| namespace FriendsOfHyperf\Sentry\Util; | ||
|
|
||
| use Hyperf\Context\Context; | ||
| use WeakMap; | ||
|
|
||
| /** | ||
| * @template TKey of object | ||
| * @template TValue of object | ||
| */ | ||
| class CoContainer | ||
| { | ||
| public const CONTEXT_KEY = 'sentry.context.container'; | ||
|
|
||
| /** | ||
| * @param TKey $key | ||
| * @param TValue $value | ||
| * @return TValue | ||
| */ | ||
| public static function set(object $key, object $value): object | ||
| { | ||
| self::getContainer()[$key] = $value; | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| /** | ||
| * @param TKey $key | ||
| * @return null|TValue | ||
| */ | ||
| public static function get(object $key): ?object | ||
| { | ||
| $container = self::getContainer(); | ||
|
|
||
| return $container[$key] ?? null; | ||
| } | ||
|
|
||
| /** | ||
| * @param TKey $key | ||
| * @return null|TValue | ||
| */ | ||
| public static function pull(object $key): ?object | ||
| { | ||
| $container = self::getContainer(); | ||
|
|
||
| if (! isset($container[$key])) { | ||
| return null; | ||
| } | ||
|
|
||
| $value = $container[$key]; | ||
| unset($container[$key]); | ||
|
|
||
| return $value; | ||
| } | ||
|
|
||
| public static function del(object $key): void | ||
| { | ||
| unset(self::getContainer()[$key]); | ||
| } | ||
|
|
||
| private static function getContainer(): WeakMap | ||
| { | ||
| return Context::getOrSet(self::CONTEXT_KEY, fn () => new WeakMap()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.