Skip to content

Commit

Permalink
feat: add support for specifying urls to exclude from tracing as a li…
Browse files Browse the repository at this point in the history
…st (#2851)

Signed-off-by: Aaron Pham <29749331+aarnphm@users.noreply.github.com>
  • Loading branch information
jiewpeng authored and aarnphm committed Aug 3, 2022
1 parent f01e930 commit 8f682bf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bentoml/_internal/configuration/containers.py
Expand Up @@ -120,7 +120,7 @@ def _is_ip_address(addr: str) -> bool:
"tracing": {
"type": Or(And(str, Use(str.lower), _check_tracing_type), None),
"sample_rate": Or(And(float, lambda i: i >= 0 and i <= 1), None),
"excluded_urls": Or(str, None),
"excluded_urls": Or([str], str, None),
Optional("zipkin"): {"url": Or(str, None)},
Optional("jaeger"): {"address": Or(str, None), "port": Or(int, None)},
},
Expand Down Expand Up @@ -417,11 +417,17 @@ def tracer_provider(
@providers.SingletonFactory
@staticmethod
def tracing_excluded_urls(
excluded_urls: t.Optional[str] = Provide[config.tracing.excluded_urls],
excluded_urls: t.Optional[t.Union[str, t.List[str]]] = Provide[
config.tracing.excluded_urls
],
):
from opentelemetry.util.http import ExcludeList
from opentelemetry.util.http import parse_excluded_urls

return parse_excluded_urls(excluded_urls)
if isinstance(excluded_urls, list):
return ExcludeList(excluded_urls)
else:
return parse_excluded_urls(excluded_urls)

# Mapping from runner name to RunnerApp file descriptor
remote_runner_mapping = providers.Static[t.Dict[str, str]]({})
Expand Down
13 changes: 13 additions & 0 deletions docs/source/guides/tracing.rst
Expand Up @@ -39,6 +39,19 @@ Here is another example config file for tracing with Jaeger and opentracing:
address: localhost
port: 6831
If you would like to exclude some routes from tracing, you can specify them using
the :code:`excluded_urls` parameter. This parameter can be either a comma-separated
string of routes, or a list of strings.

.. code-block:: yaml
tracing:
type: jaeger
jaeger:
address: localhost
port: 6831
excluded_urls: readyz,livez,healthz,static_content,docs,metrics
When starting a BentoML API model server, provide the path to this config file via the
CLI argument `--config`:
Expand Down

0 comments on commit 8f682bf

Please sign in to comment.