Skip to content

Conversation

@hero0307
Copy link
Contributor

@hero0307 hero0307 commented Dec 9, 2025

Purpose

Add the metrics display function to ucm_connector. You can specify which metrics to display on prometheus-grafana by configuring the metrics_configs.yaml file, and these metrics will also be output to the logs.

Modifications

Add three interfaces get_kv_connector_stats, build_kv_connector_stats and build_prom_metrics, as well as two classes UCMKVConnectorStats and UCMPromMetrics to ucm_connector.

Test

prometheus-grafana display
img_v3_02sq_08f22d25-39f7-4d26-b1af-a27559fc90dg
log display
3bb2d29e-f334-42de-ac99-15cd417cde3b

def build_kv_connector_stats(
cls, data: dict[str, Any] | None = None
) -> Optional[KVConnectorStats]:
return UCMDirectConnector.build_kv_connector_stats(data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Must we use specific class here?

self.data[worker_rank][metric_name] = []
self.data[worker_rank][metric_name].extend(values)
else:
# Other is a different type, treat as single worker "0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Will there be other connector's stats aggregate with UCMKVConnectorStats?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


def observe(
self,
transfer_stats_data: dict[str, Any] | KVConnectorStats,
Copy link
Contributor

Choose a reason for hiding this comment

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

Seen KVConnectorPromMetrics define this func like below, why we need to change the params?
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

self,
expected_output: Union[str, List[str], tuple[str]],
real_output: str,
**kwargs
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to add this comma

for worker_data in self.data.values()
)

def aggregate(self, other: KVConnectorStats) -> KVConnectorStats:
Copy link
Contributor

Choose a reason for hiding this comment

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

The excessive nesting depth (five levels) can be simplified by extracting helper functions and streamlining conditional checks. Same as function reduce

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.

2 participants