Skip to content

Telemetry

Shared telemetry for G6 production services.

Cluster: Uncategorised | Type: component | MCP Tools: 4

Overview

Shared telemetry module for all G6 production services. Provides one-call structlog JSON logging configuration, Prometheus metrics (request count + duration histogram), correlation ID generation, and a ready-to-serve /metrics response helper. Used by the MCP, REST, and web surfaces.

Launch-grade telemetry, not full observability

This component is intentionally scoped for launch readiness: structured logs, request correlation IDs, request counters, duration histograms, and a Prometheus scrape response. It is useful for first-user and paid-pilot operations, but it is not a full SLO, alerting, or Grafana dashboard stack. The launch plan defers SLO-based observability until after the first paying customers, so production operators should pair this with a lightweight external monitor such as Sentry or UptimeRobot until the fuller observability layer is installed.

When to use:

  • Configuring structured JSON logging at process startup
  • Instrumenting HTTP handlers with Prometheus counters and histograms
  • Exposing a /metrics endpoint for Prometheus scraping
  • Querying TelemetryBlock(op="capabilities") for machine-readable metric families, labels, unavailable features, and opt-out status
  • Using read-only MCP tools (telemetry_status, telemetry_capabilities, new_correlation_id) for agent-accessible introspection without creating tasks or runs

Offline / opt-out behavior:

Set G6_TELEMETRY=0 (also accepts false, no, or off) to skip structlog reconfiguration and return a valid empty Prometheus scrape body from expose_metrics_response(). Exported collector symbols remain importable for compatibility, so callers should use the gate for runtime side effects rather than assuming import-time registration disappears.

Example:

from mvp.telemetry import configure_logging, get_logger, new_request_id, REQUEST_COUNT, expose_metrics_response

configure_logging(level="INFO")     # call once at startup
log = get_logger("my_service")
request_id = new_request_id()       # "a3f1c9e0d2b4"

log.info("request_received", request_id=request_id, path="/solve")
REQUEST_COUNT.labels(surface="mcp", method="POST", endpoint="/solve", status="200").inc()

# In a /metrics handler:
body, content_type = expose_metrics_response()

Works well with: observability, middleware, agent_runtime

Public API

TelemetryInput(BaseModel)

Field Type Default
op str required
parameters dict[str, Any] Field(default_factory=dict)

TelemetryOutput(BaseModel)

Field Type Default
op str ''
result dict[str, Any] Field(default_factory=dict)
message str ''
completion_state Literal['verified', 'qualified-draft', 'blocked-escalated'] 'qualified-draft'
warning_card dict[str, Any] \| None None
evidence dict[str, Any] Field(default_factory=dict)
request_id str ''

TelemetryBlock(AIBlock)

AIBlock wrapper for the G6 telemetry subsystem (structlog + Prometheus).

Methods:

infer(input: TelemetryInput) -> Result[TelemetryOutput]

MCP Tools

Operation Source
telemetry_status telemetry_mcp
telemetry_capabilities telemetry_mcp
new_correlation_id telemetry_mcp
get_info telemetry_mcp