-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simple prometheus asgi optional integration (experimental, will…
… change)
- Loading branch information
Showing
6 changed files
with
104 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Prometheus | ||
========== | ||
|
||
.. warning:: | ||
|
||
This feature is mostly for internal use for now, and although we'll keep a prometheus integration in the future, | ||
configuration will change. | ||
|
||
Enable the middleware using ... | ||
|
||
.. code-block:: bash | ||
USE_ASGI_PROMETHEUS_MIDDLEWARE=true harp ... | ||
Then you can access the metrics at ``/.prometheus/metrics``. | ||
|
||
Here is an example scrape configuration for prometheus: | ||
|
||
.. code-block:: yaml | ||
scrape_configs: | ||
- job_name: harp | ||
honor_timestamps: true | ||
scrape_interval: 10s | ||
scrape_timeout: 10s | ||
metrics_path: /.prometheus/metrics | ||
scheme: http | ||
static_configs: | ||
- targets: | ||
- url.or.ip.for.harp.example.com:4080 |
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,28 @@ | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
|
||
from harp.utils.env import cast_bool, get_bool_from_env | ||
|
||
parametrize_with_string_booleans = pytest.mark.parametrize( | ||
"value, expected", | ||
[ | ||
("true", True), | ||
("yes", True), | ||
("1", True), | ||
("false", False), | ||
("no", False), | ||
("0", False), | ||
], | ||
) | ||
|
||
|
||
@parametrize_with_string_booleans | ||
def test_cast_bool(value, expected): | ||
assert cast_bool(value) == expected | ||
|
||
|
||
@parametrize_with_string_booleans | ||
def test_get_bool_from_env(value, expected): | ||
with patch.dict("os.environ", {"TEST_ENV_VAR": value}): | ||
assert get_bool_from_env("TEST_ENV_VAR", False) == expected |
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