code: def middlewares(self) -> list[Middleware]:
      middlewares = super().middlewares
  
      from opentelemetry.instrumentation.asgi import (
          OpenTelemetryMiddleware,
      )
      from starlette.middleware import Middleware
  
      def client_request_hook(
          span: Span | None, _scope: t.Dict[str, t.Any]
      ) -> None:
          if span is not None:
              trace_context.request_id = span.context.span_id
  
      middlewares.append(
          Middleware(
              OpenTelemetryMiddleware,
              excluded_urls=BentoMLContainer.tracing_excluded_urls.get(),
              default_span_details=None,
              server_request_hook=None,
              client_request_hook=client_request_hook,
              tracer_provider=BentoMLContainer.tracer_provider.get(),
          )
      )
  
      if self.enable_metrics:
          from .http.instruments import RunnerTrafficMetricsMiddleware
  
          middlewares.append(Middleware(RunnerTrafficMetricsMiddleware))
  
      access_log_config = BentoMLContainer.runners_config.logging.access
      if access_log_config.enabled.get():
          from .http.access import AccessLogMiddleware
  
          access_logger = logging.getLogger("bentoml.access")
          if access_logger.getEffectiveLevel() <= logging.INFO:
              middlewares.append(
                  Middleware(
                      AccessLogMiddleware,
                      has_request_content_length=access_log_config.request_content_length.get(),
                      has_request_content_type=access_log_config.request_content_type.get(),
                      has_response_content_length=access_log_config.response_content_length.get(),
                      has_response_content_type=access_log_config.response_content_type.get(),
                  )
              )
  
      return middlewares
  
imports: from __future__ import annotations
  import functools
  import json
  import logging
  import pickle
  import traceback
  import typing
  from typing import TYPE_CHECKING
  from simple_di import Provide
  from simple_di import inject
  from bentoml.exceptions import BentoMLException
  from bentoml.exceptions import ServiceUnavailable
  from ..configuration.containers import BentoMLContainer
  from ..context import component_context
  from ..context import trace_context
  from ..marshal.dispatcher import CorkDispatcher
  from ..runner.container import AutoContainer
  from ..runner.container import Payload
  from ..runner.utils import PAYLOAD_META_HEADER
  from ..runner.utils import Params
  from ..runner.utils import payload_paramss_to_batch_params
  from ..server.base_app import BaseAppFactory
  from ..types import LazyType
  from ..utils.metrics import exponential_buckets
label_desc: Use image node_id 7 for calling the RunnerAppFactory obj's underlying member method code with example usage: obj.middlewares() and returns: middlewares