Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acseo/syliusprometheusmetricsplugin
https://github.com/acseo/syliusprometheusmetricsplugin
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/acseo/syliusprometheusmetricsplugin
- Owner: acseo
- License: other
- Created: 2023-05-31T14:40:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-09T16:02:08.000Z (5 months ago)
- Last Synced: 2024-08-09T17:45:34.183Z (5 months ago)
- Language: PHP
- Size: 61.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Sylius Prometheus Metrics
## Features
### Observability
We use the _artprima/prometheus-metrics-bundle_ (https://github.com/artprima/prometheus-metrics-bundle) bundle to collect metrics in the Prometheus format, which can then be used to build a dashboard with Grafana.
These metrics are visible at the **/metrics/prometheus** URL of the website.Default metrics are generated. It is possible to create custom metrics to track "Business" data, such as the number of created orders or the order amount.
## Installation
1. Run `$ composer require acseo/sylius-prometheus-metrics-plugin`.
2. Add these few lines to the `config/state_machine/sylius_payment.yaml`
```yaml
winzou_state_machine:
sylius_payment:
callbacks:
after:
sylius_order_items_complete_collector:
on: 'complete'
do: ['@metrics.order_collector', 'incrementPrometheusCounters']
args: ["object.getOrder()"]
```## Installation without Symfony Flex
1. Run `$ composer require acseo/sylius-prometheus-metrics-plugin`.
2. Enable the plugin in bundles.php
```php
['all' => true],
Acseo\SyliusPrometheusMetricsPlugin\SyliusPrometheusMetricsPlugin::class => ['all' => true],
];
```3. Add this file `config/packages/prometheus_metrics.yaml`
```yaml
artprima_prometheus_metrics:
namespace: myapp
storage: '%env(PROM_METRICS_DSN)%'ignored_routes:
- prometheus_bundle_prometheus
- _wdt# used to disable default application metrics
#disable_default_metrics: false# Recommended to disable default metrics from promphp/prometheus_client_php
# see https://github.com/PromPHP/prometheus_client_php/issues/62
disable_default_promphp_metrics: true# used to enable console metrics
#enable_console_metrics: falsewhen@test:
artprima_prometheus_metrics:
storage: in_memory
```4. Add the metrics routes `config/routes/metrics.yaml`
```yaml
app_metrics:
resource: '@ArtprimaPrometheusMetricsBundle/Resources/config/routing.xml'
```5. Add environment variables
```
###> artprima/prometheus-metrics-bundle ###
PROM_METRICS_DSN=apcu
###< artprima/prometheus-metrics-bundle ###
```