Skip to content

Commit

Permalink
chore: Update access log format configuration schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
ssheng committed Sep 27, 2022
1 parent 76ade96 commit 208ce99
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
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

0 comments on commit 208ce99

Please sign in to comment.