mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-18 04:44:53 +08:00
add opentelemetry extension support (#593)
* add opentelemetry extension support * config sort * cleanup build args * Update docs * Adjust custom extension overrides for opentelemetry * Add tests * Update README.md and remove windows limitation * Fix windows static build for opentelemetry --------- Co-authored-by: crazywhalecc <jesse2061@outlook.com>
This commit is contained in:
parent
f19e90afd7
commit
21de1a2291
@ -445,6 +445,13 @@
|
|||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"opentelemetry": {
|
||||||
|
"support": {
|
||||||
|
"BSD": "wip"
|
||||||
|
},
|
||||||
|
"type": "external",
|
||||||
|
"source": "opentelemetry"
|
||||||
|
},
|
||||||
"parallel": {
|
"parallel": {
|
||||||
"support": {
|
"support": {
|
||||||
"BSD": "wip"
|
"BSD": "wip"
|
||||||
|
|||||||
@ -683,6 +683,16 @@
|
|||||||
"path": "LICENSE.txt"
|
"path": "LICENSE.txt"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"opentelemetry": {
|
||||||
|
"type": "url",
|
||||||
|
"url": "https://pecl.php.net/get/opentelemetry",
|
||||||
|
"path": "php-src/ext/opentelemetry",
|
||||||
|
"filename": "opentelemetry.tgz",
|
||||||
|
"license": {
|
||||||
|
"type": "file",
|
||||||
|
"path": "LICENSE"
|
||||||
|
}
|
||||||
|
},
|
||||||
"parallel": {
|
"parallel": {
|
||||||
"type": "url",
|
"type": "url",
|
||||||
"url": "https://pecl.php.net/get/parallel",
|
"url": "https://pecl.php.net/get/parallel",
|
||||||
|
|||||||
@ -8,8 +8,15 @@ here will describe how to check the errors by yourself and report Issue.
|
|||||||
Problems with downloading resources are one of the most common problems with spc.
|
Problems with downloading resources are one of the most common problems with spc.
|
||||||
The main reason is that the addresses used for SPC download resources are generally the official website of the corresponding project or GitHub, etc.,
|
The main reason is that the addresses used for SPC download resources are generally the official website of the corresponding project or GitHub, etc.,
|
||||||
and these websites may occasionally go down and block IP addresses.
|
and these websites may occasionally go down and block IP addresses.
|
||||||
Currently, version 2.0.0 has not added an automatic retry mechanism, so after encountering a download failure,
|
After encountering a download failure,
|
||||||
you can try to call the download command multiple times. If you confirm that the address is indeed inaccessible,
|
you can try to call the download command multiple times.
|
||||||
|
|
||||||
|
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>`.
|
||||||
|
|
||||||
|
If you confirm that the address is indeed inaccessible,
|
||||||
you can submit an Issue or PR to update the url or download type.
|
you can submit an Issue or PR to update the url or download type.
|
||||||
|
|
||||||
## Doctor Can't Fix Something
|
## Doctor Can't Fix Something
|
||||||
|
|||||||
@ -5,7 +5,14 @@
|
|||||||
## 下载失败问题
|
## 下载失败问题
|
||||||
|
|
||||||
下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。
|
下载资源问题是 spc 最常见的问题之一。主要是由于 spc 下载资源使用的地址一般均为对应项目的官方网站或 GitHub 等,而这些网站可能偶尔会宕机、屏蔽 IP 地址。
|
||||||
目前 2.0.0 版本还没有加入自动重试机制,所以在遇到下载失败后,可以多次尝试调用下载命令。如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。
|
在遇到下载失败后,可以多次尝试调用下载命令。
|
||||||
|
|
||||||
|
当下载资源时,你可能最终会看到类似 `curl: (56) The requested URL returned error: 403` 的错误,这通常是由于 GitHub 限制导致的。
|
||||||
|
你可以通过在命令中添加 `--debug` 来验证,会看到类似 `[DEBU] Running command (no output) : curl -sfSL "https://api.github.com/repos/openssl/openssl/releases"` 的输出。
|
||||||
|
|
||||||
|
要解决这个问题,可以在 GitHub 上 [创建](https://github.com/settings/token) 一个个人访问令牌,并将其设置为环境变量 `GITHUB_TOKEN=<XXX>`。
|
||||||
|
|
||||||
|
如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。
|
||||||
|
|
||||||
## doctor 无法修复
|
## doctor 无法修复
|
||||||
|
|
||||||
|
|||||||
41
src/SPC/builder/extension/opentelemetry.php
Normal file
41
src/SPC/builder/extension/opentelemetry.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace SPC\builder\extension;
|
||||||
|
|
||||||
|
use SPC\builder\Extension;
|
||||||
|
use SPC\store\FileSystem;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
if (PHP_OS_FAMILY === 'Windows') {
|
||||||
|
FileSystem::replaceFileStr(
|
||||||
|
SOURCE_PATH . '/php-src/ext/opentelemetry/config.w32',
|
||||||
|
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');",
|
||||||
|
"EXTENSION('opentelemetry', 'opentelemetry.c otel_observer.c', PHP_OPENTELEMETRY_SHARED, '/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1');"
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
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'));
|
||||||
@ -13,17 +13,18 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
// test php version
|
// test php version
|
||||||
$test_php_version = [
|
$test_php_version = [
|
||||||
// '8.1',
|
'8.1',
|
||||||
// '8.2',
|
'8.2',
|
||||||
// '8.3',
|
'8.3',
|
||||||
'8.4',
|
'8.4',
|
||||||
];
|
];
|
||||||
|
|
||||||
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
|
// test os (macos-13, macos-14, ubuntu-latest, windows-latest are available)
|
||||||
$test_os = [
|
$test_os = [
|
||||||
|
'macos-13',
|
||||||
'macos-14',
|
'macos-14',
|
||||||
'ubuntu-latest',
|
'ubuntu-latest',
|
||||||
// 'windows-latest',
|
'windows-latest',
|
||||||
];
|
];
|
||||||
|
|
||||||
// whether enable thread safe
|
// whether enable thread safe
|
||||||
@ -39,8 +40,8 @@ $prefer_pre_built = true;
|
|||||||
|
|
||||||
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
|
||||||
$extensions = match (PHP_OS_FAMILY) {
|
$extensions = match (PHP_OS_FAMILY) {
|
||||||
'Linux', 'Darwin' => 'dio',
|
'Linux', 'Darwin' => 'opentelemetry',
|
||||||
'Windows' => 'dio',
|
'Windows' => 'opentelemetry',
|
||||||
};
|
};
|
||||||
|
|
||||||
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user