efc0de230a
* fix: stabilize history timestamps and telemetry docs * fix: preserve numeric epoch cursors in history SQLite queries Normalize mixed ISO and unixepoch time values for incremental resume and scoped dedup so legacy numeric rows are not dropped by julianday filters. Co-authored-by: Cursor <cursoragent@cursor.com> * Bump version to v1.1.2 * fix: aggregate incremental start timestamps in SQLite Use MAX on the normalized time expression with GROUP BY so incremental resume loaders stay O(groups) instead of materializing every history row. Co-authored-by: Cursor <cursoragent@cursor.com> * test: parametrize duplicated incremental-start cases in TestIncrementalStart Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.3 KiB
Markdown
51 lines
1.3 KiB
Markdown
# Telemetry
|
|
|
|
::: mt5cli.telemetry
|
|
|
|
## Enabling OpenTelemetry metrics
|
|
|
|
Install the optional exporter dependencies with:
|
|
|
|
```bash
|
|
uv add 'mt5cli[otel]'
|
|
```
|
|
|
|
Then enable the default OTLP HTTP pipeline:
|
|
|
|
```python
|
|
from mt5cli.telemetry import enable_otel_metrics
|
|
|
|
enable_otel_metrics(service_name="mt5cli")
|
|
```
|
|
|
|
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_seconds`
|
|
- `mt5_history_update_rows_total`
|
|
- `mt5_history_update_failures_total`
|
|
- `mt5_snapshot_update_duration_seconds`
|
|
- `mt5_snapshot_update_failures_total`
|
|
- `mt5_account_balance`
|
|
- `mt5_account_equity`
|
|
- `mt5_account_margin`
|
|
- `mt5_account_margin_free`
|
|
- `mt5_account_margin_level`
|
|
- `mt5_position_profit`
|
|
- `mt5_position_volume`
|
|
- `mt5_terminal_connected`
|
|
- `mt5_terminal_trade_allowed`
|
|
- `mt5_terminal_trade_expert`
|
|
- `mt5_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.
|