-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Prometheus support to Tabby. (#838)
* Added Prometheus support to Tabby. 1) Added `axum-prometheus` to Cargo.toml 2) Added `metrics.rs` as a simple route to produce a metrics endpoint with prometheus-formatted events 3) Added `/v1/metrics` endpoint with API doc entry 4) Added the `PrometheusLayer` to the root layers. This change effectively allows for external Prometheus to scrape metrics from Tabby during execution in order to monitor operations (resources, timings and overall usage). * changed application/text to text/plain to adhere to rfc1341 * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * Update Makefile * - Reworked code to fit upstream changes - Added Prometheus layer and handle to worker.rs * Update CHANGELOG.md * [autofix.ci] apply automated fixes * Simplified worker metrics route definition * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: Meng Zhang <meng@tabbyml.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
7dbbfc3
commit 6dabecc
Showing
8 changed files
with
169 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::sync::Arc; | ||
|
||
use axum::extract::State; | ||
use axum_prometheus::metrics_exporter_prometheus::PrometheusHandle; | ||
|
||
#[utoipa::path( | ||
get, | ||
path = "/v1/metrics", | ||
tag = "v1", | ||
responses( | ||
(status = 200, description = "Success", body = String, content_type = "text/plain"), | ||
) | ||
)] | ||
pub async fn metrics(State(state): State<Arc<PrometheusHandle>>) -> String { | ||
state.render() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters