DeribitEx.Telemetry (deribit_ex v0.1.0)
View SourceTelemetry events for the DeribitEx library.
This module provides a consistent interface for emitting telemetry events throughout the library. Use these functions instead of calling :telemetry.execute directly to ensure consistent event naming and metadata structure.
Event Categories
DeribitEx emits telemetry events in the following categories:
- Connection: Events related to WebSocket connection lifecycle
- RPC: Events for request/response operations
- Auth: Authentication-related events
- Subscription: Channel subscription events
- Order Context: Order tracking events
Example Usage
:telemetry.attach(
"deribit-auth-handler",
[:deribit_ex, :auth, :success],
fn name, measurements, metadata, _config ->
# Process authentication success event
end,
nil
)
Summary
Types
Connection identifier, typically the WebSocket client PID.
Generic metadata map for telemetry events.
RPC request types.
Session identifier for tracking session state.
Types of session transitions.
Functions
Emits a telemetry event when authentication fails.
Emits a telemetry event when authentication is successful.
Emits a telemetry event when a connection is closed.
Emits a telemetry event when a connection is established.
Emits a telemetry event when an order is registered.
Emits a telemetry event when an order is updated.
Emits a telemetry event when an RPC request is sent.
Emits a telemetry event when an RPC response is received.
Emits a telemetry event when a session transition occurs.
Emits a telemetry event when a subscription is created.
Emits a telemetry event when a subscription is removed.
Types
Connection identifier, typically the WebSocket client PID.
@type metadata() :: map()
Generic metadata map for telemetry events.
@type rpc_type() :: :auth | :public | :private | :subscription | :heartbeat
RPC request types.
@type session_id() :: String.t()
Session identifier for tracking session state.
@type transition_type() :: :refresh | :exchange | :fork | :logout
Types of session transitions.
Functions
@spec emit_auth_failure(connection(), term(), metadata()) :: :ok
Emits a telemetry event when authentication fails.
Parameters
connection
: The WebSocket connection identifierreason
: The reason for the authentication failuremetadata
: Additional metadata to include with the event
@spec emit_auth_success(connection(), metadata()) :: :ok
Emits a telemetry event when authentication is successful.
Parameters
connection
: The WebSocket connection identifiermetadata
: Additional metadata to include with the event
@spec emit_connection_closed(connection(), term(), metadata()) :: :ok
Emits a telemetry event when a connection is closed.
Parameters
connection
: The WebSocket connection identifierreason
: The reason for the connection closuremetadata
: Additional metadata to include with the event
@spec emit_connection_opened(connection(), metadata()) :: :ok
Emits a telemetry event when a connection is established.
Parameters
connection
: The WebSocket connection identifiermetadata
: Additional metadata to include with the event
@spec emit_order_registered(String.t(), session_id(), metadata()) :: :ok
Emits a telemetry event when an order is registered.
Parameters
order_id
: The ID of the ordersession_id
: The session ID that the order belongs tometadata
: Additional metadata to include with the event
@spec emit_order_updated(String.t(), session_id(), String.t(), metadata()) :: :ok
Emits a telemetry event when an order is updated.
Parameters
order_id
: The ID of the ordersession_id
: The session ID that the order belongs tostatus
: The new status of the ordermetadata
: Additional metadata to include with the event
Emits a telemetry event when an RPC request is sent.
Parameters
type
: The type of RPC request (:auth, :public, :private, etc.)method
: The RPC method namemetadata
: Additional metadata to include with the event
Emits a telemetry event when an RPC response is received.
Parameters
type
: The type of RPC request that this is a response tomethod
: The RPC method nameduration
: The duration of the request in native time unitsmetadata
: Additional metadata to include with the event
@spec emit_session_transition( session_id(), session_id(), transition_type(), metadata() ) :: :ok
Emits a telemetry event when a session transition occurs.
Parameters
prev_session_id
: The previous session IDnew_session_id
: The new session IDtransition_type
: The type of transition (:refresh, :exchange, :fork, :logout)metadata
: Additional metadata to include with the event
Emits a telemetry event when a subscription is created.
Parameters
channel
: The channel name that was subscribed tometadata
: Additional metadata to include with the event
Emits a telemetry event when a subscription is removed.
Parameters
channel
: The channel name that was unsubscribed frommetadata
: Additional metadata to include with the event