Skip to content

feat: log incoming and outgoing packets in built-in bridge#3770

Merged
jarhodes314 merged 1 commit intothin-edge:mainfrom
jarhodes314:feat/bridge-packet-logging
Aug 28, 2025
Merged

feat: log incoming and outgoing packets in built-in bridge#3770
jarhodes314 merged 1 commit intothin-edge:mainfrom
jarhodes314:feat/bridge-packet-logging

Conversation

@jarhodes314
Copy link
Copy Markdown
Contributor

@jarhodes314 jarhodes314 commented Aug 26, 2025

Proposed changes

Adds logging for the packets sent and received by the built-in bridge. It logs connection, subscription and ping related packets. It doesn't log publish or acknowledge packets as this would be very noisy.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s. You can activate automatic signing by running just prepare-dev once)
  • I ran just format as mentioned in CODING_GUIDELINES
  • I used just check as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...s/extensions/tedge_mqtt_bridge/src/mqtt_logging.rs 91.54% 6 Missing ⚠️
crates/extensions/tedge_mqtt_bridge/src/lib.rs 88.23% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Aug 26, 2025

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass % ⏱️ Duration
684 0 3 684 100 2h3m0.511241s

Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

I will be happy to see this PR merged. I just wonder if this wouldn't be better to make consistent all the bridge-related log entries.

Currently we have:

2025-08-27T08:02:07.863413221Z  INFO tedge_mqtt_bridge: Bridge cloud connection still waiting ack for pkid=34
2025-08-27T08:02:07.886647957Z  INFO MQTT bridge: [cloud] Received SUBACK (Subscription Acknowledged): SubAck { pkid: 101, return_codes: [Success(AtLeastOnce)] }

The following would be more consistent:

2025-08-27T08:02:07.863413221Z  INFO MQTT bridge: [cloud] Bridge cloud connection still waiting ack for pkid=34
2025-08-27T08:02:07.886647957Z  INFO MQTT bridge: [cloud] Received SUBACK (Subscription Acknowledged): SubAck { pkid: 101, return_codes: [Success(AtLeastOnce)] }

Comment on lines +148 to +146
Ok(Event::Incoming(Packet::PingReq)) => {
log_event!(self, "Received PINGREQ (Ping Request)");
}
Ok(Event::Incoming(Packet::PingResp)) => {
log_event!(self, "Received PINGRESP (Ping Response)");
}
Ok(Event::Outgoing(Outgoing::PingReq)) => {
log_event!(self, "Sent PINGREQ (Ping Request)");
}
Ok(Event::Outgoing(Outgoing::PingResp)) => {
log_event!(self, "Sent PINGRESP (Ping Response)");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this a bit too verbose?

I would log PING event with a debug level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now done. If the bridge is in use, I wouldn't expect pings to be too frequent, as they're only sent in the case of no other MQTT messages being sent or received, but this is also unlikely to be very frequently useful (unanswered pings are useful to know about, but those will be logged as errors anyway).

@reubenmiller reubenmiller added the theme:troubleshooting Theme: Troubleshooting and remote control label Aug 27, 2025
@jarhodes314 jarhodes314 force-pushed the feat/bridge-packet-logging branch from 0fd8237 to 14e38e8 Compare August 27, 2025 09:08
@jarhodes314 jarhodes314 force-pushed the feat/bridge-packet-logging branch from 14e38e8 to 654b6d4 Compare August 27, 2025 09:27
@jarhodes314 jarhodes314 temporarily deployed to Test Pull Request August 27, 2025 09:27 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@didier-wenzek didier-wenzek left a comment

Choose a reason for hiding this comment

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

Approved

Copy link
Copy Markdown
Member

@rina23q rina23q left a comment

Choose a reason for hiding this comment

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

LGTM

@jarhodes314 jarhodes314 added this pull request to the merge queue Aug 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 27, 2025
@reubenmiller reubenmiller added this pull request to the merge queue Aug 27, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 27, 2025
@jarhodes314 jarhodes314 added this pull request to the merge queue Aug 28, 2025
Merged via the queue into thin-edge:main with commit 86cc7e7 Aug 28, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

theme:troubleshooting Theme: Troubleshooting and remote control

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants