Skip to content

Instrument skill handlers and dialog rendering - #509

Closed
goldyfruit wants to merge 1 commit into
OpenVoiceOS:devfrom
goldyfruit:perf/runtime-handler-metrics
Closed

goldyfruit wants to merge 1 commit into
OpenVoiceOS:devfrom
goldyfruit:perf/runtime-handler-metrics

Conversation

@goldyfruit

@goldyfruit goldyfruit commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What changed

  • measure registered skill-handler execution without counting internal bus housekeeping callbacks
  • measure Mustache dialog rendering in speak_dialog and get_response retry paths
  • publish the fixed-cardinality collectors through ovos.performance.metrics
  • document that handler, service, and rendering timings are nested rather than additive

Architecture and scope

Workshop owns these skill-level observations; ovos-core remains the sole HTTP exporter owner. No session, skill, utterance, request, or other unbounded value is exported as a label.

The earlier reply-tracing experiment was removed from the final diff. Direct-emitting skills can bypass a skill-mixin hook, and generic request IDs are not an OVOS message contract. This PR is metrics-only.

Jarbas's shared-helper review is tracked explicitly: OpenVoiceOS/ovos-utils#416 adds the dependency-free monotonic histogram primitive. The intended release order is to review and release #416, then replace this PR's local helper and bump the minimum ovos-utils version. Workshop will not import Core and create a dependency cycle, and no fallback or getattr will hide package skew.

Why

The HiveMind bridge metrics stop before OVOS skill execution. Handler and dialog boundaries expose the remaining user-visible work while preserving message, handler, and rendering semantics.

Validation

Current head 9efd827ee6b3f29d31407f950f74019a46ca66a8:

  • focused metrics tests: passed
  • broad unit run: 550 passed; two intent-layer setup errors reproduce unchanged on untouched dev in the same reused environment
  • Ruff on touched Python files: passed
  • git diff --check: passed
  • GitHub Python 3.10–3.14, lint, audit, release-preview, and CodeRabbit checks: green
  • no CI workflow changed

Summary by CodeRabbit

  • New Features

    • Added runtime performance histograms for skill handling and dialog rendering.
    • Added asynchronous event scheduling with status queries, cancellation, validation, and shutdown handling.
    • Added automatic entity-file discovery and canonical intent naming.
    • Added context-aware intent registration and vocabulary span matching.
    • Added improved session-aware context operations and lifecycle tracking.
  • Documentation

    • Added documentation covering performance metrics, measurement behavior, labels, and aggregation guidance.
    • Added performance metrics to the documentation navigation.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 52604516-54d6-4a88-9108-5374656954d2

📥 Commits

Reviewing files that changed from the base of the PR and between 9efd827 and f10d342.

📒 Files selected for processing (3)
  • docs/index.md
  • ovos_workshop/skills/ovos.py
  • pyproject.toml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Adds process-local latency histograms for skill-handler execution and dialog rendering. Instruments eligible handlers and rendering paths, registers the metrics provider, adds runtime tests, and documents histogram semantics and exposure.

Changes

Runtime performance metrics

Layer / File(s) Summary
Histogram provider and metric exposure
ovos_workshop/_metrics.py, pyproject.toml, docs/performance-metrics.md, docs/index.md
Adds thread-safe fixed-bucket histograms, JSON-friendly snapshots, predefined metrics, provider registration, and metric documentation.
Runtime measurement and validation
ovos_workshop/skills/ovos.py, test/unittests/test_runtime_metrics.py
Measures eligible skill handlers and dialog rendering, preserves handler metadata, excludes internal events, and tests the new measurements.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant EventSystem
  participant OVOSSkill
  participant SKILL_HANDLER
  participant DIALOG_RENDER
  EventSystem->>OVOSSkill: dispatch handler with handler_info
  OVOSSkill->>SKILL_HANDLER: measure handler execution
  SKILL_HANDLER-->>OVOSSkill: record duration
  OVOSSkill->>DIALOG_RENDER: measure dialog rendering
  DIALOG_RENDER-->>OVOSSkill: record duration
Loading

Suggested reviewers: jarbasal

Merge Risk: ⚪ Minimal · up to f10d3

This change adds fixed-cardinality timing metrics for skill handlers and dialog rendering without a remaining concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 3 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding instrumentation for skill-handler execution and dialog rendering.
Full details: Docstring Coverage

Explanation

Docstring coverage is 35.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 3 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ 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.

@goldyfruit

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread ovos_workshop/_metrics.py
)


class LatencyHistogram:

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 have some doubts on this one, maybe we need metrics helpers in ovos-utils to use across all other packages? we have the StopWatch class in there already.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed—the exporter is already provider/entry-point driven, but the low-level monotonic histogram storage should be shared instead of copied. I extracted that dependency-free primitive to OpenVoiceOS/ovos-utils#416. Workshop cannot import Core without reversing the dependency direction, and I do not want to hide the coordination behind a fallback/getattr. The intended order is: review and release #416, then replace this PR’s local helper and bump the explicit ovos-utils minimum. Metric ownership stays in Workshop; scrape/export policy stays in the host runtime. I am leaving this thread unresolved until that prerequisite and consumer rebase are complete.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

placeholder

Adds two opt-in latency histograms to the skill runtime: SKILL_HANDLER
around every registered event handler that carries handler_info, and
DIALOG_RENDER around each dialog-renderer call (speak_dialog and both
get_response fallbacks).

The histograms are exported through the `ovos.performance.metrics`
entry point so a collector can aggregate them alongside core's without
importing workshop internals.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@goldyfruit
goldyfruit force-pushed the perf/runtime-handler-metrics branch from 9efd827 to f10d342 Compare September 6, 2026 00:26
@goldyfruit

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@goldyfruit

Copy link
Copy Markdown
Contributor Author

🤖 Auto-generated by Claude Fable 5.1 (claude-fable-5-1) via Claude Code — NOT human-reviewed. Verify before acting.

Closing this: the instrumentation it adds turns out not to need a change in this repository at all.

A stock ovos-workshop already reports every registered handler on the bus. add_event(..., handler_info="mycroft.skill.handler") wraps the handler and emits mycroft.skill.handler.start, .complete and .error, forwarding the triggering message so the session rides along, with the skill id stamped in the context and the handler name in the payload. That is enough to time a handler from outside it. The exporter is already provider-driven through the ovos.performance.metrics entry-point group, so a collector registered there publishes the same ovos_skill_handler_execution_seconds, with the same buckets, without this diff.

That has been verified rather than assumed: a real unmodified skill drives the events, a separate bus client correlates them, and an HTTP scrape of the real exporter returns the metric family with a non-zero count. The error path emits start, error and complete, because the wrapper calls one in except and the other in finally, so a span is closed by the first terminal event and later ones are ignored.

The one metric that genuinely cannot be observed from outside is the dialog render timer, which measures a template expansion nested inside a handler that is already timed. That is not worth carrying a fork of this package for, so it is dropped rather than replaced.

The LatencyHistogram question in the open thread resolves the same way: metric ownership does not have to sit in Workshop for the metric to exist, so the helper does not need to be shared across repositories to unblock this.

@goldyfruit goldyfruit closed this Sep 10, 2026
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.

2 participants