Skip to content

Commit

Permalink
Trace: Allow Custom Trace Providers #25
Browse files Browse the repository at this point in the history
  • Loading branch information
iamacarpet committed Sep 5, 2018
1 parent 4ce4884 commit 7e43690
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"extra": {
"laravel": {
"providers": [
"A1comms\\GaeSupportLaravel\\GaeSupportServiceProvider",
"A1comms\\GaeSupportLaravel\\Trace\\TraceServiceProvider"
]
}
Expand Down
55 changes: 55 additions & 0 deletions src/A1comms/GaeSupportLaravel/GaeSupportServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace A1comms\GaeSupportLaravel;

use Illuminate\Support\ServiceProvider;

/**
* Class GaeSupportServiceProvider
*
* @package A1comms\GaeSupportLaravel
*/
class GaeSupportServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Register bindings in the container.
*
* @return void
*/
public function register()
{
$this->mergeConfigFrom(
__DIR__.'/../../config/gaesupport.php', 'gaesupport'
);
}

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
// Publish our config file when the user runs "artisan vendor:publish".
$this->publishes([
__DIR__.'/../../config/gaesupport.php' => config_path('gaesupport.php'),
]);
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array('gae-support');
}
}
4 changes: 4 additions & 0 deletions src/A1comms/GaeSupportLaravel/Trace/TraceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,9 @@ public function boot()
// Need to wait for rootSpan visibility to be changed to public.
// https://github.com/census-instrumentation/opencensus-php/issues/199
Tracer::inSpan(['name' => 'laravel/bootstrap', 'startTime' => LARAVEL_START], function () {});

foreach (config('gaesupport.trace_providers', []) as $p) {
$p::load();
}
}
}
21 changes: 21 additions & 0 deletions src/config/gaesupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

return [

/*
|--------------------------------------------------------------------------
| Trace Providers
|--------------------------------------------------------------------------
|
| This is an array of classes to register for the StackDriver Trace integration,
| defining runtime trace hooks via the opensensus PECL module,
| so code changes inside the application aren't required.
|
| These should implement OpenCensus\Trace\Integrations\IntegrationInterface
|
*/

'trace_providers' => [

],
];

0 comments on commit 7e43690

Please sign in to comment.