Skip to content

Add optional Prometheus metrics for client operations - #901

Open
Poseidonas wants to merge 2 commits into
gijzelaerr:masterfrom
Poseidonas:metrics-support
Open

Poseidonas wants to merge 2 commits into
gijzelaerr:masterfrom
Poseidonas:metrics-support

Conversation

@Poseidonas

Copy link
Copy Markdown
Contributor

Adds optional Prometheus metrics for client operations, following up on #843.

snap7/metrics.py accumulates per-operation counters and durations (MetricsRegistry) and can serve them as GET /metrics (MetricsServer, stdlib http.server, no new dependency).

Client takes an optional metrics= argument. Instrumentation sits in read_area/write_area, covering db_read/db_write and the typed wrappers on top of them without touching each one individually. A snap7_client_connected gauge updates on connect/disconnect/reconnect.

Scope note: this tracks client call counts, errors, latency, and connection state — not PLC tag values, so it's separate from the exporter described in #623.

16 new tests in tests/test_metrics.py. Full suite still passes (1399/1399, excluding e2e).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant