Пример #1
0
def traced(name, trace_id=None, parent_id=None):
    '''
    Function decorator to wrap an entire function in a trace span. If no trace
    is active in the current thread, starts a new trace, and the wrapping span
    will be a root span. If a trace is active, creates a child span of the
    existing trace.

    Example use:

    ```
    @traced(name="my_expensive_function")
    def my_func(n):
        recursive_fib(n)

    my_func(100)
    ```

    Args:
    - `name`: a descriptive name for the this trace span, i.e. "function_name". This is required.
    - `trace_id`: the trace_id to use. If None, will be automatically generated.
        Use this if you want to explicitly resume a trace in this application that was
        initiated in another application, and you have the upstream trace_id.
    - `parent_id`: If trace_id is set, will populate the root span's parent
        with this id.
    '''

    return traced_impl(tracer_fn=tracer,
                       name=name,
                       trace_id=trace_id,
                       parent_id=parent_id)
Пример #2
0
 def traced(self, name, trace_id=None, parent_id=None):
     return traced_impl(tracer_fn=self.tracer,
                        name=name,
                        trace_id=trace_id,
                        parent_id=parent_id)