Skip to content

Commit

Permalink
Laravel: updates after AutoInstrumentation in API was merged to main.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLightfootWild committed Aug 25, 2024
1 parent 60ba83a commit d5cdeca
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions src/Instrumentation/Laravel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"ext-json": "*",
"ext-opentelemetry": "*",
"laravel/framework": "^10.0 || ^11.0",
"open-telemetry/opentelemetry": "dev-auto-instrumentation-registration"
"open-telemetry/opentelemetry": "dev-main as 1.x-dev"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.50",
Expand Down Expand Up @@ -55,7 +55,7 @@
"repositories": [
{
"type": "vcs",
"url": "https://github.com/brettmc/opentelemetry-php"
"url": "https://github.com/open-telemetry/opentelemetry-php"
}
],
"config": {
Expand Down
4 changes: 2 additions & 2 deletions src/Instrumentation/Laravel/src/Hooks/Hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks;

use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\TracerInterface;
Expand All @@ -13,7 +13,7 @@
interface Hook
{
public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Console;

use Illuminate\Console\Command as IlluminateCommand;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\Span;
Expand All @@ -22,7 +22,7 @@ class Command implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -31,7 +31,7 @@ public function instrument(
$this->hookExecute($hookManager, $tracer);
}

protected function hookExecute(HookManager $hookManager, TracerInterface $tracer): void
protected function hookExecute(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
IlluminateCommand::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel as KernelContract;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\Span;
Expand All @@ -28,7 +28,7 @@ class Kernel implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -39,7 +39,7 @@ public function instrument(
}
}

private function hookHandle(HookManager $hookManager, TracerInterface $tracer): void
private function hookHandle(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
KernelContract::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
use OpenTelemetry\API\Globals;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\Span;
Expand All @@ -31,7 +31,7 @@ class Kernel implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -40,7 +40,7 @@ public function instrument(
$this->hookHandle($hookManager, $tracer);
}

protected function hookHandle(HookManager $hookManager, TracerInterface $tracer): void
protected function hookHandle(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
KernelContract::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
use DateInterval;
use DateTimeInterface;
use Illuminate\Contracts\Queue\Queue as QueueContract;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\TracerInterface;
use OpenTelemetry\Context\Context;
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Queue\AttributesBuilder;
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Hook;
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Queue\AttributesBuilder;
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\PostHookTrait;
use OpenTelemetry\Contrib\Instrumentation\Laravel\LaravelConfiguration;
use OpenTelemetry\SemConv\TraceAttributes;
Expand All @@ -27,7 +27,7 @@ class Queue implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -38,7 +38,7 @@ public function instrument(
$this->hookPushRaw($hookManager, $tracer);
}

protected function hookBulk(HookManager $hookManager, TracerInterface $tracer): void
protected function hookBulk(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
QueueContract::class,
Expand Down Expand Up @@ -73,7 +73,7 @@ protected function hookBulk(HookManager $hookManager, TracerInterface $tracer):
);
}

protected function hookLater(HookManager $hookManager, TracerInterface $tracer): void
protected function hookLater(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
QueueContract::class,
Expand Down Expand Up @@ -115,7 +115,7 @@ protected function hookLater(HookManager $hookManager, TracerInterface $tracer):
);
}

protected function hookPushRaw(HookManager $hookManager, TracerInterface $tracer): void
protected function hookPushRaw(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
QueueContract::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Foundation\Application as FoundationalApplication;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\TracerInterface;
Expand All @@ -23,7 +23,7 @@
class Application implements Hook
{
public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Foundation\Console;

use Illuminate\Foundation\Console\ServeCommand as FoundationServeCommand;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\TracerInterface;
Expand All @@ -18,7 +18,7 @@
class ServeCommand implements Hook
{
public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Queue;

use Illuminate\Queue\Queue as AbstractQueue;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\Propagation\TraceContextPropagator;
Expand All @@ -19,7 +19,7 @@ class Queue implements Hook
use AttributesBuilder;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Illuminate\Queue;

use Illuminate\Queue\SyncQueue as LaravelSyncQueue;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\SpanKind;
Expand All @@ -23,7 +23,7 @@ class SyncQueue implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -32,7 +32,7 @@ public function instrument(
$this->hookPush($hookManager, $tracer);
}

protected function hookPush(HookManager $hookManager, TracerInterface $tracer): void
protected function hookPush(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
LaravelSyncQueue::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\Queue\Job;
use Illuminate\Queue\Worker as QueueWorker;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Logs\LoggerInterface;
use OpenTelemetry\API\Metrics\MeterInterface;
use OpenTelemetry\API\Trace\Propagation\TraceContextPropagator;
Expand All @@ -27,7 +27,7 @@ class Worker implements Hook
use PostHookTrait;

public function instrument(
HookManager $hookManager,
HookManagerInterface $hookManager,
LaravelConfiguration $configuration,
LoggerInterface $logger,
MeterInterface $meter,
Expand All @@ -37,7 +37,7 @@ public function instrument(
$this->hookWorkerGetNextJob($hookManager, $tracer);
}

private function hookWorkerProcess(HookManager $hookManager, TracerInterface $tracer): void
private function hookWorkerProcess(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
QueueWorker::class,
Expand Down Expand Up @@ -88,7 +88,7 @@ private function hookWorkerProcess(HookManager $hookManager, TracerInterface $tr
);
}

private function hookWorkerGetNextJob(HookManager $hookManager, TracerInterface $tracer): void
private function hookWorkerGetNextJob(HookManagerInterface $hookManager, TracerInterface $tracer): void
{
$hookManager->hook(
QueueWorker::class,
Expand Down
2 changes: 1 addition & 1 deletion src/Instrumentation/Laravel/src/LaravelConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private function __construct(
public static function fromArray(array $properties): self
{
return new self(
enabled: $properties['enabled'] ?? (class_exists(Sdk::class) ? !Sdk::isDisabled() : true),
enabled: (class_exists(Sdk::class) && !Sdk::isDisabled()) || $properties['enabled'],
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Instrumentation/Laravel/src/LaravelInstrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Nevay\SPI\ServiceLoader;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\ConfigurationRegistry;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\Context;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManager;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\HookManagerInterface;
use OpenTelemetry\API\Instrumentation\AutoInstrumentation\Instrumentation;
use OpenTelemetry\API\Instrumentation\ConfigurationResolver;
use OpenTelemetry\Contrib\Instrumentation\Laravel\Hooks\Hook;
Expand All @@ -17,7 +17,7 @@ class LaravelInstrumentation implements Instrumentation
{
public const INSTRUMENTATION_NAME = 'io.opentelemetry.contrib.php.laravel';

public function register(HookManager $hookManager, ConfigurationRegistry $configuration, Context $context): void
public function register(HookManagerInterface $hookManager, ConfigurationRegistry $configuration, Context $context): void
{
$config = $configuration->get(LaravelConfiguration::class) ?? LaravelConfiguration::default();

Expand Down

0 comments on commit d5cdeca

Please sign in to comment.