code: def trace_record_factory(*args: t.Any, **kwargs: t.Any):
      record = default_factory(*args, **kwargs)
      if record.name in (
          "bentoml_monitor_data",
          "bentoml_monitor_schema",
      ):
          return record
      record.levelname_bracketed = f"[{record.levelname}]"
      record.component = f"[{_component_name()}]"
      trace_id = trace_context.trace_id
      if trace_id in (0, None):
          record.trace_msg = ""
      else:
          from .configuration.containers import BentoMLContainer
  
          logging_formatting = BentoMLContainer.logging_formatting.get()
          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)
          record.trace_msg = f" (trace={trace_id},span={span_id},sampled={trace_context.sampled},service.name={trace_context.service_name})"
      record.request_id = trace_context.request_id
      record.service_name = trace_context.service_name
  
      return record
  
file_path: BentoML/src/bentoml/_internal/log.py
imports: from __future__ import annotations
  import logging
  import logging.config
  import typing
  from functools import lru_cache
  from .configuration import get_debug_mode
  from .configuration import get_quiet_mode
  from .context import component_context
  from .context import trace_context
label_desc: Use image node_id 3 for calling a global function with example usage: trace_record_factory() and returns: record, record