diff --git a/config/ext.json b/config/ext.json index 08ed6777..325e40d0 100644 --- a/config/ext.json +++ b/config/ext.json @@ -445,6 +445,13 @@ "zlib" ] }, + "opentelemetry": { + "support": { + "BSD": "wip" + }, + "type": "external", + "source": "opentelemetry" + }, "parallel": { "support": { "BSD": "wip" diff --git a/config/source.json b/config/source.json index a3ecd8df..b97ab139 100644 --- a/config/source.json +++ b/config/source.json @@ -683,6 +683,16 @@ "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": { "type": "url", "url": "https://pecl.php.net/get/parallel", diff --git a/docs/en/guide/troubleshooting.md b/docs/en/guide/troubleshooting.md index 0dbb17d5..c3366f6d 100644 --- a/docs/en/guide/troubleshooting.md +++ b/docs/en/guide/troubleshooting.md @@ -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. 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. -Currently, version 2.0.0 has not added an automatic retry mechanism, so after encountering a download failure, -you can try to call the download command multiple times. If you confirm that the address is indeed inaccessible, +After encountering a download failure, +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=`. + +If you confirm that the address is indeed inaccessible, you can submit an Issue or PR to update the url or download type. ## Doctor Can't Fix Something diff --git a/docs/zh/guide/troubleshooting.md b/docs/zh/guide/troubleshooting.md index 22b36f81..030edf45 100644 --- a/docs/zh/guide/troubleshooting.md +++ b/docs/zh/guide/troubleshooting.md @@ -5,7 +5,14 @@ ## 下载失败问题 下载资源问题是 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=`。 + +如果确认地址确实无法正常访问,可以提交 Issue 或 PR 更新地址。 ## doctor 无法修复 diff --git a/src/SPC/builder/extension/opentelemetry.php b/src/SPC/builder/extension/opentelemetry.php new file mode 100644 index 00000000..4b0829e0 --- /dev/null +++ b/src/SPC/builder/extension/opentelemetry.php @@ -0,0 +1,41 @@ +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; + } +} diff --git a/src/globals/ext-tests/opentelemetry.php b/src/globals/ext-tests/opentelemetry.php new file mode 100644 index 00000000..746068b3 --- /dev/null +++ b/src/globals/ext-tests/opentelemetry.php @@ -0,0 +1,5 @@ + 'dio', - 'Windows' => 'dio', + 'Linux', 'Darwin' => 'opentelemetry', + 'Windows' => 'opentelemetry', }; // If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).