Add reusable Prometheus telemetry setup#93
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes OpenTelemetry metrics support opt-in via a new telemetry extra and adds reusable helpers for configuring a Prometheus-exporting MeterProvider, while also enriching existing publish counters with a robot_id attribute for fleet breakdowns.
Changes:
- Add
requirements-telemetry.txtand wire it as an install extra (inorbit-edge[telemetry]); remove OTEL from base requirements. - Introduce
get_meter()/setup_prometheus_meter_provider()helpers and unify sync/asyncwith_counter_metric(deprecatingwith_counter_metric_async). - Add
robot_idmetric attributes toRobotSession.publish_*counters and update the demo (README, Dockerfile, env vars) to expose/metrics.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
tox.ini |
Installs telemetry deps in tox so tests can run against OTEL. |
setup.py |
Adds telemetry extras and bumps version to 2.1.0. |
requirements.txt |
Removes OTEL deps from base install. |
requirements-telemetry.txt |
Introduces pinned OTEL + Prometheus exporter dependencies. |
inorbit_edge/metrics.py |
Adds optional-OTEL no-op behavior plus Prometheus provider setup + decorator updates. |
inorbit_edge/robot.py |
Adds robot_id attributes to publish counters; fixes double-counting for publish_laser. |
inorbit_edge/tests/test_metrics.py |
Adds tests for decorator behavior, robot_id attributes, and Prometheus setup helper. |
inorbit_edge/tests/demo/example.py |
Adds optional /metrics server wiring via env vars. |
inorbit_edge/tests/demo/README.md |
Documents demo usage, telemetry extra, and Docker run instructions. |
inorbit_edge/tests/demo/Dockerfile |
Adds demo image that installs [video,telemetry] and defaults metrics env vars. |
README.md |
Documents the new telemetry extra and shows usage for Prometheus + custom metrics. |
.dockerignore |
Reduces Docker build context for demo image builds. |
inorbit_edge/__init__.py / .bumpversion.cfg |
Version bump to 2.1.0. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b-Tomas
approved these changes
Apr 30, 2026
Member
b-Tomas
left a comment
There was a problem hiding this comment.
Looks great @leandropineda
Just a couple of small comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in
[telemetry]extra to the SDK and a small helper layer so connectors can install a Prometheus-exportingMeterProviderin one call. Keeps the package import-clean when telemetry is not installed (no hard dep onopentelemetry-*). Existing publish counters now carry arobot_idattribute soFleetConnectordeployments get per-robot breakdowns for free.This PR makes OTEL optional and lifts the recipe into a function so it can be reused (e.g.
inorbit-connectorwill call it from a single place).Changes
[telemetry]extra. Base install no longer pullsopentelemetry-*.get_meter()andsetup_prometheus_meter_provider()helpers so connectors install a Prometheus-exportingMeterProviderin one call instead of copy-pasting the recipe.with_counter_metric(sync + async, optional per-call attributes); deprecatewith_counter_metric_async.RobotSession.publish_*counters now carryrobot_idfor per-robot breakdowns in fleet deployments. Stop double-counting onpublish_laser.INORBIT_METRICS_PORTenv to scrape the demo's/metrics.Backwards compatibility
pip install inorbit-edge) no longer pulls OTEL packages. Anyone relying on transitive availability must addinorbit-edge[telemetry](or pin OTEL themselves).with_counter_metric(counter)no-attribute form behaves identically to the previous version.with_counter_metric_asynckeeps working but warns.calls_publish_*_totalseries gain a newrobot_idlabel. Pre-aggregated PromQL likesum(rate(calls_publish_pose_total[5m]))still produces the same value because Prometheus sums across labels by default.Demo