-
Notifications
You must be signed in to change notification settings - Fork 1k
Initial version of defining the interfaces to accept metrics #15913
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
Changes from 1 commit
2c63137
3dd931b
7d24843
f8fb42f
b48641a
2d06ebd
9650f9d
9e0a294
602f06e
a4cf9fd
6fcf355
31f56d5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # This file defines the interfaces that snappi tests accept external metrics. | ||
|
||
|
|
||
| # Metrics data are organized into the hierarchies below | ||
| # ResourceMetrics | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # ├── ResourceID | ||
| # └── ScopeMetrics | ||
|
||
| # ├── ScopeID | ||
| # └── Metric | ||
|
||
| # ├── Name | ||
| # ├── Description | ||
| # ├── Unit | ||
| # ├── metadata | ||
| # └── data | ||
| # └── Gauge | ||
| # | ||
| # A ResourceMetrics has its ID and a list of ScopeMetrics objects. | ||
| # A ScopeMetrics has its ID and a list of Metric objects. | ||
| # A Metric has several attributes and data. So far we only have Gauge type data. | ||
| # A Gauge has a list of NumberDataPoint objects. | ||
| # A NumberDataPoint has its label, value, flags and the timestamp at which the data was collected. | ||
| # +---------------------+ | ||
| # | DataPoint 1 | | ||
| # | +---------+ +-----+ | | ||
| # +-----+ | |timestamp| |label| | | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # | 1 |-->| +---------+ +-----+ | | ||
| # +-----+ | | | ||
| # | . | | +-----+ +-----+ | | ||
| # | . | | |value| |flags| | | ||
| # | . | | +-----+ +-----+ | | ||
| # | . | +---------------------+ | ||
| # | . | . | ||
| # | . | . | ||
| # | . | . | ||
| # | . | +---------------------+ | ||
| # | . | | DataPoint M | | ||
| # +-----+ | +---------+ +-----+ | | ||
| # | M |-->| |timestamp| |label| | | ||
| # +-----+ | +---------+ +-----+ | | ||
| # | | | ||
| # | +-----+ +-----+ | | ||
| # | |value| |flags| | | ||
| # | +-----+ +-----+ | | ||
| # +---------------------+ | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| from typing import List, Dict, Union | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| class NumberDataPoint: | ||
| def __init__(self, time_unix_nano: int, label: List[Dict[str, str]], value: Union[int, float], flags: int = None): | ||
| self.time_unix_nano = time_unix_nano # UNIX Epoch time in nanoseconds | ||
| self.label = label # The key of key-value pairs in dictionaries | ||
| self.value = value # Metric value (can be double or integer) | ||
| self.flags = flags # Optional flags | ||
|
|
||
| def __repr__(self): | ||
| return (f"NumberDataPoint(label={self.label}, " | ||
| f"time_unix_nano={self.time_unix_nano}, value={self.value}, flags={self.flags})") | ||
|
|
||
|
|
||
| class Gauge: | ||
| def __init__(self): | ||
| self.data_points = [] # List of NumberDataPoint objects | ||
|
|
||
| def add_data_point(self, data_point): | ||
| self.data_points.append(data_point) | ||
|
|
||
| def __repr__(self): | ||
| return f"Gauge(data_points={self.data_points})" | ||
|
|
||
|
|
||
| class Metric: | ||
| def __init__(self, name, description, unit, data_points, metadata=None): | ||
| self.name = name # Metric name | ||
| self.description = description # Metric description | ||
| self.unit = unit # Metric unit (e.g., seconds, bytes) | ||
| self.data = data # Can be Gauge only | ||
| self.metadata = metadata or {} # Default to an empty dictionary if None | ||
|
|
||
| def __repr__(self): | ||
| return (f"Metric(name={self.name}, description={self.description}, " | ||
| f"unit={self.unit}, data={self.data})") | ||
|
|
||
|
|
||
| # a ScopeMetrics object's ID is device_id | ||
| class ScopeMetrics: | ||
| def __init__(self, device_id): | ||
| self.device_id = device_id | ||
| self.metrics = [] | ||
|
|
||
| def add_metric(self, metric): | ||
| self.metrics.append(metric) | ||
|
|
||
| def __repr__(self): | ||
| return f"ScopeMetrics(scope={self.scope}, metrics={self.metrics})" | ||
|
|
||
|
|
||
| # a ResourceMetrics object's ID is test_run_id | ||
| class ResourceMetrics: | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| def __init__(self, test_run_id, os_version): | ||
sm-xu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| self.test_run_id = test_run_id | ||
| self.os_version = os_version | ||
| self.scope_metrics = [] | ||
|
|
||
| def add_scope_metrics(self, scope_metric): | ||
| self.scope_metrics.append(scope_metric) | ||
|
|
||
| def __repr__(self): | ||
| return f"ResourceMetrics(resource={self.resource}, scope_metrics={self.scope_metrics})" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All common label names are missing too, e.g.: PortId, QueueId, PSUId....
otherwise it will be very hard to create unified dashboard, because each tests could use its own names, and causing problems in filters.