- 
                Notifications
    You must be signed in to change notification settings 
- Fork 117
👷 Laravel instrumentation 1.1.x #269
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
          
     Draft
      
      
            ChrisLightfootWild
  wants to merge
  48
  commits into
  open-telemetry:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
ChrisLightfootWild:spi/laravel
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            48 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      4c7f2c9
              
                Laravel: removed older hook/register.
              
              
                ChrisLightfootWild e2e039a
              
                Laravel: add new Hook interface for SPI.
              
              
                ChrisLightfootWild 65e413e
              
                Laravel: load Laravel instruments via SPI.
              
              
                ChrisLightfootWild 1deb2b4
              
                Laravel: watchers accept TracerInterface.
              
              
                ChrisLightfootWild 98af07f
              
                Laravel: hook Foundation\Application.
              
              
                ChrisLightfootWild 1ba04c2
              
                Laravel: convert more hooks.
              
              
                ChrisLightfootWild f3428c5
              
                Laravel: added LaravelComponentProvider and LaravelConfiguration.
              
              
                ChrisLightfootWild bb09763
              
                Laravel: PoC composer changes for SPI.
              
              
                ChrisLightfootWild c1ed471
              
                Laravel: register with SPI ServiceLoader in case SPI plugin is not al…
              
              
                ChrisLightfootWild 3d9beb3
              
                Laravel: enabled spi-config.autoload-files composer config for SPI pl…
              
              
                ChrisLightfootWild 9788fdd
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild 60ba83a
              
                Laravel: fix return type.
              
              
                ChrisLightfootWild d5cdeca
              
                Laravel: updates after AutoInstrumentation in API was merged to main.
              
              
                ChrisLightfootWild e494ac2
              
                Laravel: use Configuration\ConfigProperties API for instrumentation r…
              
              
                ChrisLightfootWild ea2e4bb
              
                Laravel: use updated TraceAttributeValues::MESSAGING_OPERATION_TYPE_*…
              
              
                ChrisLightfootWild 4231acd
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild ea05ad4
              
                Laravel: added ComponentProvider namespace.
              
              
                ChrisLightfootWild d67da56
              
                Laravel: bump otel dependencies to 1.1.
              
              
                ChrisLightfootWild 190f628
              
                Laravel: respect current way of disabling instrumentation.
              
              
                ChrisLightfootWild 7412881
              
                Laravel: sem-conv 1.24.
              
              
                ChrisLightfootWild d2887bc
              
                Laravel: bump phpunit.
              
              
                ChrisLightfootWild cf6deaf
              
                Laravel: tests bootstrap via SPI.
              
              
                ChrisLightfootWild c53a6db
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild 3eec435
              
                Laravel: skip PHP 8.0 in CI.
              
              
                ChrisLightfootWild 45a6932
              
                Laravel: lint.
              
              
                ChrisLightfootWild ee8cebe
              
                Laravel: nullify missing attributes to reduce noise.
              
              
                ChrisLightfootWild a6a677e
              
                Laravel: remove dev-dependencies which are not explicitly required.
              
              
                ChrisLightfootWild 6a8d0ef
              
                Laravel: bump target_php_version in phan.
              
              
                ChrisLightfootWild 60fc781
              
                Laravel: suppress PhanTypeMismatchReturn in LaravelComponentProvider.
              
              
                ChrisLightfootWild 0d7dcf4
              
                Laravel: remove property_exists check that supported Laravel versions…
              
              
                ChrisLightfootWild 16dc809
              
                Laravel: pass instrumentation Context to hooks
              
              
                ChrisLightfootWild fc1df3f
              
                Laravel: suppress PhanDeprecatedClassConstant for deprecated sem-conv…
              
              
                ChrisLightfootWild c9a83fe
              
                Laravel: drop ext-opentelemetry hard requirement.
              
              
                ChrisLightfootWild 44440df
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild a3cf950
              
                Laravel: use TextMapPropagatorInterface from InstrumentationContext i…
              
              
                ChrisLightfootWild 504796e
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild f18ab42
              
                Laravel: update LaravelConfiguration enabled logic with default config.
              
              
                ChrisLightfootWild b0d6da3
              
                Laravel: added suggested propagators to composer.json.
              
              
                ChrisLightfootWild b5b053a
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild fee0f01
              
                Laravel: updated semconv attributes
              
              
                ChrisLightfootWild 828dca2
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild 1513e1b
              
                Laravel: _register ordering
              
              
                ChrisLightfootWild d65a213
              
                Laravel: updated ComponentProviders to fulfil most recent interface
              
              
                ChrisLightfootWild 1c65531
              
                Laravel: composer updates and component provider updates
              
              
                ChrisLightfootWild b30d150
              
                Merge remote-tracking branch 'upstream/main' into spi/laravel
              
              
                ChrisLightfootWild 709dd6c
              
                Laravel: lint
              
              
                ChrisLightfootWild 6ce15a7
              
                Laravel: missing import
              
              
                ChrisLightfootWild 70a5996
              
                Laravel: psalm-suppress UnusedClass. SPI loads these.
              
              
                ChrisLightfootWild File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,18 +1,30 @@ | ||
