-
-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
f19e90a
commit 21de1a2
Showing
7 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,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; | ||
} | ||
} |
This file contains 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,5 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
assert(function_exists('OpenTelemetry\Instrumentation\hook')); |
This file contains 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