Option C Tools
Loading...
Searching...
No Matches
tests_mcp.test_mcp_metrics Namespace Reference

Classes

class  TestPrometheusAvailableFlag
class  TestMetricsNoOpWhenAbsent
class  TestMetricsWithPrometheus
class  TestMetricsE2E

Functions

bool _is_prometheus_installed ()
McpMetrics _isolated_metrics ()

Detailed Description

Purpose
-------
Phase 5C tests for :class:`oct.mcp.metrics.McpMetrics` (Prometheus
instrumentation).

Responsibilities
----------------
- Verify no-op behaviour when ``prometheus_client`` is not installed.
- Verify ``record_call`` increments counters and records histogram.
- Verify ``record_rate_limit_hit`` and ``record_validation_failure``
  counters.
- Verify ``start_server`` launches a background daemon thread.
- Verify end-to-end metric recording through ``_run_tool``.

Diagnostics
-----------
Domain: MCP-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- Tests mock ``prometheus_client`` imports; no real metrics server is
  started.

Function Documentation

◆ _is_prometheus_installed()

bool tests_mcp.test_mcp_metrics._is_prometheus_installed ( )
protected

Definition at line 49 of file test_mcp_metrics.py.

Here is the caller graph for this function:

◆ _isolated_metrics()

McpMetrics tests_mcp.test_mcp_metrics._isolated_metrics ( )
protected
McpMetrics on a private CollectorRegistry — avoids
``Duplicated timeseries`` collisions across tests when
``prometheus_client`` is installed.

Definition at line 57 of file test_mcp_metrics.py.

Here is the caller graph for this function: