Skip to content

Fix topic statistics source collision for multiple subscriptions#3171

Open
Saigirish23 wants to merge 1 commit into
ros2:rollingfrom
Saigirish23:fix/topic-stats-rolling
Open

Fix topic statistics source collision for multiple subscriptions#3171
Saigirish23 wants to merge 1 commit into
ros2:rollingfrom
Saigirish23:fix/topic-stats-rolling

Conversation

@Saigirish23
Copy link
Copy Markdown

Description

When topic statistics are enabled for multiple subscriptions within the same node,
all statistics messages currently use the same measurement_source_name
because SubscriptionTopicStatistics only uses the node name when constructing
the source identifier.

This makes it difficult to determine which subscription produced a particular
statistics message when a node subscribes to multiple topics.

This PR addresses the issue by including the subscribed topic name in the
statistics source identifier. The resulting identifier is constructed as
node_name/topic_name, allowing statistics from different subscriptions within
the same node to be distinguished.

Changes included in this PR:

  • Update SubscriptionTopicStatistics to accept the subscribed topic name.
  • Construct the statistics source identifier using both the node name and topic name.
  • Update the subscription creation path to pass the topic name when topic statistics are enabled.
  • Update existing tests affected by the constructor change.
  • Add a regression test (test_multiple_subscriptions_differentiated) to verify that statistics generated by multiple subscriptions in the same node have distinct source identifiers.

Fixes #2756

Is this user-facing behavior change?

Yes.

When topic statistics are enabled, statistics messages published on
/statistics will now contain unique measurement_source_name values for
different subscriptions within the same node. This makes it possible to
correctly identify which subscription produced a given statistics message.

Did you use Generative AI?

Yes.

I used ChatGPT (GPT-5.5) to assist with investigating the issue, discussing
possible implementation approaches, reviewing code changes, and drafting parts
of the regression test and PR description. All code changes, testing, and final
content were reviewed and validated manually.

Additional Information

A similar fix was initially proposed for the Humble branch, but it could not be
merged because the required constructor change introduces an API change that is
not suitable for a stable release. This PR targets the Rolling branch, where
such changes are permitted.

Signed-off-by: Saigirish23 <b24me1066@iitj.ac.in>
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.

Topic Statistics for multiple subscriptions in same node aren't differentiated

1 participant