Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added \Attribute::TARGET_PARAMETER to \OpenTelemetry\API\Instrumentation\SpanAttribute #1433

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 {
}
};
}
}