|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Contracts\Queue\Job; |
|
6
|
|
|
use Illuminate\Http\Request; |
|
|
|
|
|
|
7
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
8
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
9
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
|
|
|
|
|
10
|
|
|
use Umbrellio\Jaravel\Configurations; |
|
11
|
|
|
|
|
12
|
|
|
return [ |
|
13
|
|
|
/** |
|
14
|
|
|
* Enable Jaravel tracing or not. If not, noop tracer will be used. |
|
15
|
|
|
*/ |
|
16
|
|
|
'enabled' => env('JARAVEL_ENABLED', true), |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Name of your service, that will be shown in Jaeger panel |
|
20
|
|
|
*/ |
|
21
|
|
|
'tracer_name' => env('JARAVEL_TRACER_NAME', 'application'), |
|
22
|
|
|
|
|
23
|
|
|
'agent_host' => env('JARAVEL_AGENT_HOST', 'http://127.0.0.1'), |
|
24
|
|
|
|
|
25
|
|
|
'agent_port' => env('JARAVEL_AGENT_PORT', 6832), |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Every log in your application will be added to active span, if enabled |
|
29
|
|
|
*/ |
|
30
|
|
|
'logs_enabled' => env('JARAVEL_LOGS_ENABLED', true), |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Describes configuration for incoming Http requests |
|
34
|
|
|
*/ |
|
35
|
|
|
'http' => [ |
|
36
|
|
|
'span_name' => Configurations\Http\SpanNameResolver::class, |
|
37
|
|
|
'tags' => fn (Request $request, Response $response) => [ |
|
38
|
|
|
'type' => 'http', |
|
39
|
|
|
'request_host' => $request->getHost(), |
|
40
|
|
|
'request_path' => $request->path(), |
|
41
|
|
|
'request_method' => $request->method(), |
|
42
|
|
|
'response_status' => $response->getStatusCode(), |
|
43
|
|
|
'error' => !$response->isSuccessful() && !$response->isRedirection(), |
|
44
|
|
|
], |
|
45
|
|
|
], |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Describes configuration for console commands |
|
49
|
|
|
*/ |
|
50
|
|
|
'console' => [ |
|
51
|
|
|
'span_name' => fn (string $command, ?InputInterface $input = null) => 'Console: ' . $command, |
|
|
|
|
|
|
52
|
|
|
'filter_commands' => ['schedule:run', 'horizon', 'queue:'], |
|
53
|
|
|
'tags' => fn (string $command, int $exitCode, ?InputInterface $input = null, ?OutputInterface $output = null) => [ |
|
|
|
|
|
|
54
|
|
|
'type' => 'console', |
|
55
|
|
|
'console_command' => $command, |
|
56
|
|
|
'console_exit_code' => $exitCode, |
|
57
|
|
|
], |
|
58
|
|
|
], |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Describes configuration for queued jobs |
|
62
|
|
|
*/ |
|
63
|
|
|
'job' => [ |
|
64
|
|
|
'span_name' => fn ($realJob, ?Job $job) => 'Job: ' . get_class($realJob), |
|
|
|
|
|
|
65
|
|
|
'tags' => fn ($realJob, ?Job $job) => [ |
|
66
|
|
|
'type' => 'job', |
|
67
|
|
|
'job_class' => get_class($realJob), |
|
68
|
|
|
'job_id' => optional($job) |
|
69
|
|
|
->getJobId(), |
|
70
|
|
|
'job_connection_name' => optional($job) |
|
71
|
|
|
->getConnectionName(), |
|
72
|
|
|
'job_name' => optional($job) |
|
73
|
|
|
->getName(), |
|
74
|
|
|
'job_queue' => optional($job) |
|
75
|
|
|
->getQueue(), |
|
76
|
|
|
'job_attempts' => optional($job) |
|
77
|
|
|
->attempts(), |
|
78
|
|
|
], |
|
79
|
|
|
], |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Describes configuration for Guzzle requests if you`re using middleware created by HttpTracingMiddlewareFactory |
|
83
|
|
|
*/ |
|
84
|
|
|
'guzzle' => [ |
|
85
|
|
|
'span_name' => Configurations\Guzzle\SpanNameResolver::class, |
|
86
|
|
|
'tags' => Configurations\Guzzle\TagsResolver::class, |
|
87
|
|
|
], |
|
88
|
|
|
]; |
|
89
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: