|
Option C Tools
|
Public Member Functions | |
| None | __init__ (self, "CollectorRegistry | None" registry=None) |
| None | start_server (self, int port) |
| None | record_call (self, str tool, str decision, float duration_s, int redactions) |
| None | record_rate_limit_hit (self, str tool) |
| None | record_validation_failure (self, str tool) |
Protected Attributes | |
| _registry = registry if registry is not None else REGISTRY | |
| Counter | _tool_calls |
| Histogram | _tool_duration |
| Counter | _rate_limit_hits |
| Counter | _redactions |
| Counter | _validation_failures |
Prometheus instrumentation for the oct-mcp pipeline. All record methods are no-ops when ``prometheus_client`` is absent. Instantiate once per server session and pass into :class:`ServerState`.
Definition at line 84 of file metrics.py.
| None oct.mcp.metrics.McpMetrics.__init__ | ( | self, | |
| "CollectorRegistry | None" | registry = None ) |
Build the metric vectors.
Parameters
----------
registry
Prometheus :class:`CollectorRegistry` to register metrics on.
``None`` (default) uses the module-level global ``REGISTRY``,
which is what ``prometheus_client.start_http_server()`` exposes
on ``/metrics`` by default. Pass a private
``CollectorRegistry()`` for tests or multi-tenant scenarios
that need isolation from other ``McpMetrics`` instances.
Definition at line 91 of file metrics.py.
| None oct.mcp.metrics.McpMetrics.record_call | ( | self, | |
| str | tool, | ||
| str | decision, | ||
| float | duration_s, | ||
| int | redactions ) |
Record a completed (or denied) tool call.
Parameters
----------
tool
MCP tool name, e.g. ``"oct_lint"``.
decision
Pipeline decision: ``"allowed"``, ``"denied"``, or
``"requires_confirmation"``.
duration_s
Wall-clock duration in seconds.
redactions
Number of redaction substitutions applied to the output.
Definition at line 177 of file metrics.py.
| None oct.mcp.metrics.McpMetrics.record_rate_limit_hit | ( | self, | |
| str | tool ) |
Increment the rate-limit rejection counter for *tool*.
Definition at line 208 of file metrics.py.
| None oct.mcp.metrics.McpMetrics.record_validation_failure | ( | self, | |
| str | tool ) |
Increment the validation-failure counter for *tool*.
Definition at line 217 of file metrics.py.
| None oct.mcp.metrics.McpMetrics.start_server | ( | self, | |
| int | port ) |
Start the Prometheus ``/metrics`` HTTP server on *port*.
Runs in a **daemon** background thread so it does not block the
MCP event loop. Silently no-ops when ``prometheus_client`` is
absent.
Parameters
----------
port
TCP port to bind. Must be in the range 1–65535.
Definition at line 147 of file metrics.py.
|
protected |
Definition at line 124 of file metrics.py.
|
protected |
Definition at line 130 of file metrics.py.
|
protected |
Definition at line 110 of file metrics.py.
|
protected |
Definition at line 112 of file metrics.py.
|
protected |
Definition at line 118 of file metrics.py.
|
protected |
Definition at line 136 of file metrics.py.