Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(prometheus): ensure metrics are lazily loaded #3089

Merged
merged 18 commits into from Oct 28, 2022
Merged
1 change: 1 addition & 0 deletions docs/source/conf.py
Expand Up @@ -167,5 +167,6 @@
"transformers.file_utils",
"xgboost",
"catboost",
"prometheus_client",
"bentoml._internal.models.model.ModelSignatureDict",
]
6 changes: 3 additions & 3 deletions docs/source/guides/metrics.rst
Expand Up @@ -9,7 +9,7 @@ BentoML allows users to define custom metrics with `Prometheus <https://promethe
This article will dive into how to add custom metrics to monitor your BentoService and how you can incorporate custom metrics into
either a :ref:`concepts/runner:Custom Runner` or your :ref:`Service <concepts/service:Service and APIs>`.

Having a `Prometheus server <https://prometheus.io/docs/prometheus/latest/getting_started/>` available will help visualize the examples in this guide.
Having a `Prometheus server <https://prometheus.io/docs/prometheus/latest/getting_started/>`_ available will help visualize the examples in this guide.

.. note::

Expand All @@ -18,11 +18,11 @@ Having a `Prometheus server <https://prometheus.io/docs/prometheus/latest/gettin

.. seealso::

All `metrics types <https://prometheus.io/docs/concepts/metric_types/>`_ supported by Prometheus are supported in BentoML. See :ref:`Metrics API <reference/metrics:Metrics API>` for more information on ``bentoml.metrics``.
All `metrics types <https://prometheus.io/docs/concepts/metric_types/>`_ supported by Prometheus are supported in BentoML. See :ref:`reference/metrics:Metrics API` for more information on ``bentoml.metrics``.


Using Metrics in a BentoService
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We will build a custom histogram to track the latency of our :ref:`pretrained NLTK runner <concepts/runner:Custom Runner>`, a custom
counter to measure the total amount of time our endpoint is invoked.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/metrics.rst
Expand Up @@ -68,7 +68,7 @@ ensure `multiprocessing mode <https://github.com/prometheus/client_python#multip
The following section will go over the most commonly used metrics API in
``bentoml.metrics``:

.. currentmodule:: bentoml._internal.server.metrics
.. currentmodule:: bentoml.metrics

.. autofunction:: bentoml.metrics.generate_latest

Expand Down
4 changes: 3 additions & 1 deletion requirements/tests-requirements.txt
Expand Up @@ -17,4 +17,6 @@ imageio==2.22.1
pyarrow==9.0.0
build[virtualenv]==0.8.0
protobuf==3.19.6
grpcio-tools>=1.41.0,<1.49.0,!=1.48.2
grpcio>=1.41.0, <1.49, !=1.48.2
grpcio-health-checking>=1.41.0, <1.49, !=1.48.2
opentelemetry-instrumentation-grpc==0.34b0
2 changes: 2 additions & 0 deletions src/bentoml/_internal/runner/runner_handle/remote.py
Expand Up @@ -138,6 +138,8 @@ async def async_run_method(
*args: P.args,
**kwargs: P.kwargs,
) -> R | tuple[R, ...]:
import aiohttp

from ...runner.container import AutoContainer

inp_batch_dim = __bentoml_method.config.batch_dim[0]
Expand Down