| <?php | ||
|  | ||
| /** | ||
| * This file must *only* be used to register SPI components, as it | ||
| * will be pruned automatically via the tbachert/spi plugin. | ||
| */ | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| use Nevay\SPI\ServiceLoader; | ||
| use OpenTelemetry\API\Instrumentation\AutoInstrumentation\Instrumentation; | ||
| use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks; | ||
| use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelInstrumentation; | ||
| use OpenTelemetry\SDK\Sdk; | ||
|  | ||
| if (class_exists(Sdk::class) && Sdk::isInstrumentationDisabled(LaravelInstrumentation::NAME) === true) { | ||
| return; | ||
| } | ||
| ServiceLoader::register(Instrumentation::class, LaravelInstrumentation::class); | ||
|  | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Console\Command::class); | ||
|  | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Console\Kernel::class); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Http\Kernel::class); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Contracts\Queue\Queue::class); | ||
|  | ||
| if (extension_loaded('opentelemetry') === false) { | ||
| trigger_error('The opentelemetry extension must be loaded in order to autoload the OpenTelemetry Laravel auto-instrumentation', E_USER_WARNING); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Database\Eloquent\Model::class); | ||
|  | ||
| return; | ||
| } | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Foundation\Application::class); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Foundation\Console\ServeCommand::class); | ||
|  | ||
| LaravelInstrumentation::register(); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\Queue::class); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\SyncQueue::class); | ||
| ServiceLoader::register(Hooks\Hook::class, Hooks\Illuminate\Queue\Worker::class); | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -11,28 +11,22 @@ | |
| "require": { | ||
| "php": "^8.1", | ||
| "ext-json": "*", | ||
| "ext-opentelemetry": "*", | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed based on similar issue raised for PDO instrumentation. | ||
| "laravel/framework": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0", | ||
| "laravel/framework": "^10.0 || ^11.0 || ^12.0", | ||
| "open-telemetry/api": "^1.6", | ||
| "open-telemetry/sem-conv": "^1.32" | ||
| }, | ||
| "suggest": { | ||
| "open-telemetry/opentelemetry-propagation-server-timing": "Automatically propagate the context to the client through server-timing headers.", | ||
| "open-telemetry/opentelemetry-propagation-traceresponse": "Automatically propagate the context to the client through trace-response headers." | ||
| }, | ||
| "require-dev": { | ||
| "friendsofphp/php-cs-fixer": "^3.50", | ||
| "guzzlehttp/guzzle": "*", | ||
| "nunomaduro/collision": "*", | ||
| "open-telemetry/sdk": "^1.8", | ||
| "open-telemetry/sdk-configuration": "^0.3.0", | ||
| "orchestra/testbench": ">=7.41.3", | ||
| "phan/phan": "^5.0", | ||
| "php-http/mock-client": "*", | ||
| "phpstan/phpstan": "^1.1", | ||
| "phpstan/phpstan-phpunit": "^1.0", | ||
| "phpunit/phpunit": "^9.5", | ||
| "phpunit/phpunit": "^10.5 || ^11.3", | ||
| "psalm/plugin-phpunit": "^0.19.2", | ||
| "spatie/laravel-ignition": "*", | ||
| "vimeo/psalm": "6.4.0" | ||
| }, | ||
| "autoload": { | ||
|  | @@ -48,11 +42,27 @@ | |
| "OpenTelemetry\\Tests\\Contrib\\Instrumentation\\Laravel\\": "tests/" | ||
| } | ||
| }, | ||
| "suggest": { | ||
| "ext-opentelemetry": "Required to provide auto-instrumentation hooks.", | ||
| "open-telemetry/opentelemetry-propagation-server-timing": "Automatically propagate the context to the client through server-timing headers.", | ||
| "open-telemetry/opentelemetry-propagation-traceresponse": "Automatically propagate the context to the client through trace-response headers." | ||
| }, | ||
| "extra": { | ||
| "spi-config": { | ||
| "autoload-files": true | ||
| }, | ||
| "spi": { | ||
| "OpenTelemetry\\API\\Configuration\\Config\\ComponentProvider": [ | ||
| "OpenTelemetry\\Contrib\\Instrumentation\\Laravel\\ComponentProvider\\LaravelComponentProvider" | ||
| ] | ||
| } | ||
| }, | ||
| "config": { | ||
| "lock": false, | ||
| "sort-packages": true, | ||
| "allow-plugins": { | ||
| "php-http/discovery": false | ||
| "php-http/discovery": false, | ||
| "tbachert/spi": true | ||
| } | ||
| } | ||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
  
    
      
          
            33 changes: 33 additions & 0 deletions
          
          33 
        
  src/Instrumentation/Laravel/src/ComponentProvider/LaravelComponentProvider.php
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace OpenTelemetry\Contrib\Instrumentation\Laravel\ComponentProvider; | ||
|  | ||
| use OpenTelemetry\API\Configuration\Config\ComponentProvider; | ||
| use OpenTelemetry\API\Configuration\Config\ComponentProviderRegistry; | ||
| use OpenTelemetry\API\Configuration\Context; | ||
| use OpenTelemetry\API\Instrumentation\AutoInstrumentation\InstrumentationConfiguration; | ||
| use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelConfiguration; | ||
| use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; | ||
| use Symfony\Component\Config\Definition\Builder\NodeBuilder; | ||
|  | ||
| class LaravelComponentProvider implements ComponentProvider | ||
| { | ||
| /** | ||
| * @phan-suppress PhanTypeMismatchReturn | ||
| */ | ||
| public function createPlugin(array $properties, Context $context): InstrumentationConfiguration | ||
| { | ||
| return LaravelConfiguration::fromArray($properties); | ||
| } | ||
|  | ||
| public function getConfig(ComponentProviderRegistry $registry, NodeBuilder $builder): ArrayNodeDefinition | ||
| { | ||
| return $builder | ||
| ->arrayNode('laravel') | ||
| ->canBeDisabled() | ||
| ->addDefaultsIfNotSet() | ||
| ; | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <?php | ||
|  | ||
| declare(strict_types=1); | ||
|  | ||
| namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks; | ||
|  | ||
| use OpenTelemetry\API\Instrumentation\AutoInstrumentation\Context as InstrumentationContext; | ||
| use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface; | ||
| use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelInstrumentation; | ||
|  | ||
| interface Hook | ||
| { | ||
| public function instrument( | ||
| LaravelInstrumentation $instrumentation, | ||
| HookManagerInterface $hookManager, | ||
| InstrumentationContext $context, | ||
| ): void; | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.