Skip to content

fix(laravel): use KIND_SERVER for Artisan Kernel::handle span#667

Open
zigzagdev wants to merge 1 commit into
open-telemetry:mainfrom
zigzagdev:fix/laravel-artisan-kernel-span-kind
Open

fix(laravel): use KIND_SERVER for Artisan Kernel::handle span#667
zigzagdev wants to merge 1 commit into
open-telemetry:mainfrom
zigzagdev:fix/laravel-artisan-kernel-span-kind

Conversation

@zigzagdev

Copy link
Copy Markdown
Contributor

Summary

Description

  • Illuminate\Contracts\Console\Kernel::handle() is instrumented with SpanKind::KIND_PRODUCER, which is meant for fire-and-forget messages sent to a queue and does not describe a synchronous Artisan CLI invocation.
  • Changed to SpanKind::KIND_SERVER, matching the role this span plays as the entry point of the Artisan process — the same treatment already given to Hooks/Illuminate/Contracts/Http/Kernel.php's handle() span for HTTP requests.

Why no test was added

The existing test suite cannot cover this bug in principle:

  • Kernel::instrument() only registers hookHandle() when shouldTraceCli() returns true
  • shouldTraceCli() evaluates to false during PHPUnit runs because PHPUnit itself runs under the CLI SAPI (PHP_SAPI === 'cli') and OTEL_PHP_TRACE_CLI_ENABLED defaults to false.
    So, Kernel::hookHandle() is never registered during test execution, making it impossible to assert on the SpanKind from within the test suite.

@zigzagdev
zigzagdev requested a review from a team as a code owner July 23, 2026 13:20
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.09%. Comparing base (03b5f93) to head (9da7620).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
.../src/Hooks/Illuminate/Contracts/Console/Kernel.php 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main     #667   +/-   ##
=========================================
  Coverage     80.09%   80.09%           
  Complexity     1597     1597           
=========================================
  Files           118      118           
  Lines          6179     6179           
=========================================
  Hits           4949     4949           
  Misses         1230     1230           
Flag Coverage Δ
Context/Swoole 0.00% <ø> (ø)
Exporter/Instana 49.80% <ø> (ø)
Instrumentation/AwsSdk 82.14% <ø> (ø)
Instrumentation/CakePHP 20.42% <ø> (ø)
Instrumentation/CodeIgniter 79.31% <ø> (ø)
Instrumentation/Curl 86.88% <ø> (ø)
Instrumentation/Doctrine 92.82% <ø> (ø)
Instrumentation/ExtAmqp 88.80% <ø> (ø)
Instrumentation/Guzzle 79.76% <ø> (ø)
Instrumentation/HttpAsyncClient 78.94% <ø> (ø)
Instrumentation/HttpConfig 28.76% <ø> (ø)
Instrumentation/IO 0.00% <ø> (ø)
Instrumentation/Laravel 75.72% <0.00%> (ø)
Instrumentation/Magento2 88.12% <ø> (ø)
Instrumentation/MongoDB 76.84% <ø> (ø)
Instrumentation/OpenAIPHP 86.71% <ø> (ø)
Instrumentation/PostgreSql 91.36% <ø> (ø)
Instrumentation/Psr14 77.41% <ø> (ø)
Instrumentation/Psr15 89.74% <ø> (ø)
Instrumentation/Psr16 97.43% <ø> (ø)
Instrumentation/Psr18 79.41% <ø> (ø)
Instrumentation/Psr6 97.56% <ø> (ø)
Instrumentation/ReactPHP 99.41% <ø> (ø)
Instrumentation/Session 94.28% <ø> (ø)
Instrumentation/Slim 84.21% <ø> (ø)
Propagation/CloudTrace 90.69% <ø> (ø)
Propagation/Instana 98.07% <ø> (ø)
Propagation/ServerTiming 94.73% <ø> (ø)
Propagation/TraceResponse 94.73% <ø> (ø)
ResourceDetectors/Azure 91.66% <ø> (ø)
ResourceDetectors/DigitalOcean 100.00% <ø> (ø)
Sampler/Xray 78.38% <ø> (ø)
Shims/OpenTracing 92.99% <ø> (ø)
SqlCommenter 95.58% <ø> (ø)
Utils/Test 87.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../src/Hooks/Illuminate/Contracts/Console/Kernel.php 0.00% <0.00%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03b5f93...9da7620. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant