diff --git a/.github/workflows/phpdoc-to-github-pages b/.github/workflows/phpdoc-to-github-pages.yml similarity index 98% rename from .github/workflows/phpdoc-to-github-pages rename to .github/workflows/phpdoc-to-github-pages.yml index 69334e287..36648d157 100644 --- a/.github/workflows/phpdoc-to-github-pages +++ b/.github/workflows/phpdoc-to-github-pages.yml @@ -4,7 +4,6 @@ on: push: branches: - "main" - pull_request: workflow_dispatch: # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages diff --git a/README.md b/README.md index 2944e391b..10565533d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ This is the **[monorepo](https://en.wikipedia.org/wiki/Monorepo)** for the **mai Please read the official documentation: https://opentelemetry.io/docs/instrumentation/php/ +API Documentation is available here: https://open-telemetry.github.io/opentelemetry-php/ + ## Packages and versions | Package | Latest | diff --git a/proto/otel/composer.json b/proto/otel/composer.json index 1ee4865e8..95a701889 100644 --- a/proto/otel/composer.json +++ b/proto/otel/composer.json @@ -18,7 +18,7 @@ ], "require": { "php": "^8.0", - "google/protobuf": "^3.3.0" + "google/protobuf": "^3.22 || ^4.0" }, "autoload": { "psr-4": { diff --git a/src/API/Instrumentation/SpanAttribute.php b/src/API/Instrumentation/SpanAttribute.php index b2dcd1ef8..1a9fa1d13 100644 --- a/src/API/Instrumentation/SpanAttribute.php +++ b/src/API/Instrumentation/SpanAttribute.php @@ -11,7 +11,7 @@ * attribute, adding this attribute to an argument will * add the argument as a span attribute. */ -#[Attribute(Attribute::TARGET_PROPERTY)] +#[Attribute(Attribute::TARGET_PARAMETER | Attribute::TARGET_PROPERTY)] final class SpanAttribute { /** diff --git a/src/SDK/Resource/Detectors/Host.php b/src/SDK/Resource/Detectors/Host.php index 7d74f6991..3a353cc67 100644 --- a/src/SDK/Resource/Detectors/Host.php +++ b/src/SDK/Resource/Detectors/Host.php @@ -54,7 +54,9 @@ private function getLinuxId(): ?string foreach ($paths as $path) { $file = $this->dir . $path; if (is_file($file) && is_readable($file)) { - return trim(file_get_contents($file)); + $contents = file_get_contents($file); + + return $contents !== false ? trim($contents) : null; } } @@ -65,7 +67,9 @@ private function getBsdId(): ?string { $file = $this->dir . self::PATH_ETC_HOSTID; if (is_file($file) && is_readable($file)) { - return trim(file_get_contents($file)); + $contents = file_get_contents($file); + + return $contents !== false ? trim($contents) : null; } $out = exec('which kenv && kenv -q smbios.system.uuid'); diff --git a/tests/Unit/API/Instrumentation/SpanAttributeTest.php b/tests/Unit/API/Instrumentation/SpanAttributeTest.php index d6437aa82..cc905ecde 100644 --- a/tests/Unit/API/Instrumentation/SpanAttributeTest.php +++ b/tests/Unit/API/Instrumentation/SpanAttributeTest.php @@ -5,7 +5,9 @@ namespace OpenTelemetry\Tests\Unit\API\Instrumentation; use OpenTelemetry\API\Instrumentation\SpanAttribute; +use OpenTelemetry\API\Instrumentation\WithSpan; use PHPUnit\Framework\Attributes\CoversClass; +use PHPUnit\Framework\Attributes\DoesNotPerformAssertions; use PHPUnit\Framework\TestCase; #[CoversClass(SpanAttribute::class)] @@ -16,4 +18,17 @@ public function test_with_span(): void $attr = new SpanAttribute('foo'); $this->assertSame('foo', $attr->name); } + + #[DoesNotPerformAssertions] + public function test_attribute_targets_parameter(): void + { + new class() { + #[WithSpan] + public function foo( + #[SpanAttribute] string $a, + #[SpanAttribute('a_better_attribute_name')] string $b, + ): void { + } + }; + } }