-
Notifications
You must be signed in to change notification settings - Fork 1
feat: use CoroutineHandler instead CurlHandler for HTTP exporter #12
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
Conversation
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.
Pull request overview
This PR introduces support for using CoroutineHandler instead of CurlHandler for the OpenTelemetry HTTP exporter in Hyperf applications. It implements a custom discovery mechanism (HyperfGuzzle) that provides coroutine-aware HTTP clients optimized for Swoole environments, with optional connection pooling support.
Changes:
- Adds HyperfGuzzle class implementing DiscoveryInterface to provide coroutine-aware Guzzle clients
- Registers HyperfGuzzle as the primary HTTP client discoverer in ConfigProvider
- Adds comprehensive unit tests for the HyperfGuzzle implementation
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Support/HyperfGuzzle.php | Implements DiscoveryInterface to provide Guzzle clients with CoroutineHandler or PoolHandler based on configuration |
| src/ConfigProvider.php | Registers HyperfGuzzle as the primary client discoverer before the default Guzzle discoverer |
| tests/Unit/Support/HyperfGuzzleTest.php | Adds unit tests covering available(), create(), and handler selection logic |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Discovery::setDiscoverers([ | ||
| HyperfGuzzle::class, | ||
| Guzzle::class, | ||
| ]); |
Copilot
AI
Jan 30, 2026
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.
The new 'otlp_http.pool' configuration option is not documented in the published configuration file. Based on the PR description, this configuration is essential for users who want to use PoolHandler instead of CoroutineHandler. Consider adding a commented example in the configuration file to help users understand this feature. The PR description mentions that pool configuration can be defined within the 'open-telemetry.php' file, but the published config template (publish/open-telemetry.php) doesn't include this section.
|
|
||
| private function createHandler(): HandlerStack | ||
| { | ||
| /** @var ContainerInterface $container */ |
Copilot
AI
Jan 30, 2026
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.
Missing import for ContainerInterface. The PHPDoc annotation uses ContainerInterface but the corresponding use statement is not present. Based on the codebase conventions (see src/Factory/OTelResourceFactory.php:8, src/Factory/Trace/TracerProviderFactory.php:8), this should be 'Hyperf\Contract\ContainerInterface'.
| use Mockery as m; | ||
| use PHPUnit\Framework\TestCase; | ||
| use Psr\Container\ContainerInterface; | ||
| use ReflectionAttribute; |
Copilot
AI
Jan 30, 2026
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.
The ReflectionAttribute import is unused and should be removed to keep the imports clean.
| use ReflectionAttribute; |
| use GuzzleHttp\HandlerStack; | ||
| use Hyperf\Context\ApplicationContext; | ||
| use Hyperf\Contract\ConfigInterface; | ||
| use Hyperf\Guzzle\ClientFactory; |
Copilot
AI
Jan 30, 2026
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.
The ClientFactory import is unused and should be removed to keep the imports clean.
| use Hyperf\Guzzle\ClientFactory; |
Description
The
OtlpHttpTransportFactory[1] uses thePsrTransportFactory[2] which in turn usesDiscovery[3] to obtain a functional instance ofClientInterfaceto emit data via HTTP. Therefore, to inject theGuzzle\Clientwith theCoroutineHandler, it was necessary to injectHyperfGuzzleas a possible discovery.Why not use Listeners, for example: BootApplication?
The
TracerProviderFactoryis executed during the reading of dependencies (dependencies.php) which is read before any event is emitted. Therefore, it is necessary to register theDiscoverybefore this stage.If the pool configuration is defined within the
open-telemetry.phpfile, thePoolHandlerwill be used; otherwise, theCoroutineHandlerwill be used. Example:Type of change
Checklist
feat: add SQS aspect)composer testpasses locally