Skip to content

Commit

Permalink
fix: Cannot define custom duration histogram buckets via `@bentoml.se…
Browse files Browse the repository at this point in the history
…rvice(metrics=...)` (#4895)

Fixes #4859

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Aug 2, 2024
1 parent 1764c69 commit 51468b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/_bentoml_sdk/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class APIMethod(t.Generic[P, R]):
batch_dim: tuple[int, int] = attrs.field(
default=(0, 0), converter=lambda x: (x, x) if not isinstance(x, tuple) else x
)
max_batch_size: int = 100
max_batch_size: int = attrs.field(default=100, validator=attrs.validators.gt(1))
max_latency_ms: int = 60000
is_stream: bool = attrs.field(init=False)
doc: str | None = attrs.field(init=False)
Expand Down
4 changes: 4 additions & 0 deletions src/bentoml/_internal/server/http/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def __init__(
def _setup(
self,
metrics_client: "PrometheusClient" = Provide[BentoMLContainer.metrics_client],
duration_buckets: tuple[float, ...] = Provide[
BentoMLContainer.duration_buckets
],
):
self.metrics_client = metrics_client

Expand All @@ -164,6 +167,7 @@ def _setup(
"http_response_code",
"runner_name",
],
buckets=duration_buckets,
)
self.metrics_request_total = metrics_client.Counter(
namespace=self.namespace,
Expand Down

0 comments on commit 51468b6

Please sign in to comment.