Skip to content

feat: exporter prometheus_client /metrics (JEP-0013 Phase 2) - #934

Open
RoddieKieley wants to merge 13 commits into
jumpstarter-dev:mainfrom
RoddieKieley:jep-0013-phase2-exporter-metrics
Open

feat: exporter prometheus_client /metrics (JEP-0013 Phase 2)#934
RoddieKieley wants to merge 13 commits into
jumpstarter-dev:mainfrom
RoddieKieley:jep-0013-phase2-exporter-metrics

Conversation

@RoddieKieley

Copy link
Copy Markdown
Contributor
  • Add exporter-local prometheus_client registry with JEP-named series: jumpstarter_operations_total, jumpstarter_operation_duration_seconds, jumpstarter_operation_errors_total, jumpstarter_stream_bytes_total, jumpstarter_active_sessions, plus exemplars (client, lease_id).
  • Expose HTTP GET /metrics on the exporter process for lab/dev scrape (same registry Phase 3 will later reverse-scrape via MetricsStream).
  • Minimal core-path wiring so series increment under test; full per-driver telemetry architecture remains Phase 4.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 643cea3a-48f4-4e37-a006-03476029dddf

📥 Commits

Reviewing files that changed from the base of the PR and between b29c345 and 21dd350.

📒 Files selected for processing (2)
  • python/packages/jumpstarter/jumpstarter/driver/base.py
  • python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • python/packages/jumpstarter/jumpstarter/driver/base.py
  • python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py

📝 Walkthrough

Walkthrough

The exporter adds a local Prometheus registry, an HTTP metrics server, driver and stream instrumentation, active-session tracking, and configurable CLI bind-address propagation.

Changes

Exporter metrics

