Skip to content

Commit 108924a

Browse files
r12fyutongzhang-microsoft
authored andcommitted
Redesign and implement the telemetry framework (sonic-net#20387)
What is the motivation for this PR? The current telemetry framework has many serious problems: Hard to import, because it is outside of the tests folder No implementation, hard to try out Hard to use and extend, because the interface is too primitive No tests and can break easily How did you do it? This PR add a few things to improve the current telemetry framework: Add new design doc with example code provided in the doc. Implement both TS (timeseries) and DB (database) reporter, so we can try the feature easily. How did you verify/test it? Run all tests locally and passed. Any platform specific information? N/A. Fix TS reporters. Fix TSRepoter. Fix TS reporter. minor fix. Fix example. Reverse relationship of metrics and reporter to support more types of metrics in future. Remove bydesign not working test. Fix example. Update tests. Update TS reporter and DB repoter. Update minor things. Remove no required code. Revert unexpected change. Rename and update doc. * Get os version and job id (sonic-net#1) Get os version and elastictest job id from correct place. * Revert OS version change. * Remove duplicated mock reporter fixture. --------- Co-authored-by: Yutong Zhang <[email protected]> Signed-off-by: Lakshmi Yarramaneni <[email protected]>
1 parent 339377a commit 108924a

42 files changed

Lines changed: 4004 additions & 128 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/tests/telemetry.md

Lines changed: 369 additions & 0 deletions
Large diffs are not rendered by default.

test_reporting/telemetry/README.md

Lines changed: 0 additions & 128 deletions
This file was deleted.
-85.4 KB
Binary file not shown.

tests/common/telemetry/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Telemetry Utils
2+
3+
Please refer to [SONiC Mgmt Test Telemetry Framework](../../../docs/tests/telemetry.md) design doc.

tests/common/telemetry/__init__.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"""
2+
SONiC Mgmt Test Telemetry Framework
3+
4+
"""
5+
6+
# Base classes
7+
from .base import Reporter, Metric, MetricCollection, MetricDefinition
8+
9+
# Metric types
10+
from .metrics import GaugeMetric, HistogramMetric
11+
12+
# Reporters
13+
from .reporters import TSReporter, DBReporter
14+
15+
# Device metric collections
16+
from .metrics.device import (
17+
DevicePortMetrics, DevicePSUMetrics, DeviceQueueMetrics,
18+
DeviceTemperatureMetrics, DeviceFanMetrics
19+
)
20+
21+
# Constants and labels
22+
from .constants import (
23+
# Common Labels
24+
METRIC_LABEL_DEVICE_ID, METRIC_LABEL_DEVICE_PORT_ID, METRIC_LABEL_DEVICE_PSU_ID,
25+
METRIC_LABEL_DEVICE_QUEUE_ID, METRIC_LABEL_DEVICE_SENSOR_ID, METRIC_LABEL_DEVICE_FAN_ID,
26+
27+
# Port Metrics
28+
METRIC_NAME_PORT_RX_BPS, METRIC_NAME_PORT_TX_BPS, METRIC_NAME_PORT_RX_UTIL, METRIC_NAME_PORT_TX_UTIL,
29+
30+
# PSU Metrics
31+
METRIC_NAME_PSU_VOLTAGE, METRIC_NAME_PSU_CURRENT, METRIC_NAME_PSU_POWER,
32+
33+
# BGP Metrics
34+
METRIC_NAME_BGP_CONVERGENCE_TIME_PORT_RESTART,
35+
36+
# Units
37+
UNIT_SECONDS, UNIT_BYTES_PER_SECOND, UNIT_PERCENT, UNIT_COUNT
38+
)
39+
40+
# Pytest fixtures (imported for convenience, but should be used via conftest.py)
41+
from .fixtures import ts_reporter, db_reporter
42+
43+
# Version information
44+
__version__ = "1.0.0"
45+
46+
# Public API - define what gets imported with "from common.telemetry import *"
47+
__all__ = [
48+
# Base classes
49+
'Reporter', 'Metric', 'MetricCollection', 'MetricDefinition',
50+
51+
# Metric types
52+
'GaugeMetric', 'HistogramMetric',
53+
54+
# Reporters
55+
'TSReporter', 'DBReporter',
56+
57+
# Device metrics
58+
'DevicePortMetrics', 'DevicePSUMetrics', 'DeviceQueueMetrics',
59+
'DeviceTemperatureMetrics', 'DeviceFanMetrics',
60+
61+
# Essential constants
62+
'METRIC_LABEL_DEVICE_ID', 'METRIC_LABEL_DEVICE_PORT_ID', 'METRIC_LABEL_DEVICE_PSU_ID',
63+
'METRIC_LABEL_DEVICE_QUEUE_ID', 'METRIC_LABEL_DEVICE_SENSOR_ID', 'METRIC_LABEL_DEVICE_FAN_ID',
64+
65+
# Port metric names
66+
'METRIC_NAME_PORT_RX_BPS', 'METRIC_NAME_PORT_TX_BPS', 'METRIC_NAME_PORT_RX_UTIL', 'METRIC_NAME_PORT_TX_UTIL',
67+
68+
# PSU metric names
69+
'METRIC_NAME_PSU_VOLTAGE', 'METRIC_NAME_PSU_CURRENT', 'METRIC_NAME_PSU_POWER',
70+
71+
# BGP metric names
72+
'METRIC_NAME_BGP_CONVERGENCE_TIME_PORT_RESTART',
73+
74+
# Common units
75+
'UNIT_SECONDS', 'UNIT_PERCENT', 'UNIT_COUNT', 'UNIT_BYTES_PER_SECOND',
76+
77+
# Pytest fixtures
78+
'ts_reporter', 'db_reporter'
79+
]

0 commit comments

Comments
 (0)