SnakeBridge.Telemetry (SnakeBridge v0.11.0)

View Source

Telemetry event definitions for SnakeBridge.

This module provides instrumentation for compile-time operations including:

  • Source scanning
  • Python introspection
  • Code generation
  • Lock file verification

Event List

EventMeasurementsMetadata
[:snakebridge, :compile, :start]system_timelibraries, strict
[:snakebridge, :compile, :stop]duration, symbols_generated, files_writtenlibraries, mode
[:snakebridge, :compile, :exception]durationreason, stacktrace
[:snakebridge, :compile, :scan, :stop]duration, files_scanned, symbols_foundlibrary, phase, details
[:snakebridge, :compile, :introspect, :start]system_timelibrary, phase, details
[:snakebridge, :compile, :introspect, :stop]duration, symbols_introspected, cache_hitslibrary, phase, details
[:snakebridge, :compile, :generate, :stop]duration, bytes_written, functions_generated, classes_generatedlibrary, phase, details
[:snakebridge, :docs, :fetch]durationmodule, function, source
[:snakebridge, :lock, :verify]durationresult, warnings
[:snakebridge, :session, :cleanup]system_timesession_id, source, reason

Usage

# Attach handlers in your application
SnakeBridge.Telemetry.Handlers.Logger.attach()

# Compile-time events are automatically emitted during mix compile

Summary

Functions

compile_exception(start_time, reason, stacktrace)

@spec compile_exception(integer(), term(), list()) :: :ok

Emits compile exception event.

Measurements

  • duration - Time in native units

Metadata

  • library - :all
  • phase - :compile
  • details - %{reason: term(), stacktrace: list()}

compile_start(libraries, strict)

@spec compile_start([atom()], boolean()) :: :ok

Emits compile start event.

Measurements

  • system_time - System time when compilation started

Metadata

  • library - :all
  • phase - :compile
  • details - %{libraries: [...], strict: boolean()}

compile_stop(start_time, symbols, files, libraries, mode)

@spec compile_stop(
  integer(),
  non_neg_integer(),
  non_neg_integer(),
  [atom()],
  :normal | :strict
) :: :ok

Emits compile stop event.

Measurements

  • duration - Time in native units
  • symbols_generated - Number of symbols generated
  • files_written - Number of files written

Metadata

  • library - :all
  • phase - :compile
  • details - %{libraries: [...], mode: :normal | :strict}

docs_fetch(start_time, module, function, source)

@spec docs_fetch(integer(), module(), atom(), :cache | :python | :metadata) :: :ok

Emits docs fetch event.

Measurements

  • duration - Time in native units

Metadata

  • module - Module fetched
  • function - Function name
  • source - :cache, :python, or :metadata

event_metadata_schema(arg1)

@spec event_metadata_schema([atom()]) :: [atom()]

Returns the expected metadata fields for an event.

generate_stop(start_time, library, file, bytes, functions, classes)

@spec generate_stop(
  integer(),
  atom(),
  String.t(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer()
) :: :ok

Emits generate stop event.

Measurements

  • duration - Time in native units
  • bytes_written - Number of bytes written
  • functions_generated - Number of functions generated
  • classes_generated - Number of classes generated

Metadata

  • library - Library atom generated
  • phase - :generate
  • details - %{file: String.t()}

introspect_start(library, batch_size)

@spec introspect_start(atom(), non_neg_integer()) :: :ok

Emits introspect start event.

Measurements

  • system_time - System time when introspection started

Metadata

  • library - Library atom being introspected
  • phase - :introspect
  • details - %{batch_size: non_neg_integer()}

introspect_stop(start_time, library, symbols, cache_hits, python_time)

@spec introspect_stop(
  integer(),
  atom(),
  non_neg_integer(),
  non_neg_integer(),
  integer()
) :: :ok

Emits introspect stop event.

Measurements

  • duration - Time in native units
  • symbols_introspected - Number of symbols introspected
  • cache_hits - Number of cache hits

Metadata

  • library - Library atom introspected
  • phase - :introspect
  • details - %{python_time: integer()}

lock_verify(start_time, result, warnings \\ [])

@spec lock_verify(integer(), :ok | :warning | :error, [String.t()]) :: :ok

Emits lock verify event.

Measurements

  • duration - Time in native units

Metadata

  • result - :ok, :warning, or :error
  • warnings - List of warning strings

scan_stop(start_time, files, symbols, paths)

@spec scan_stop(integer(), non_neg_integer(), non_neg_integer(), [String.t()]) :: :ok

Emits scan stop event.

Measurements

  • duration - Time in native units
  • files_scanned - Number of files scanned
  • symbols_found - Number of symbols found

Metadata

  • library - :all
  • phase - :scan
  • details - %{paths: [String.t()]}

session_cleanup(session_id, source, reason)

@spec session_cleanup(String.t(), :manual | :owner_down, term()) :: :ok

Emits session cleanup event.

Measurements

  • system_time - System time when cleanup was triggered

Metadata

  • session_id - Session identifier
  • source - :manual or :owner_down
  • reason - Exit reason or :manual