{"id":16818510,"url":"https://github.com/loshz/metrics_server","last_synced_at":"2025-03-22T03:31:28.701Z","repository":{"id":42128752,"uuid":"457231625","full_name":"loshz/metrics_server","owner":"loshz","description":"A hassle-free, single-responsibility, safe HTTP/S server used to easily expose metrics in your application.","archived":false,"fork":false,"pushed_at":"2024-05-29T23:43:42.000Z","size":98,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-15T15:15:04.537Z","etag":null,"topics":["http","https","metrics","rust","server"],"latest_commit_sha":null,"homepage":"https://docs.rs/metrics_server","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loshz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-09T06:10:32.000Z","updated_at":"2024-05-29T23:42:05.000Z","dependencies_parsed_at":"2024-05-22T20:26:17.714Z","dependency_job_id":"3a39baf4-baed-464c-9528-7f2c942b0b17","html_url":"https://github.com/loshz/metrics_server","commit_stats":{"total_commits":63,"total_committers":1,"mean_commits":63.0,"dds":0.0,"last_synced_commit":"b50ed3013ff8b55cc1a1d014cfda65a8ef18866e"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loshz%2Fmetrics_server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loshz%2Fmetrics_server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loshz%2Fmetrics_server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loshz%2Fmetrics_server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loshz","download_url":"https://codeload.github.com/loshz/metrics_server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902929,"owners_count":20529114,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","https","metrics","rust","server"],"created_at":"2024-10-13T10:50:18.027Z","updated_at":"2025-03-22T03:31:28.229Z","avatar_url":"https://github.com/loshz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metrics_server\n[![CI](https://github.com/loshz/metrics_server/actions/workflows/ci.yml/badge.svg)](https://github.com/loshz/metrics_server/actions/workflows/ci.yml)\n[![Version](https://img.shields.io/crates/v/metrics_server.svg)](https://crates.io/crates/metrics_server)\n[![Docs](https://docs.rs/metrics_server/badge.svg)](https://docs.rs/metrics_server)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/loshz/metrics_server/blob/main/LICENSE)\n\n\u003e**Note**: This lib's API should _**NOT**_ currently be considered stable - it might change before v1.\n\nA hassle-free, single-responsibility, safe HTTP/S server used to easily expose metrics in an application.\n\nThis crate provides a thread safe, minimalstic HTTP/S server used to buffer metrics and serve them via a standard `/metrics` endpoint. It's aim is to remove the boilerplate needed to create such simple mechanisms. It is currently somewhat oppinionated and naive in order to maintain little complexity.\n\n\n## Usage\n\nInclude the lib in your `Cargo.toml` dependencies:\n```toml\n[dependencies]\nmetrics_server = \"0.15\"\n```\n\nTo enable TLS support, pass the optional feature flag:\n```toml\n[dependencies]\nmetrics_server = { version = \"0.15\", features = [\"tls\"] }\n```\n\n### HTTP\n```rust\nuse metrics_server::MetricsServer;\n\n// Create a new HTTP server and start listening for requests in the background.\nlet server = MetricsServer::http(\"localhost:8001\");\n\n// Publish your application metrics.\nlet bytes = server.update(\"my_awesome_metric = 10\".into());\nassert_eq!(22, bytes);\n\n// Stop the server.\nserver.stop().unwrap();\n```\n\n### HTTPS\nNote: there is currently no option to skip TLS cert verification.\n```rust\nuse metrics_server::MetricsServer;\n\n// Load TLS config.\nlet cert = include_bytes!(\"/path/to/cert.pem\").to_vec();\nlet key = include_bytes!(\"/path/to/key.pem\").to_vec();\n\n// Create a new HTTPS server and start listening for requests in the background.\nlet server = MetricsServer::https(\"localhost:8443\", cert, key);\n\n// Publish your application metrics.\nlet bytes = server.update(\"my_awesome_metric = 10\".into());\nassert_eq!(22, bytes);\n\n// Stop the server.\nserver.stop().unwrap();\n```\n\n### Serve a custom URL\n```rust\nuse metrics_server::MetricsServer;\n\n// Create a new server and specify the URL path to serve.\nlet mut server = MetricsServer::new(\"localhost:8001\", None, None);\nserver.serve_uri(\"/path/to/metrics\");\n\n// Publish your application metrics.\nlet bytes = server.update(\"my_awesome_metric = 10\".into());\nassert_eq!(22, bytes);\n\n// Stop the server.\nserver.stop().unwrap();\n```\n\nFor more comprehensive usage, see the included [examples](./examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floshz%2Fmetrics_server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floshz%2Fmetrics_server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floshz%2Fmetrics_server/lists"}