Telemetry¶
mt5cli.telemetry ¶
Optional OpenTelemetry metrics for MT5 history and snapshot observability.
configure_metrics ¶
Configure MT5 metrics using the provided meter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
meter
|
Any
|
An OpenTelemetry |
required |
enable_otel_metrics ¶
Enable OTel metrics by wiring up an SDK MeterProvider pipeline.
Requires the otel optional dependency group:
pip install "mt5cli[otel]".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_name
|
str
|
OTel meter/service name used for the |
'mt5cli'
|
readers
|
list[Any] | None
|
Optional list of metric readers. When None (the default),
a :class: |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in mt5cli/telemetry.py
get_metrics ¶
Return the global :class:_Mt5Metrics instance.
Returns:
| Type | Description |
|---|---|
_Mt5Metrics
|
The global metric registry (no-op until :func: |
_Mt5Metrics
|
called). |
Enabling OpenTelemetry metrics¶
Install the optional exporter dependencies with:
Then enable the default OTLP HTTP pipeline:
When readers=None, enable_otel_metrics() builds a
PeriodicExportingMetricReader backed by the OTLP HTTP exporter and reads the
endpoint from OTEL_EXPORTER_OTLP_ENDPOINT.
If your application already owns an OpenTelemetry Meter, wire mt5cli into it
directly with configure_metrics(meter).
Emitted metric names¶
enable_otel_metrics() / configure_metrics() register these instruments:
mt5_history_update_duration_secondsmt5_history_update_rows_totalmt5_history_update_failures_totalmt5_snapshot_update_duration_secondsmt5_snapshot_update_failures_totalmt5_account_balancemt5_account_equitymt5_account_marginmt5_account_margin_freemt5_account_margin_levelmt5_position_profitmt5_position_volumemt5_terminal_connectedmt5_terminal_trade_allowedmt5_terminal_trade_expertmt5_last_successful_update_timestamp
The history metrics use a dataset attribute. Account and position gauges add
labels such as login, server, and symbol where applicable.