Skip to content

Conversation

@harp-intel
Copy link
Contributor

This pull request introduces a new feature for trimming metrics to a specific time range and refactors the metrics codebase to use integer timestamps consistently. It also improves usability and robustness in the metrics reporting and summary generation. The most important changes are grouped below:

New Feature: Time Range Trimming for Metrics

  • Added a new metrics trim subcommand, allowing users to generate summary reports for a specific time interval using either absolute timestamps or relative offsets. This is documented in the README.md with usage examples and output details.
  • Implemented filterByTimeRange methods for both MetricCollection and MetricGroup, enabling filtering of metrics rows to a specified time range. The summary generation pipeline now supports time-based trimming via summarizeMetricsWithTrim. [1] [2]

Timestamp Refactor

  • Changed the internal representation of timestamps from float64 to int throughout the metrics codebase, including struct fields, parsing logic, aggregation, and tests, ensuring consistency and simplifying time-based operations. [1] [2] [3] [4] [5] [6]

Usability Improvements

  • The metrics command now displays available subcommands in its help output, making it easier for users to discover and use features like trimming.

Robustness and Error Handling

  • Added an Initialized method to the Metadata struct and updated the JSON marshaling logic to output null if metadata is uninitialized, preventing errors in downstream report generation.

Frontend/Reporting Enhancements

  • Updated the HTML report templates to safely handle cases where system_info or metadata may be undefined, preventing runtime errors in the interactive report. [1] [2]

Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
@harp-intel harp-intel linked an issue Nov 28, 2025 that may be closed by this pull request
@harp-intel harp-intel requested a review from Copilot November 28, 2025 18:48
Copy link
Contributor

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 pull request introduces a new metrics trim subcommand for filtering metrics to specific time ranges and refactors timestamp handling from float64 to int throughout the metrics codebase. This allows users to analyze specific portions of collected metrics data by excluding unwanted phases like setup or teardown.

Key changes:

  • Added metrics trim subcommand with support for absolute timestamps and relative time offsets
  • Refactored all timestamp representations from float64 to int for consistency
  • Enhanced HTML report templates with null-safety checks for metadata

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cmd/metrics/trim.go New trim subcommand implementation with time range validation and filtering logic
cmd/metrics/summary.go Added summarizeMetricsWithTrim function and filterByTimeRange methods; refactored timestamp type from float64 to int
cmd/metrics/summary_test.go Updated test fixtures to use integer timestamps instead of float64
cmd/metrics/metadata.go Added Initialized() method and null-handling in JSON marshaling
cmd/metrics/metrics.go Enhanced usage output to display available subcommands
cmd/metrics/resources/base.html Added null-safety checks for system_info and metadata in template
README.md Documented the new trim feature with usage examples

Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
Signed-off-by: Harper, Jason M <jason.m.harper@intel.com>
@harp-intel harp-intel merged commit ded2a2b into main Nov 29, 2025
11 of 14 checks passed
@harp-intel harp-intel deleted the metricstrim branch November 29, 2025 16:57
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.

add feature to refine time range of metrics data

2 participants