Skip to content

metrics: Add hopr_last_time and rename hopr_up #7183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 30, 2025
Merged

Conversation

tolbrino
Copy link
Contributor

@tolbrino tolbrino commented May 26, 2025

@tolbrino tolbrino added this to the 3.0.0 milestone May 26, 2025
@tolbrino tolbrino requested a review from a team May 26, 2025 11:45
@tolbrino tolbrino self-assigned this May 26, 2025
@Copilot Copilot AI review requested due to automatic review settings May 26, 2025 11:45
@tolbrino tolbrino enabled auto-merge May 26, 2025 11:46
Copy link
Contributor

coderabbitai bot commented May 26, 2025

📝 Walkthrough
## Walkthrough

This change updates metric labels from `hopr_up` to `hopr_start_time` across documentation, code, and dashboard configurations. It also introduces a new metric to record the timestamp of the last API endpoint fetch. The `hopr-platform` dependency is added to the REST API crate.

## Changes

| Files / Paths                                                                 | Change Summary                                                                                          |
|-------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| METRICS.md                                                                    | Renamed `hopr_up` to `hopr_start_time` and added `hopr_http_api_last_used_time` metric with descriptions.|
| deploy/compose/grafana/provisioning/dashboards/hopr/hoprd-grafana-dashboard.json | Updated all dashboard queries and variable definitions from `hopr_up` to `hopr_start_time`.             |
| hopr/hopr-lib/src/lib.rs                                                      | Renamed metric label from `hopr_up` to `hopr_start_time`.                                              |
| hoprd/rest-api/Cargo.toml                                                     | Added `hopr-platform` as a new workspace dependency.                                                   |
| hoprd/rest-api/src/prometheus.rs                                              | Added `METRIC_API_LAST_TIME` gauge to record the last API fetch timestamp.                             |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant API
    participant Prometheus

    Client->>API: Make API request
    API->>API: Process request
    API->>Prometheus: Update METRIC_API_LAST_TIME with current timestamp
    API-->>Client: Respond to request

Assessment against linked issues

Objective Addressed Explanation
Rename hopr_up metric to hopr_start_time (7083)
Add a metric for last seen/current timestamp of node (hopr_last_seen or similar) (7083)

Suggested labels

crate:hoprd

Suggested reviewers

  • tolbrino
  • Teebor-Choka

</details>

<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: .coderabbit.yaml**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 3784c1c3442ae713c5fe898f930809c25ff3cc20 and 856d2f6dcc52707ec9cb7bc63d3b793aae5db67f.

</details>

<details>
<summary>⛔ Files ignored due to path filters (1)</summary>

* `Cargo.lock` is excluded by `!**/*.lock`

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `METRICS.md` (1 hunks)
* `hopr/hopr-lib/src/lib.rs` (1 hunks)
* `hoprd/rest-api/src/prometheus.rs` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>

* hopr/hopr-lib/src/lib.rs
* METRICS.md
* hoprd/rest-api/src/prometheus.rs

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (6)</summary>

* GitHub Check: tests-smoke-hopli
* GitHub Check: tests-unit-nightly
* GitHub Check: tests-unit
* GitHub Check: hoprd / docker
* GitHub Check: Linter
* GitHub Check: zizmor

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNxU3bABsvkCiQBHbGlcABpIcVwvOkgAIjZcCngGRC4AQVp6WHxeAH0vNERcXPE2dAx6fww0Muy87G5Q2MgAd0LGf2oYuUhsREoI/C8BJIx8cvpUDEcBShiAdgBGAA4AZg0YWBJrOzRM/0R+5CQHaUgzeYAGNYnzgDYlu424baVEBiTucXwsWnwzsa4HgUfASeBKSBKXDaaKTDAAM3wFGY1HgP3QAnweAiW3s3FE8HhyU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OCGnBhIHCAkgoOgKoOKVKQYI8gkj4goCqADCSm3CWnIHoDBCpzlBMLMPmlrBHEKHknDnmiVmcK0EQFmlEB8PhDuAABZnCsobx9DCdeITDEkd57ob0N4tdvN4jnZGB4jNF/AKC6poh1YfEBpaA3YCC1EaRps1DGZtg78N8J8JtzkZtiR3cfgnEcZXF1dRJF4xslt283lGZLsi86Ze8tto4Hs9sNcR94U3sTs5UMglB6A5Q79iQFEhYEJkIUI38P8v8f8/8AC4IuBwD6tKCNQQU+iwYeEhVEtkt78QANQ0sGBRljiF8Qgl8tMdNgwj4SAN8DMFN8IlNIIrxcjo4HwFwR5EdVwWB1xNxvx7Bkd/xDxFBgI1BQILwIIDAfi1x1BchwQfD/B3RPQEp/NxwkTJxIQxolh5gBB4RVgSABAABOAQRYBgBgQIy4JYAAJgECZMpKZLQCZPmDuA5LQHmDJPhECLuEpNWHAkMB+M5MCMWFoFWAYEuBIEWAAFYST4RlgSAmTFTlhFh4RFTtSBBFSzE1TKS7h4R5TFg7h5T6BLwCTVh5hlhAiGBaTVhAjAiOSSAlhZTFSxplhKTlh4QRTrhLhKSGANTmJZSQzLgxT8SIBIBlhFS7haAmSAjaA6TFSuTGTRBgyBASSGA7hVgZTsyRS0A0ASBFTaABAHg5w8TkSQTUT0TchMSPpsTchpwxSgA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

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.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=hoprnet/hoprnet&utm_content=7183):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses #7083 by updating metric naming for clarity and adding a new gauge to capture the last API access time.

  • Adds a new gauge (METRIC_API_LAST_TIME) in the REST API to record the timestamp of the latest API call
  • Renames the "hopr_up" metric to "hopr_start_time" for consistency
  • Updates METRICS.md and Cargo.toml to reflect these changes

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.

File Description
hoprd/rest-api/src/prometheus.rs Introduces a new gauge to track API last access time and imports current time utility
hoprd/rest-api/Cargo.toml Adds dependency on hopr-platform
hopr/hopr-lib/src/lib.rs Renames metric "hopr_up" to "hopr_start_time" and improves log message formatting
METRICS.md Updates metric names and descriptions to reflect the changes made in the code
Files not reviewed (1)
  • deploy/compose/grafana/provisioning/dashboards/hopr/hoprd-grafana-dashboard.json: Language not supported

@Teebor-Choka Teebor-Choka disabled auto-merge May 30, 2025 20:29
@Teebor-Choka Teebor-Choka merged commit 0685a51 into master May 30, 2025
30 of 31 checks passed
@Teebor-Choka Teebor-Choka deleted the tb/202505-api-up branch May 30, 2025 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate:hopr-lib crate:hoprd-api dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve hoprd uptime metrics Get system epoch (current timestamp) of the node through the API
4 participants