Normandy.Telemetry.Span
(normandy v2.2.0)
View Source
:telemetry.span/3 for Normandy's own spans, except that the :exception
event's stacktrace is always [].
A stacktrace can hold call arguments (prompts, tool input, credentials), so it is logged by the code that rescues the failure and never emitted in telemetry. The raise itself keeps its original stacktrace.
The :exception reason is redacted the same way (exception_metadata/3): an
exception that is not one of Normandy's own (a bug) is emitted as
%Normandy.TurnError{reason: %{exception: module}}, since its fields and message can
hold the value it failed on. The raise itself is unchanged.
Events, measurements and metadata are otherwise those of :telemetry.span/3:
:start and :stop (and :exception with kind, reason on top of the start
metadata), all sharing a telemetry_span_context.
Summary
Functions
Runs fun as the span event_prefix. fun returns {result, stop_metadata} or
{result, extra_measurements, stop_metadata}; result is returned.
Like span/3, for a fun that returns the call's result as is and a function
that says how the span ends: outcome maps the result to {:ok, stop_metadata}
(the :stop event carries exactly that metadata, plus the span context) or
{:error, %Normandy.LLMError{}}, which ends the span in :exception without
raising: the result is still returned. A raise, exit or throw inside fun is an
:exception too, and is re-raised.
Types
@type event_prefix() :: [atom()]
Functions
@spec span( event_prefix(), map(), (-> {result, map()} | {result, map(), map()}) ) :: result when result: term()
Runs fun as the span event_prefix. fun returns {result, stop_metadata} or
{result, extra_measurements, stop_metadata}; result is returned.
@spec span(event_prefix(), map(), (-> result), (result -> {:ok, map()} | {:error, Normandy.LLMError.t()})) :: result when result: term()
Like span/3, for a fun that returns the call's result as is and a function
that says how the span ends: outcome maps the result to {:ok, stop_metadata}
(the :stop event carries exactly that metadata, plus the span context) or
{:error, %Normandy.LLMError{}}, which ends the span in :exception without
raising: the result is still returned. A raise, exit or throw inside fun is an
:exception too, and is re-raised.