class_docstr: Reports telemetry for improving product experience.
class_docstr_tok: ["Reports","telemetry","for","improving","product","experience","."]
docstr: Similar to log_function_end, except adding the duration of the call and exception trace on error.
docstr_tok: ["Similar","to","log_function_end",",","except","adding","the","duration","of","the","call","and","exception","trace","on","error","."]
code: def log_function_end(  # noqa: D
      self,
      invocation_id: str,
      module_name: str,
      function_name: str,
      runtime: float,
      exception_trace: Optional[str],
  ) -> None:
      """Similar to log_function_end, except adding the duration of the call and exception trace on error."""
      if (
          TelemetryLevel.USAGE >= self._report_levels_higher_or_equal_to
          or (
              exception_trace
              and TelemetryLevel.EXCEPTION
              >= self._report_levels_higher_or_equal_to
          )
      ):
          for handler in self._handlers:
              handler.log(
                  client_id=self._client_id,
                  function_end_event=FunctionEndEvent.create(
                      event_time=datetime.datetime.now(),
                      level_name=TelemetryLevel.USAGE.name
                      if not exception_trace
                      else TelemetryLevel.EXCEPTION.name,
                      invocation_id=invocation_id,
                      module_name=module_name,
                      function_name=function_name,
                      runtime=runtime,
                      exception_trace=exception_trace,
                  ),
              )
  
imports: from __future__ import annotations
  import datetime
  import functools
  import logging
  import os
  import platform
  import sys
  import time
  import traceback
  import uuid
  from hashlib import sha256
  from typing import Callable, List, Optional, TypeVar
  from typing_extensions import ParamSpec
  from metricflow.random_id import random_id
  from metricflow.telemetry.handlers.handlers import TelemetryHandler, ToMemoryTelemetryHandler
  from metricflow.telemetry.handlers.python_log import PythonLoggerTelemetryHandler
  from metricflow.telemetry.models import FunctionEndEvent, FunctionStartEvent, TelemetryLevel
label_desc: Use image node_id 7 for calling the TelemetryReporter obj's underlying member method code with example usage: obj.log_function_end(invocation_id, module_name, function_name, runtime, exception_trace) without return types