def annotate_mapper(**decargs):
    """Add input and output watermarks to processed events."""
    def decorator(func):
        """Annotate events with entry and/or exit timestamps."""
        def wrapper(event, *args, **kwargs):
            """Add enter and exit annotations to the processed event."""
            funcname = ":".join([func.__module__, func.__name__])
            enter_ts = time.time()
            out = func(event, *args, **kwargs)
            enter_key = funcname + "|enter"
            out = annotate_event(out, enter_key, ts=enter_ts, **decargs)
            exit_key = funcname + "|exit"
            out = annotate_event(out, exit_key, ts=time.time(), **decargs)
            return out

        return wrapper
    return decorator
def annotate_mapper ( ** decargs ) : def decorator ( func ) : def wrapper ( event , * args , ** kwargs ) : funcname = ":" . join ( [ func . __module__ , func . __name__ ] ) enter_ts = time . time ( ) out = func ( event , * args , ** kwargs ) enter_key = funcname + "|enter" out = annotate_event ( out , enter_key , ts = enter_ts , ** decargs ) exit_key = funcname + "|exit" out = annotate_event ( out , exit_key , ts = time . time ( ) , ** decargs ) return out return wrapper return decorator
Add input and output watermarks to processed events.