Skip to content

Commit 7e43690

Browse files
committed
Trace: Allow Custom Trace Providers #25
1 parent 4ce4884 commit 7e43690

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"extra": {
2727
"laravel": {
2828
"providers": [
29+
"A1comms\\GaeSupportLaravel\\GaeSupportServiceProvider",
2930
"A1comms\\GaeSupportLaravel\\Trace\\TraceServiceProvider"
3031
]
3132
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
namespace A1comms\GaeSupportLaravel;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
/**
8+
* Class GaeSupportServiceProvider
9+
*
10+
* @package A1comms\GaeSupportLaravel
11+
*/
12+
class GaeSupportServiceProvider extends ServiceProvider
13+
{
14+
/**
15+
* Indicates if loading of the provider is deferred.
16+
*
17+
* @var bool
18+
*/
19+
protected $defer = false;
20+
21+
/**
22+
* Register bindings in the container.
23+
*
24+
* @return void
25+
*/
26+
public function register()
27+
{
28+
$this->mergeConfigFrom(
29+
__DIR__.'/../../config/gaesupport.php', 'gaesupport'
30+
);
31+
}
32+
33+
/**
34+
* Bootstrap any application services.
35+
*
36+
* @return void
37+
*/
38+
public function boot()
39+
{
40+
// Publish our config file when the user runs "artisan vendor:publish".
41+
$this->publishes([
42+
__DIR__.'/../../config/gaesupport.php' => config_path('gaesupport.php'),
43+
]);
44+
}
45+
46+
/**
47+
* Get the services provided by the provider.
48+
*
49+
* @return array
50+
*/
51+
public function provides()
52+
{
53+
return array('gae-support');
54+
}
55+
}

src/A1comms/GaeSupportLaravel/Trace/TraceServiceProvider.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ public function boot()
2020
// Need to wait for rootSpan visibility to be changed to public.
2121
// https://github.com/census-instrumentation/opencensus-php/issues/199
2222
Tracer::inSpan(['name' => 'laravel/bootstrap', 'startTime' => LARAVEL_START], function () {});
23+
24+
foreach (config('gaesupport.trace_providers', []) as $p) {
25+
$p::load();
26+
}
2327
}
2428
}

src/config/gaesupport.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Trace Providers
8+
|--------------------------------------------------------------------------
9+
|
10+
| This is an array of classes to register for the StackDriver Trace integration,
11+
| defining runtime trace hooks via the opensensus PECL module,
12+
| so code changes inside the application aren't required.
13+
|
14+
| These should implement OpenCensus\Trace\Integrations\IntegrationInterface
15+
|
16+
*/
17+
18+
'trace_providers' => [
19+
20+
],
21+
];

0 commit comments

Comments
 (0)