Layer / File(s) Summary
Metrics registry and HTTP server
python/packages/jumpstarter/jumpstarter/metrics/*, python/packages/jumpstarter/pyproject.toml
Adds metrics for operations, errors, durations, streams, sessions, and exemplars. Serves OpenMetrics data at /metrics with configurable bind behavior.
Driver, session, and stream instrumentation
python/packages/jumpstarter/jumpstarter/driver/base.py, python/packages/jumpstarter/jumpstarter/exporter/session.py, python/packages/jumpstarter/jumpstarter/streams/common.py, python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
Records driver outcomes and durations, classifies failures, tracks active sessions, and records directional stream bytes. Tests cover registry behavior and integration wiring.
Metrics bind configuration
python/packages/jumpstarter-cli/jumpstarter_cli/run.py
Adds --metrics-bind-address, defaults it to :0, supports 0 to disable metrics, and forwards it to the child process.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 21dd3

The metrics exporter change has no actionable merge-blocking risk identified at the current head and is merge-ready after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant CLI as run command
  participant Child as exporter child
  participant Server as metrics HTTP server
  participant Registry as MetricsRegistry
  participant Driver as driver handler
  CLI->>Child: pass metrics_bind_address
  Child->>Server: start metrics server
  Server->>Registry: expose /metrics
  Driver->>Registry: record operations and stream bytes
  Registry-->>Server: return OpenMetrics data
Loading

Poem

A rabbit tracks each byte in flight,
And marks each driver call just right.
The metrics server starts on cue,
With ephemeral ports when set to :0.
Sessions rise and fall in view.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.82% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the exporter Prometheus metrics feature and its JEP-0013 phase.
Description check ✅ Passed The description directly explains the exporter-local metrics registry, HTTP endpoint, exemplars, and core-path wiring.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread python/packages/jumpstarter/jumpstarter/metrics/__init__.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/exporter/session.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py
Comment thread python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
python/packages/jumpstarter/jumpstarter/driver/base.py (1)

161-173: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Record unary success after response serialization.

encode_value(result) can raise after _record_operation_metrics(..., result="success") records success, then the generic handler records the same RPC as result="failure". Build the DriverCallResponse before recording success.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/packages/jumpstarter/jumpstarter/driver/base.py` around lines 161 -
173, The unary operation handler currently records success before response
serialization can fail. In the surrounding operation flow, construct the
DriverCallResponse and run encode_value(result) before calling
_record_operation_metrics with result="success"; keep the success log and return
after serialization succeeds so encoding failures are handled only as failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@python/packages/jumpstarter/jumpstarter/driver/base.py`:
- Around line 161-173: The unary operation handler currently records success
before response serialization can fail. In the surrounding operation flow,
construct the DriverCallResponse and run encode_value(result) before calling
_record_operation_metrics with result="success"; keep the success log and return
after serialization succeeds so encoding failures are handled only as failures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 75605a6c-9f92-4070-b4a6-707a6f3fe110

📥 Commits

Reviewing files that changed from the base of the PR and between 7fb0364 and 1c23b95.

⛔ Files ignored due to path filters (1)
  • python/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • python/packages/jumpstarter-cli/jumpstarter_cli/run.py
  • python/packages/jumpstarter/jumpstarter/driver/base.py
  • python/packages/jumpstarter/jumpstarter/exporter/session.py
  • python/packages/jumpstarter/jumpstarter/metrics/__init__.py
  • python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
  • python/packages/jumpstarter/jumpstarter/metrics/registry.py
  • python/packages/jumpstarter/jumpstarter/metrics/server.py
  • python/packages/jumpstarter/jumpstarter/streams/common.py
  • python/packages/jumpstarter/pyproject.toml

@RoddieKieley
RoddieKieley requested a review from raballew August 11, 2026 23:06
@bennyz
bennyz requested a review from bkhizgiy August 12, 2026 13:22

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
python/packages/jumpstarter-cli/jumpstarter_cli/run.py (1)

325-345: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add or verify command-level coverage for the new option.

The supplied tests cover start_metrics_server, but not the run command boundary. If no command-level test exists, cover the default :0, the disable value 0, and forwarding into _serve_with_exc_handling.

As per coding guidelines, Python test files must provide comprehensive package test coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@python/packages/jumpstarter-cli/jumpstarter_cli/run.py` around lines 325 -
345, Add command-level tests for the `run` command that verify the default
`metrics_bind_address` value `:0`, the disable value `0`, and forwarding the
selected value into `_serve_with_exc_handling`. Reuse the existing CLI test
fixtures and preserve coverage of the `run` boundary in addition to
`start_metrics_server`.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py`:
- Around line 210-217: Update start_metrics_server and
test_metrics_server_ephemeral_bind_returns_concrete_port so the test receives a
shutdown handle along with the address, then invoke that handle in a finally
block surrounding the URL request and assertions to close the listening socket
and background thread.

---

Nitpick comments:
In `@python/packages/jumpstarter-cli/jumpstarter_cli/run.py`:
- Around line 325-345: Add command-level tests for the `run` command that verify
the default `metrics_bind_address` value `:0`, the disable value `0`, and
forwarding the selected value into `_serve_with_exc_handling`. Reuse the
existing CLI test fixtures and preserve coverage of the `run` boundary in
addition to `start_metrics_server`.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c82536c3-1000-4fc8-915c-1965ef93b839

📥 Commits

Reviewing files that changed from the base of the PR and between 8215b9f and b29c345.

📒 Files selected for processing (3)
  • python/packages/jumpstarter-cli/jumpstarter_cli/run.py
  • python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
  • python/packages/jumpstarter/jumpstarter/metrics/server.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • python/packages/jumpstarter/jumpstarter/metrics/server.py

Comment thread python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/driver/base.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/server.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/__init__.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/server.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/metrics_test.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/server.py
Comment thread python/packages/jumpstarter/jumpstarter/streams/common.py Outdated
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py
Comment thread python/packages/jumpstarter/jumpstarter/metrics/registry.py Outdated
@RoddieKieley
RoddieKieley requested a review from raballew August 14, 2026 15:35

@mangelajo mangelajo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary — PR #934: Exporter Prometheus metrics (JEP-0013 Phase 2)

This PR adds exporter-local Prometheus metrics with a prometheus_client registry, an HTTP /metrics endpoint, and instrumentation of the DriverCall/StreamingDriverCall/Stream code paths. Previous review feedback (26 threads from raballew and CodeRabbit) has been thoroughly addressed.

JEP-0013 Compliance Assessment

What Phase 2 should deliver per the JEP:

  1. /metrics scrape endpoints on Controller and Router (covered by PR #933)
  2. Exporter-local prometheus_client counters/histograms/gauges with driver_type
  3. Prometheus exemplars for client, lease_id, trace_id (when present)

Metric series implemented vs. JEP specification:

JEP Series Implemented Notes
jumpstarter_operations_total Yes Labels: exporter, operation, result, driver_type — matches JEP
jumpstarter_operation_duration_seconds Yes Histogram with default buckets — matches JEP
jumpstarter_operation_errors_total Yes Labels include error_type — matches JEP
jumpstarter_stream_bytes_total Yes Labels: exporter, driver_type, direction — matches JEP
jumpstarter_active_sessions Yes Gauge with exporter label — matches JEP
jumpstarter_lease_acquisitions_total No Controller-side metric — not in scope for this PR
jumpstarter_telemetry_dropped_total No Phase 3 (Telemetry service) — correctly deferred
jumpstarter_scrape_timeouts_total No Phase 3 (Telemetry service) — correctly deferred

Gaps / deviations from JEP:

  1. trace_id exemplar: JEP lists trace_id as an exemplar key. This PR only implements client and lease_id. Likely a Phase 3+ concern.
  2. driver_type unbounded: JEP specifies a driverTypeEnum allowlist with remap to "other". The implementation accepts any string. The codebase already has 6 driver types outside the JEP's predefined set (automotive, bluetooth, gpio, debug, shell, testing). No remapping is done.
  3. operation unbounded: The label comes from @export method names. Bounded per-process by loaded drivers but not validated against an allowlist.

All three gaps are documented in inline comments. None are blockers for Phase 2.

What looks good

  • Isolation from RPC path: _record_operation_metrics wraps all metrics calls in try/except, ensuring metrics failures never discard gRPC responses or change abort status codes. This is tested by test_driver_call_succeeds_when_metrics_recording_raises.
  • AbortError bypass: The grpc.aio.AbortError catch before the generic except Exception prevents cardinality explosion from client-controlled invalid method names. Tested by test_unknown_driver_method_does_not_record_operation_metric.
  • Encode-before-record: Success metrics are recorded only after the response is encoded, so serialization failures correctly count as failures.
  • Dedicated registry: Uses a separate CollectorRegistry (not prometheus_client.REGISTRY), avoiding pollution from/to default Go-style process metrics. This is the right choice for the exporter.
  • Non-fatal server binding: Metrics server bind failures log a warning and return ("", None), so the exporter continues operating without metrics.
  • Error type consolidation: The _DRIVER_CALL_ERRORS table replaces duplicated exception handling blocks in DriverCall and StreamingDriverCall, reducing code from ~90 lines to ~35 — a nice refactor.
  • Stream metrics: copy_stream captures metrics context once before the loop, not per-chunk, avoiding repeated structlog lookups in the hot path.
  • Test coverage: 400+ lines of tests covering the registry, server lifecycle, driver error mapping, exemplars, cardinality protection, and graceful degradation.

Findings (see inline comments)

  1. driver_type unbounded — No remapping of unknown driver types to "other" as the JEP specifies. Not a blocker but worth tracking.
  2. operation label unbounded — Bounded in practice by loaded drivers but not documented/validated.
  3. error_type type safety_record_operation_metrics accepts str | None rather than ErrorType | None, so the Literal types can't catch typos.
  4. Stream metrics hot-path — Per-chunk Counter.inc() could add overhead for high-throughput streams; monitor and batch if needed.
  5. Ephemeral port default--metrics-bind-address defaults to :0 (always enabled, random port). Question about intent for controller-mode exporters.
  6. trace_id exemplar missing — JEP includes it; presumably Phase 3.

No blocking issues. The implementation is well-aligned with JEP-0013 Phase 2 scope.


AI generated, human reviewed/modified.

exporter: str,
operation: str,
result: OperationResult,
driver_type: str,

@mangelajo mangelajo Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be ignored, the plan is to do it metrics server side, and anyway I believe the bigger problem is going to be the operations. (previous comment L93)

JEP-0013 conformance — driver_type is unbounded

The JEP specifies a bounded driverTypeEnum allowlist (storage, power, network, serial, console, video, composite) with unmapped values remapped to "other". However driver_type here is accepted as a plain str with no validation.

In practice, the codebase already has drivers using automotive, bluetooth, gpio, debug, shell, and testing — all outside the JEP's predefined set. There's no enforcement at the registry level, so each unique driver_type string creates new Prometheus label combinations, growing series cardinality.

The JEP envisions server-side remapping in spec.telemetry.metrics.driverTypeEnum, but that's a Phase 5 concern. For Phase 2, consider at least:

  1. Documenting that driver_type cardinality is bounded by the number of loaded drivers (finite per process), or
  2. Adding a _KNOWN_DRIVER_TYPES set and remapping unknown values to "other" in record_operation().

Not a blocker — just flagging a gap between the JEP's design and the current implementation.


AI generated, human reviewed/modified.

self,
*,
exporter: str,
operation: str,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JEP-0013 conformance — operation label is also unbounded

The operation label comes from request.method in DriverCall, which is the driver method name (e.g., "on", "off", "flash"). While the grpc.aio.AbortError catch prevents recording metrics for unknown methods rejected by __lookup_drivercall, the set of valid operations is still unbounded across all driver types.

The JEP mentions operation in the label set but doesn't explicitly constrain it. In practice this is bounded by the number of @export methods across all loaded drivers per process, so it's unlikely to cause cardinality explosion. But it's worth documenting this assumption.


AI generated, human reviewed/modified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true... We may want to keep an eye on this and move them to exemplars if necessary later. I would make a note of this on the JEP somewhere.

May be after the Unresolved questions, add a Risks section with a note on evaluating how this works? https://jumpstarter.dev/main/contributing/jeps/JEP-0013-observability-telemetry-logs.html#unresolved-questions

metrics_registry = get_registry()
async for v in src:
if metrics_direction is not None:
metrics_registry.add_stream_bytes(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good that the metrics context (exporter, exemplars, registry) is captured once before the loop rather than per-chunk. This avoids per-iteration structlog lookups in the hot path.

However, add_stream_bytes is called for every chunk in the stream. For high-throughput streams (e.g., storage flashing), this means one Counter.inc() call per chunk. The prometheus_client Counter is thread-safe (uses a lock internally), so this could introduce contention if tx and rx run concurrently in the task group.

For Phase 2 this is likely fine (the contention is on different label sets so different _ValueClass instances). Just something to monitor if stream throughput becomes a concern — batching byte counts and flushing periodically would reduce overhead.


AI generated, human reviewed/modified.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this to risks as well?, if we notice degradation in flashing performance we may want to batch the increments.

from prometheus_client import CollectorRegistry, Counter, Gauge, Histogram
from prometheus_client.openmetrics.exposition import generate_latest as generate_latest_openmetrics

DEFAULT_EXEMPLAR_KEYS = ("client", "lease_id")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JEP-0013 conformance — exemplar keys

The JEP lists exemplar keys as client, lease_id, and trace_id (when present). This implementation only includes client and lease_id. The trace_id is presumably a Phase 3+ concern (telemetry service), but it's worth noting the gap for tracking purposes.


AI generated, human reviewed/modified.

server = ThreadingHTTPServer((host, port), Handler)
server.request_queue_size = _METRICS_REQUEST_QUEUE_SIZE
server.timeout = _METRICS_REQUEST_TIMEOUT_S
except (OSError, ValueError) as e:

@mangelajo mangelajo Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be fatal, if we want metrics this should become a more evident error to the administrator. Probably if we exit, a new random port will be tried, this risk could be avoided by listening on a unix socket or memory stream if that's possible with the prometheus stack.

"Operation failed",
extra={"operation": op, "driver_type": self.driver_type,
"result": "failure", "error_type": "connection_error"},
self._record_operation_metrics(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The try/except wrapping around _record_operation_metrics is critical and well-designed — a metrics failure must never discard an already-computed gRPC response. The test test_driver_call_succeeds_when_metrics_recording_raises validates this, which is excellent.

One subtlety: this line falls through to _record_operation_metrics which itself has a try/except. So there's double protection — the method-level wrapper and the internal wrapper. That's fine for defense-in-depth, but the outer wrapper here might mask bugs in the metrics code during development. Consider logging at DEBUG rather than WARNING for the inner catch if both levels are active.


AI generated, human reviewed/modified.

await exporter.serve()
except* Exception as excgroup:
_handle_exporter_exceptions(excgroup)
from jumpstarter.metrics import start_metrics_server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we import here and not at the top?

default=False,
help="Exit after the current lease ends instead of waiting for a new one.",
)
@click.option(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more than an option itself, this should be something internal, that the exporter decides to start or not based on the availability of a metrics endpoint in jumpstarter.

What I mean is that this is an internal detail, the exporter should recognize if the endpoint should be created, probably we don't even need to listen on a TCP port, since the exporter itself will funnel the scrapping requests down to the metrics server. Could be a unix socket, or a memory stream.

Probably until we add a mechanism to look at the server availability of a metrics endpoint we can start it always by default in the main branch.

self,
*,
exporter: str,
operation: str,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is true... We may want to keep an eye on this and move them to exemplars if necessary later. I would make a note of this on the JEP somewhere.

May be after the Unresolved questions, add a Risks section with a note on evaluating how this works? https://jumpstarter.dev/main/contributing/jeps/JEP-0013-observability-telemetry-logs.html#unresolved-questions

metrics_registry = get_registry()
async for v in src:
if metrics_direction is not None:
metrics_registry.add_stream_bytes(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add this to risks as well?, if we notice degradation in flashing performance we may want to batch the increments.

RoddieKieley and others added 12 commits August 19, 2026 18:37
- Add exporter-local `prometheus_client` registry with JEP-named series: `jumpstarter_operations_total`, `jumpstarter_operation_duration_seconds`, `jumpstarter_operation_errors_total`, `jumpstarter_stream_bytes_total`, `jumpstarter_active_sessions`, plus exemplars (`client`, `lease_id`).
- Expose HTTP `GET /metrics` on the exporter process for lab/dev scrape (same registry Phase 3 will later reverse-scrape via MetricsStream).
- Minimal core-path wiring so series increment under test; full per-driver telemetry architecture remains Phase 4.
Re-raise grpc AbortError before generic handlers to avoid client-controlled
operation label cardinality, tighten bounded metric label types, default
metrics bind host to loopback, log session metric decrements on failure, and
expand exporter metrics unit coverage.
Avoid repeated exporter/exemplar context lookups inside the copy_stream
loop now that metrics helpers are imported at module level.
Build DriverCallResponse (including encode_value) before recording success
so serialization failures are counted only as failures, with a regression test.

Co-authored-by: Cursor <cursoragent@cursor.com>
Default jmp run --metrics-bind-address to :0 so concurrent exporters do not
collide on 8080, and treat metrics listen bind errors as non-fatal so the
exporter continues without /metrics when a fixed port is already taken.
Stop the metrics HTTP server from tests and jmp run so listen sockets
are not leaked after exporter exit.
Parse failures (ValueError) now share the bind-failure path so a bad
--metrics-bind-address cannot crash the exporter.

Co-authored-by: Cursor <cursoragent@cursor.com>
Avoid a race where the asyncio path and metrics HTTP thread each create
a MetricsRegistry and discard counters from the first instance.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clear the exporter correlation field after decrementing active sessions
so it does not leak into later sessions or logs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Centralize DriverCall/StreamingDriverCall error mapping, move
reset_registry_for_tests to metrics/_testing, restore log_message(format=),
hoist session/stream imports, tighten exemplar regex asserts, add metrics
HTTP request timeout and backlog limits, and rename
inc_active_sessions to adjust_active_sessions.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@RoddieKieley
RoddieKieley force-pushed the jep-0013-phase2-exporter-metrics branch from e6fca45 to 35674c9 Compare August 19, 2026 21:10
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

4 participants