Skip to content

feat(zetaclient): add /systemtime telemetry endpoint#3235

Merged
gartnera merged 3 commits intodevelopfrom
zetaclient-system-time
Dec 3, 2024
Merged

feat(zetaclient): add /systemtime telemetry endpoint#3235
gartnera merged 3 commits intodevelopfrom
zetaclient-system-time

Conversation

@gartnera
Copy link
Contributor

@gartnera gartnera commented Dec 2, 2024

This endpoint will be used to debug issued related to bad system time values.

Related to #3227

Summary by CodeRabbit

  • New Features
    • Introduced a new endpoint /systemtime that returns the current system time in UTC format.
  • Bug Fixes
    • No bug fixes were included in this release.
  • Documentation
    • Updated documentation to reflect the new /systemtime endpoint functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough

Walkthrough

This pull request introduces a new HTTP handler, systemdTimeHandler, to the TelemetryServer class in the zetaclient/metrics/telemetry.go file. This handler provides the current system time in UTC format via the /systemtime endpoint, formatted according to the RFC3339 standard. The handler is registered within the existing Handlers method, ensuring that the overall structure and functionality of the TelemetryServer class remain intact, with no changes to existing logic or error handling.

Changes

File Path Change Summary
zetaclient/metrics/telemetry.go Added systemdTimeHandler function to return current UTC time at /systemtime endpoint. Registered this handler in Handlers method of TelemetryServer.

Possibly related PRs

Suggested labels

no-changelog

Suggested reviewers

  • fbac
  • skosito
  • kingpinXD
  • ws4charlie
  • brewmaster012
  • lumtis

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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 for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 61.81%. Comparing base (f10ae08) to head (75e050b).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/metrics/telemetry.go 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3235      +/-   ##
===========================================
- Coverage    61.81%   61.81%   -0.01%     
===========================================
  Files          431      431              
  Lines        30759    30763       +4     
===========================================
  Hits         19015    19015              
- Misses       10886    10890       +4     
  Partials       858      858              
Files with missing lines Coverage Δ
zetaclient/metrics/telemetry.go 0.00% <0.00%> (ø)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (2)
zetaclient/metrics/telemetry.go (2)

337-341: Add unit tests for the new endpoint

The new endpoint lacks test coverage. Consider adding the following test cases:

  1. Verify the response format (RFC3339)
  2. Verify the content type header
  3. Verify the time is in UTC

Would you like me to help generate the unit test implementation?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 338-340: zetaclient/metrics/telemetry.go#L338-L340
Added lines #L338 - L340 were not covered by tests

🪛 GitHub Check: lint

[failure] 340-340:
unnecessary conversion (unconvert)


337-341: Consider adding response caching

Since system time queries might be frequent during debugging, consider adding caching headers to help clients make efficient use of the endpoint.

 func systemTimeHandler(w http.ResponseWriter, _ *http.Request) {
     w.Header().Set("Content-Type", "text/plain")
+    w.Header().Set("Cache-Control", "public, max-age=1")
     nowString := time.Now().UTC().Format(time.RFC3339)
     _, err := fmt.Fprint(w, nowString)
     if err != nil {
         log.Error().Err(err).Msg("Failed to write response")
     }
 }
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 338-340: zetaclient/metrics/telemetry.go#L338-L340
Added lines #L338 - L340 were not covered by tests

🪛 GitHub Check: lint

[failure] 340-340:
unnecessary conversion (unconvert)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f10ae08 and 56d2f08.

📒 Files selected for processing (1)
  • zetaclient/metrics/telemetry.go (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
zetaclient/metrics/telemetry.go (1)

Pattern **/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

🪛 GitHub Check: codecov/patch
zetaclient/metrics/telemetry.go

[warning] 194-194: zetaclient/metrics/telemetry.go#L194
Added line #L194 was not covered by tests


[warning] 338-340: zetaclient/metrics/telemetry.go#L338-L340
Added lines #L338 - L340 were not covered by tests

🪛 GitHub Check: lint
zetaclient/metrics/telemetry.go

[failure] 340-340:
unnecessary conversion (unconvert)

Copy link
Contributor

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

LGTM outside of lint issue

@gartnera gartnera force-pushed the zetaclient-system-time branch from 56d2f08 to 75e050b Compare December 3, 2024 16:56
@gartnera gartnera added this pull request to the merge queue Dec 3, 2024
Merged via the queue into develop with commit 30924dc Dec 3, 2024
@gartnera gartnera deleted the zetaclient-system-time branch December 3, 2024 17:53
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.

3 participants