open-telemetry / open-telemetry/opentelemetry-php
#[WithSpan] with SpanKind consts
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 912
- Forks
- 232
- Avg merge
- 7d 16h
- Merged PRs (30d)
- 4
Description
Describe your environment
PHP 8.2.29 (from php:8.2-apache-bullseye docker image)
php --ri opentelemetry
opentelemetry
opentelemetry hooks => enabled
extension version => 1.2.1
Directive => Local Value => Master Value
opentelemetry.conflicts => no value => no value
opentelemetry.validate_hook_functions => On => On
opentelemetry.allow_stack_extension => Off => Off
opentelemetry.attr_hooks_enabled => On => On
opentelemetry.display_warnings => Off => Off
opentelemetry.attr_pre_handler_function => OpenTelemetry\API\Instrumentation\WithSpanHandler::pre => OpenTelemetry\API\Instrumentation\WithSpanHandler::pre
opentelemetry.attr_post_handler_function => OpenTelemetry\API\Instrumentation\WithSpanHandler::post => OpenTelemetry\API\Instrumentation\WithSpanHandler::post
composer show | grep open-telemetry
open-telemetry/api 1.8.0 API for OpenTelemetry PHP.
open-telemetry/context 1.4.0 Context implementation for OpenTelemetry PHP.
open-telemetry/exporter-otlp 1.3.2 OTLP exporter for OpenTelemetry.
open-telemetry/gen-otlp-protobuf 1.5.0 PHP protobuf files for communication with OpenTelemetry OTLP collectors/servers.
open-telemetry/opentelemetry-auto-guzzle 1.2.1 OpenTelemetry auto-instrumentation for Guzzle.
open-telemetry/opentelemetry-auto-laravel 1.4.0 OpenTelemetry auto-instrumentation for Laravel
open-telemetry/opentelemetry-auto-psr18 1.1.1 OpenTelemetry auto-instrumentation for PSR-18 (HTTP Client).
open-telemetry/sdk 1.12.0 SDK for OpenTelemetry PHP.
open-telemetry/sem-conv 1.38.0 Semantic conventions for OpenTelemetry PHP.
Steps to reproduce
use OpenTelemetry\API\Instrumentation\WithSpan;
use OpenTelemetry\API\Trace\SpanKind;
#[WithSpan("foo", SpanKind::KIND_PRODUCER)]
private function foo()
{
echo 1;
}
calls OpenTelemetry\API\Instrumentation\WithSpanHandler::pre with
$span_args = [
"name" => "foo",
"span_kind" => null,
];
What is the expected behavior?
$span_args = [
"name" => "foo",
"span_kind" => 3,
];
#[WithSpan("foo", 3)] works correctly, but #[WithSpan("foo", SpanKind::KIND_PRODUCER)] is wrong.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with OpenTelemetry\API\Instrumentation\WithSpan and WithSpanHandler::pre, then inspect how the SpanKind::KIND_PRODUCER attribute argument is resolved. Reproduce the example with PHP 8.2 and confirm that the handler receives span_kind as 3 rather than null; the literal 3 case provides a working comparison.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- observability
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100