Tinkex.Telemetry.Reporter.Events (Tinkex v0.3.4)

View Source

Event building for different telemetry event types.

Responsible for constructing typed event structs (GenericEvent, SessionStartEvent, SessionEndEvent, UnhandledExceptionEvent) with proper indexing and timestamps.

Summary

Functions

Build an exception event (either user error or unhandled exception).

Build a generic telemetry event.

Build a session end event with duration.

Build a session start event.

Build an unhandled exception event.

Build a user error event (as a generic event with warning severity).

Enqueue a session start event.

Maybe enqueue a session end event if not already enqueued.

Determine severity for a telemetry event based on event name.

Functions

build_exception_event(state, exception, severity)

@spec build_exception_event(map(), Exception.t(), atom()) :: {term(), map()}

Build an exception event (either user error or unhandled exception).

Delegates to ExceptionHandler to determine the exception type and builds the appropriate event.

Returns {event, updated_state} where session_index has been incremented.

build_generic_event(state, name, data, severity)

@spec build_generic_event(map(), String.t(), map(), atom()) ::
  {Tinkex.Types.Telemetry.GenericEvent.t(), map()}

Build a generic telemetry event.

Returns {event, updated_state} where session_index has been incremented.

build_session_end_event(state)

@spec build_session_end_event(map()) ::
  {Tinkex.Types.Telemetry.SessionEndEvent.t(), map()}

Build a session end event with duration.

Returns {event, updated_state} where session_index has been incremented.

build_session_start_event(state)

@spec build_session_start_event(map()) ::
  {Tinkex.Types.Telemetry.SessionStartEvent.t(), map()}

Build a session start event.

Returns {event, updated_state} where session_index has been incremented.

build_unhandled_exception(state, exception, severity)

@spec build_unhandled_exception(map(), Exception.t(), atom()) ::
  {Tinkex.Types.Telemetry.UnhandledExceptionEvent.t(), map()}

Build an unhandled exception event.

Returns {event, updated_state} where session_index has been incremented.

build_user_error_event(state, exception)

@spec build_user_error_event(map(), Exception.t()) ::
  {Tinkex.Types.Telemetry.GenericEvent.t(), map()}

Build a user error event (as a generic event with warning severity).

Returns {event, updated_state} where session_index has been incremented.

enqueue_session_start(state)

@spec enqueue_session_start(map()) :: {map(), boolean()}

Enqueue a session start event.

Returns {updated_state, accepted?}.

maybe_enqueue_session_end(state)

@spec maybe_enqueue_session_end(map()) :: map()

Maybe enqueue a session end event if not already enqueued.

Returns updated_state.

severity_for_event(arg1)

@spec severity_for_event(list()) :: atom()

Determine severity for a telemetry event based on event name.