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

configuration: migrate schema to api_server #3046

Merged
merged 1 commit into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 5 additions & 7 deletions bentoml/_internal/configuration/containers.py
Expand Up @@ -139,6 +139,10 @@ def _is_ip_address(addr: str) -> bool:
"request_content_type": Or(bool, None),
"response_content_length": Or(bool, None),
"response_content_type": Or(bool, None),
"format": {
"trace_id": str,
"span_id": str,
},
},
},
"http": {
Expand Down Expand Up @@ -198,12 +202,6 @@ def _is_ip_address(addr: str) -> bool:
},
},
},
"logging": {
"formatting": {
"trace_id_format": str,
"span_id_format": str,
}
},
}
)

Expand Down Expand Up @@ -607,7 +605,7 @@ def duration_buckets(
@providers.SingletonFactory
@staticmethod
def logging_formatting(
cfg: dict[str, t.Any] = Provide[config.logging.formatting],
cfg: dict[str, t.Any] = Provide[api_server_config.logging.access.format],
) -> dict[str, str]:
return cfg

Expand Down
9 changes: 4 additions & 5 deletions bentoml/_internal/configuration/default_configuration.yaml
Expand Up @@ -12,6 +12,10 @@ api_server:
request_content_type: true
response_content_length: true
response_content_type: true
format:
trace_id: 032x
span_id: 016x

http:
host: 0.0.0.0
port: 3000
Expand Down Expand Up @@ -65,8 +69,3 @@ tracing:
otlp:
protocol: ~
url: ~

logging:
formatting:
trace_id_format: 032x
span_id_format: 016x
4 changes: 2 additions & 2 deletions bentoml/_internal/log.py
Expand Up @@ -119,8 +119,8 @@ def trace_record_factory(*args: t.Any, **kwargs: t.Any):
from .configuration.containers import BentoMLContainer

logging_formatting = BentoMLContainer.logging_formatting.get()
trace_id_format = logging_formatting["trace_id_format"]
span_id_format = logging_formatting["span_id_format"]
trace_id_format = logging_formatting["trace_id"]
span_id_format = logging_formatting["span_id"]

trace_id = format(trace_id, trace_id_format)
span_id = format(trace_context.span_id, span_id_format)
Expand Down
21 changes: 12 additions & 9 deletions docs/source/guides/logging.rst
Expand Up @@ -98,19 +98,22 @@ The available configuration options are identical to the webserver request loggi
These logs are disabled by default in order to prevent double logging of requests.


Logging Formatting
""""""""""""""""""
Access Logging Format
"""""""""""""""""""""

You may configure the logging formatting options at the top level of your ``bentoml_configuration.yml``.
The default configuration is shown below, where the opentelemetry trace_id and span_id are logged in
hexadecimal format, consistent with opentelemetry logging instrumentation.
You may configure the format of the Trace and Span IDs in the access logs in ``bentoml_configuration.yml``.
The default configuration is shown below, where the opentelemetry ``trace_id`` and ``span_id`` are logged in
hexadecimal format, consistent with opentelemetry logging instrumentation. You may also configure other format
specs, such as decimal ``d``.

.. code-block:: yaml

logging:
formatting:
trace_id_format: 032x
span_id_format: 016x
api_server:
logging:
access:
format:
trace_id: 032x
span_id: 016x


Library Logging
Expand Down