ExAzureCore.Telemetry (ex_azure_core v0.2.0)

Copy Markdown

Telemetry events for ExAzureCore operations.

Events

ExAzureCore emits the following telemetry events:

[:ex_azure_core, :request, :start]

Emitted when a request starts.

Measurements:

  • :system_time - System time at start (from System.system_time())

Metadata:

  • :service - Service atom (e.g., :storage, :keyvault)
  • :method - HTTP method
  • :path - Request path

[:ex_azure_core, :request, :stop]

Emitted when a request completes (success or error).

Measurements:

  • :duration - Request duration in native time units

Metadata:

  • :service - Service atom
  • :method - HTTP method
  • :path - Request path
  • :result - :ok or :error

[:ex_azure_core, :request, :exception]

Emitted when a request raises an exception.

Measurements:

  • :duration - Time until exception in native time units

Metadata:

  • :service - Service atom
  • :kind - Exception kind (:error, :exit, :throw)
  • :reason - Exception reason
  • :stacktrace - Exception stacktrace

Usage

Attach handlers in your application startup:

:telemetry.attach_many(
  "my-app-azure-handler",
  [
    [:ex_azure_core, :request, :start],
    [:ex_azure_core, :request, :stop],
    [:ex_azure_core, :request, :exception]
  ],
  &MyApp.AzureTelemetry.handle_event/4,
  nil
)

Summary

Functions

Emits a start event.

Executes a function with telemetry span events.

Functions

emit_exception(metadata, kind, reason, stacktrace, start_time)

@spec emit_exception(map(), atom(), term(), list(), integer()) :: :ok

Emits an exception event.

emit_start(metadata)

@spec emit_start(map()) :: :ok

Emits a start event.

emit_stop(metadata, result, start_time)

@spec emit_stop(map(), {:ok, term()} | {:error, term()}, integer()) :: :ok

Emits a stop event.

span(operation, config, fun)

@spec span(struct(), map(), (-> result)) :: result
when result: {:ok, term()} | {:error, term()}

Executes a function with telemetry span events.

Emits :start before execution, :stop after successful completion, and :exception if the function raises.

Parameters

  • operation - The operation being executed (for metadata)
  • config - The resolved configuration
  • fun - The function to execute (should return {:ok, _} or {:error, _})