Skip to content

Introduce start_span, stop_span #132

@rlipscombe

Description

@rlipscombe

I want to report a span that, er, spans over an asynchronous call to a gen_statem, using gen_statem:send_request() and gen_statem:check_response().

It would be useful if there were telemetry:start_span() and telemetry:stop_span() functions for this use case.

An example without gen_statem might make this clearer:

Span = telemetry:start_span([worker, processing], StartMetadata),
Parent = self(),
{MRef, Pid} = spawn_monitor(fun() -> Result = do_some_work(), Parent ! {reply, Result} end),
receive
    {reply, Result} ->
        telemetry:stop_span([worker, processing], Span);
    {'DOWN', Ref, process, Pid, Error} when Error /= normal ->
        telemetry:error_span([worker, processing], Span)
end.

...something like that, anyway.

Maybe the EventPrefix ought to be stashed in the span, to avoid repetition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions