code: def test_extra_field(serve_and_ray_shutdown, raise_error):
      """Test ray serve extra logging"""
      logger = logging.getLogger("ray.serve")
  
      @serve.deployment(logging_config={"encoding": "JSON"})
      def fn(*args):
          if raise_error:
              logger.info(
                  "user_func", extra={SERVE_LOG_EXTRA_FIELDS: [123]}
              )
          else:
              logger.info(
                  "user_func",
                  extra={
                      "k1": "my_v1",
                      SERVE_LOG_EXTRA_FIELDS: {"k2": "my_v2"},
                  },
              )
          return {
              "log_file": logger.handlers[1].baseFilename,
          }
  
      serve.run(fn.bind(), name="app1", route_prefix="/fn")
      resp = requests.get("http://127.0.0.1:8000/fn")
      if raise_error:
          resp.status_code == 500
      else:
          resp = resp.json()
          with open(resp["log_file"], "r") as f:
              s = f.read()
              assert re.findall(".*my_v1.*", s) == []
              assert re.findall('.*"k2": "my_v2".*', s) != []
  
imports: import io
  import json
  import logging
  import os
  import re
  import string
  import sys
  import time
  from contextlib import redirect_stderr
  import pytest
  import requests
  import starlette
  import ray
  import ray.util.state
  from ray import serve
  from ray._private.test_utils import wait_for_condition
  from ray.serve._private.common import ServeComponentType
  from ray.serve._private.constants import SERVE_LOG_EXTRA_FIELDS
  from ray.serve._private.logging_utils import ServeJSONFormatter, get_component_log_file_name, get_serve_logs_dir
label_desc: Use image node_id 10 for calling a global function with example usage: test_extra_field(serve_and_ray_shutdown, raise_error) and returns: dict