Skip to content

Commit

Permalink
PROMETHEUS_APP_NAME added
Browse files Browse the repository at this point in the history
  • Loading branch information
MadridianFox committed Feb 20, 2023
1 parent 826bdf4 commit 0341ce7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public function handle($request, Closure $next)
# config/prometheus.php
return [
'default_bag' => '<bag-name>',
'enabled' => env('PROMETHEUS_ENABLED', true),
'app_name' => env('PROMETHEUS_APP_NAME', env('APP_NAME')),
'bags' => [
'<bag-name>' => [
'namespace' => '<prometheus-namespace>',
Expand Down
5 changes: 3 additions & 2 deletions config/prometheus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [
'default_bag' => 'default',
'enabled' => env('PROMETHEUS_ENABLED', true),
'app_name' => env('PROMETHEUS_APP_NAME', env('APP_NAME')),
'bags' => [
'default' => [
'namespace' => env('PROMETHEUS_NAMESPACE', 'app'),
Expand All @@ -16,10 +17,10 @@
'bag' => 'default',
],
'label_middlewares' => [
\Ensi\LaravelPrometheus\LabelMiddlewares\AppNameLabelMiddleware::class,
// \Ensi\LaravelPrometheus\LabelMiddlewares\AppNameLabelMiddleware::class,
],
'on_demand_metrics' => [
\Ensi\LaravelPrometheus\OnDemandMetrics\MemoryUsageOnDemandMetric::class,
// \Ensi\LaravelPrometheus\OnDemandMetrics\MemoryUsageOnDemandMetric::class,
],
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/LabelMiddlewares/AppNameLabelMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public function labels(): array

public function values(): array
{
return [config('app.name')];
return [config('prometheus.app_name')];
}
}
4 changes: 3 additions & 1 deletion tests/MetricsBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,9 @@ public function testNoCreateSameMetricTwice(): void

public function testLabelMiddleware()
{
config(['app.name' => 'app-name']);
config([
'prometheus.app_name' => 'app-name'
]);

$bag = new MetricsBag([
'namespace' => 'test',
Expand Down

0 comments on commit 0341ce7

Please sign in to comment.