mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-22 00:05:37 +08:00
add opentelemetry extension support
This commit is contained in:
@@ -335,3 +335,10 @@ and they all have their own open source licenses.
|
||||
|
||||
Please use the `bin/spc dump-license` command to export the open source licenses used in the project after compilation,
|
||||
and comply with the corresponding project's LICENSE.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
When downloading extensions, you may eventually see errors like `curl: (56) The requested URL returned error: 403` which are often caused by github rate limiting.
|
||||
You can verify this by adding `--debug` to the command and will see something like `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"`.
|
||||
|
||||
To fix this, [create](https://github.com/settings/tokens) a personal access token on GitHub and set it as an environment variable `GITHUB_TOKEN=<XXX>`.
|
||||
@@ -432,6 +432,21 @@
|
||||
"type": "builtin",
|
||||
"arg-type-unix": "custom"
|
||||
},
|
||||
"opentelemetry": {
|
||||
"notes": true,
|
||||
"support": {
|
||||
"Windows": "wip"
|
||||
},
|
||||
"arg-type": "enable",
|
||||
"source": "opentelemetry",
|
||||
"unix-only": true,
|
||||
"ext-suggests": [
|
||||
"grpc",
|
||||
"protobuf",
|
||||
"ffi"
|
||||
],
|
||||
"type": "external"
|
||||
},
|
||||
"openssl": {
|
||||
"notes": true,
|
||||
"type": "builtin",
|
||||
|
||||
@@ -667,6 +667,16 @@
|
||||
"path": "COPYING"
|
||||
}
|
||||
},
|
||||
"opentelemetry": {
|
||||
"type": "url",
|
||||
"url": "https://pecl.php.net/get/opentelemetry",
|
||||
"path": "php-src/ext/opentelemetry",
|
||||
"filename": "opentelemetry.tgz",
|
||||
"license": {
|
||||
"type": "file",
|
||||
"path": "LICENSE"
|
||||
}
|
||||
},
|
||||
"openssl": {
|
||||
"type": "ghrel",
|
||||
"repo": "openssl/openssl",
|
||||
|
||||
43
src/SPC/builder/extension/opentelemetry.php
Normal file
43
src/SPC/builder/extension/opentelemetry.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace SPC\builder\extension;
|
||||
|
||||
use SPC\builder\Extension;
|
||||
use SPC\builder\windows\WindowsBuilder;
|
||||
use SPC\util\CustomExt;
|
||||
use SPC\util\GlobalEnvManager;
|
||||
|
||||
#[CustomExt('opentelemetry')]
|
||||
class opentelemetry extends Extension
|
||||
{
|
||||
public function validate(): void
|
||||
{
|
||||
if ($this->builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') {
|
||||
throw new \RuntimeException('The opentelemetry extension requires PHP 8.0 or later');
|
||||
}
|
||||
}
|
||||
|
||||
public function patchBeforeBuildconf(): bool
|
||||
{
|
||||
// soft link to the grpc source code
|
||||
if ($this->builder instanceof WindowsBuilder) {
|
||||
// not support windows yet
|
||||
throw new \RuntimeException('opentelemetry extension does not support windows yet');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function patchBeforeMake(): bool
|
||||
{
|
||||
// add -Wno-strict-prototypes
|
||||
GlobalEnvManager::putenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS=' . getenv('SPC_CMD_VAR_PHP_MAKE_EXTRA_CFLAGS') . ' -Wno-strict-prototypes');
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getUnixConfigureArg(): string
|
||||
{
|
||||
return '--enable-opentelemetry=' . BUILD_ROOT_PATH . '/opentelemetry GRPC_LIB_SUBDIR=' . BUILD_LIB_PATH;
|
||||
}
|
||||
}
|
||||
5
src/globals/ext-tests/opentelemetry.php
Normal file
5
src/globals/ext-tests/opentelemetry.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
assert(function_exists('OpenTelemetry\Instrumentation\hook'));
|
||||
Reference in New Issue
Block a user