<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def execution_timer(value):
 """The ``execution_timer`` decorator allows for easy instrumentation of the duration of function calls, using the method name in the key. The following example would add duration timing with the key ``my_function`` .. code: python @statsd.execution_timer def my_function(foo):
 pass You can also have include a string argument value passed to your method as part of the key. Pass the index offset of the arguments to specify the argument number to use. In the following example, the key would be ``my_function.baz``: .. code:python @statsd.execution_timer(2) def my_function(foo, bar, 'baz'):
 pass """

    def _invoke(method, key_arg_position, *args, **kwargs):
        start_time = time.time()
        result = method(*args, **kwargs)
        duration = time.time() - start_time

        key = [method.func_name]
        if key_arg_position is not None:
            key.append(args[key_arg_position])
        add_timing('.'.join(key), value=duration)
        return result

    if type(value) is types.FunctionType:
        def wrapper(*args, **kwargs):
            return _invoke(value, None, *args, **kwargs)
        return wrapper
    else:
        def duration_decorator(func):
            def wrapper(*args, **kwargs):
                return _invoke(func, value, *args, **kwargs)
            return wrapper
        return duration_decorator