def log_scope(self, stream_name, properties={}, log_scope_stack_trace=False,
                log_exception_stack_trace=False, namespace=None):
    """
    Identical to `log_function` except that `log_scope` is used to log blocks
    of code. The API is identical except that keys in `properties` are mapped to
    real values rather than getter functions. Usage:

      with kronos_client.log_scope('mystreamname', properties={ 'lol':'cat' },
                                   log_scope_stack_trace=True):
        <some code here>
    """
    start_time = time.time()
    namespace = namespace or self.namespace
    event = properties.copy()
    if log_scope_stack_trace:
      event['stack_trace'] = traceback.extract_stack()
    try:
      yield event
    except Exception, exception:
      self._log_exception(event, exception,
                          (sys.last_traceback if log_exception_stack_trace
                           else None))
    event['duration'] = time.time() - start_time
    self.put({stream_name: [event]}, namespace=namespace)