diff --git a/docs/PHP/danog/MadelineProto/Settings/Prometheus.md b/docs/PHP/danog/MadelineProto/Settings/Prometheus.md index d587d3fa04..63ad350850 100644 --- a/docs/PHP/danog/MadelineProto/Settings/Prometheus.md +++ b/docs/PHP/danog/MadelineProto/Settings/Prometheus.md @@ -17,15 +17,17 @@ Prometheus settings. ## Method list: -* [`setEnablePrometheus(bool $enable): self`](#setEnablePrometheus) -* [`getEnablePrometheus(): bool`](#getEnablePrometheus) -* [`setPrometheusEndpoint(?\Amp\Socket\SocketAddress $endpoint): self`](#setPrometheusEndpoint) -* [`getPrometheusEndpoint(): ?\Amp\Socket\SocketAddress`](#getPrometheusEndpoint) +* [`setReturnMetricsFromStartAndLoop(bool $enable): self`](#setReturnMetricsFromStartAndLoop) +* [`getReturnMetricsFromStartAndLoop(): bool`](#getReturnMetricsFromStartAndLoop) +* [`setEnableCollection(bool $enable): self`](#setEnableCollection) +* [`getEnableCollection(): bool`](#getEnableCollection) +* [`setMetricsBindTo(?\Amp\Socket\SocketAddress $metricsBindTo): self`](#setMetricsBindTo) +* [`getMetricsBindTo(): ?\Amp\Socket\SocketAddress`](#getMetricsBindTo) ## Methods: -### `setEnablePrometheus(bool $enable): self` +### `setReturnMetricsFromStartAndLoop(bool $enable): self` -Whether to enable additional prometheus stat reporting for this session. +Whether to expose prometheus metrics with startAndLoop, by providing a ?metrics query string. Parameters: @@ -34,20 +36,37 @@ Parameters: -### `getEnablePrometheus(): bool` +### `getReturnMetricsFromStartAndLoop(): bool` -Whether additional prometheus stat reporting is enabled for this session. +Whether to expose prometheus metrics with startAndLoop, by providing a ?metrics query string. -### `setPrometheusEndpoint(?\Amp\Socket\SocketAddress $endpoint): self` +### `setEnableCollection(bool $enable): self` + +Whether to enable additional prometheus stat collection for this session. + + +Parameters: + +* `$enable`: `bool` + + + +### `getEnableCollection(): bool` + +Whether additional prometheus stat collection is enabled for this session. + + + +### `setMetricsBindTo(?\Amp\Socket\SocketAddress $metricsBindTo): self` Whether to expose prometheus metrics on the specified endpoint via HTTP. Parameters: -* `$endpoint`: `?\Amp\Socket\SocketAddress` +* `$metricsBindTo`: `?\Amp\Socket\SocketAddress` #### See also: @@ -56,7 +75,7 @@ Parameters: -### `getPrometheusEndpoint(): ?\Amp\Socket\SocketAddress` +### `getMetricsBindTo(): ?\Amp\Socket\SocketAddress` Whether to expose prometheus metrics on the specified endpoint via HTTP. diff --git a/docs/docs/UPDATES.md b/docs/docs/UPDATES.md index d1d913b9c3..bccfa5886c 100644 --- a/docs/docs/UPDATES.md +++ b/docs/docs/UPDATES.md @@ -163,6 +163,8 @@ use danog\MadelineProto\Settings\Database\Redis; use danog\MadelineProto\SimpleEventHandler; use danog\MadelineProto\VoIP; +use function Amp\Socket\SocketAddress\fromString; + // MadelineProto is already loaded if (class_exists(API::class)) { // Otherwise, if a stable version of MadelineProto was installed via composer, load composer autoloader @@ -428,6 +430,15 @@ $settings->getLogger()->setLevel(Logger::LEVEL_ULTRA_VERBOSE); // $settings->setDb((new Postgres)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony')); // $settings->setDb((new Mysql)->setDatabase('MadelineProto')->setUsername('daniil')->setPassword('pony')); +// You can also enable collection of prometheus metrics. +// $settings->getPrometheus()->setEnableCollection(true); + +// Metrics can be returned by an autoconfigured http://127.0.0.1:12345 HTTP server. +// $settings->getPrometheus()->setMetricsBindTo(fromString("127.0.0.1:12345")); + +// Metrics can also be returned by the current script via web, if called with a ?metrics query string +// $settings->getPrometheus()->setReturnMetricsFromStartAndLoop(true); + // For users or bots MyEventHandler::startAndLoop('bot.madeline', $settings);