AshScylla.Telemetry (AshScylla v0.10.2)

Copy Markdown View Source

Telemetry integration for AshScylla.

Emits standard :telemetry events for query execution, enabling integration with LiveDashboard, Datadog, OpenTelemetry, and other observability tools.

Events

  • [:ash_scylla, :query, :start] - Emitted when a query begins execution. Measurements: %{system_time: integer()} Metadata: %{resource: module(), operation: atom(), query: String.t()}

  • [:ash_scylla, :query, :stop] - Emitted when a query finishes. Measurements: %{duration: integer()} Metadata: %{resource: module(), operation: atom(), query: String.t()}

  • [:ash_scylla, :query, :exception] - Emitted when a query raises. Measurements: %{duration: integer()} Metadata: %{resource: module(), operation: atom(), query: String.t(), kind: atom(), reason: term()}

  • [:ash_scylla, :batch, :start] - Emitted when a batch operation begins. Measurements: %{system_time: integer()} Metadata: %{resource: module(), operation: atom(), batch_size: integer()}

  • [:ash_scylla, :batch, :stop] - Emitted when a batch operation finishes. Measurements: %{duration: integer()} Metadata: %{resource: module(), operation: atom(), batch_size: integer()}

Attaching a Handler

:telemetry.attach(
  "ash_scylla-logger",
  [:ash_scylla, :query, :stop],
  &MyApp.Telemetry.handle_event/4,
  nil
)

Summary

Functions

Executes a batch operation within a telemetry span.

Formats a duration in nanoseconds to a human-readable string.

Executes a function within a telemetry span.

Functions

batch_span(resource, operation, batch_size, fun)

@spec batch_span(module(), atom(), integer(), (-> result)) :: result when result: var

Executes a batch operation within a telemetry span.

Emits [:ash_scylla, :batch, :start] before execution and [:ash_scylla, :batch, :stop] after.

format_duration(nanoseconds)

@spec format_duration(integer()) :: String.t()

Formats a duration in nanoseconds to a human-readable string.

span(resource, operation, query, fun)

@spec span(module(), atom(), String.t(), (-> result)) :: result when result: var

Executes a function within a telemetry span.

Emits [:ash_scylla, :query, :start] before execution and [:ash_scylla, :query, :stop] after. If the function raises, [:ash_scylla, :query, :exception] is emitted.

Returns the function's return value.