Skip to content

Commit

Permalink
Merge branch 'open-telemetry:main' into config-0.3-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
brettmc authored Nov 18, 2024
2 parents def56f1 + 8857b0c commit bcedd00
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- "main"
pull_request:
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion proto/otel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"require": {
"php": "^8.0",
"google/protobuf": "^3.3.0"
"google/protobuf": "^3.22 || ^4.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/API/Instrumentation/SpanAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/**
Expand Down
8 changes: 6 additions & 2 deletions src/SDK/Resource/Detectors/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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');
Expand Down
15 changes: 15 additions & 0 deletions tests/Unit/API/Instrumentation/SpanAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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 {
}
};
}
}

0 comments on commit bcedd00

Please sign in to comment.