Skip to content

Commit

Permalink
pw_bluetooth_sapphire: Add LE L2CAP channel request metric
Browse files Browse the repository at this point in the history
Add an Inspect metrics for LE L2CAP channel requests.

Test: Builds
Change-Id: Iacebb12b7280d44bbc29f671c4ab81067a67240c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/262432
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Jason Graffius <[email protected]>
Commit-Queue: Josh Conner <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
  • Loading branch information
josh-conner authored and CQ Bot Account committed Jan 23, 2025
1 parent 769e458 commit aa3dd95
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pw_bluetooth_sapphire/host/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ adapter:
set_connectable_false_events
set_connectable_true_events
le:
open_l2cap_channel_requests
outgoing_connection_requests
pair_requests
start_advertising_events
Expand Down
4 changes: 4 additions & 0 deletions pw_bluetooth_sapphire/host/gap/adapter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class AdapterImpl final : public Adapter {
l2cap::ChannelParameters params,
sm::SecurityLevel security_level,
l2cap::ChannelCallback cb) override {
adapter_->metrics_.le.open_l2cap_channel_requests.Add();
adapter_->le_connection_manager_->OpenL2capChannel(
peer_id, psm, params, security_level, std::move(cb));
}
Expand Down Expand Up @@ -509,6 +510,7 @@ class AdapterImpl final : public Adapter {
inspect::Node metrics_le_node_;
struct AdapterMetrics {
struct LeMetrics {
UintMetricCounter open_l2cap_channel_requests;
UintMetricCounter outgoing_connection_requests;
UintMetricCounter pair_requests;
UintMetricCounter start_advertising_events;
Expand Down Expand Up @@ -852,6 +854,8 @@ void AdapterImpl::AttachInspect(inspect::Node& parent, std::string name) {
metrics_node_ = adapter_node_.CreateChild(kMetricsInspectNodeName);

metrics_le_node_ = metrics_node_.CreateChild("le");
metrics_.le.open_l2cap_channel_requests.AttachInspect(
metrics_le_node_, "open_l2cap_channel_requests");
metrics_.le.outgoing_connection_requests.AttachInspect(
metrics_le_node_, "outgoing_connection_requests");
metrics_.le.pair_requests.AttachInspect(metrics_le_node_, "pair_requests");
Expand Down
1 change: 1 addition & 0 deletions pw_bluetooth_sapphire/host/gap/adapter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,7 @@ TEST_F(AdapterTest, InspectHierarchy) {
auto le_matcher =
AllOf(NodeMatches(AllOf(NameMatches("le"),
PropertyList(UnorderedElementsAre(
UintIs("open_l2cap_channel_requests", 0),
UintIs("outgoing_connection_requests", 0),
UintIs("pair_requests", 0),
UintIs("start_advertising_events", 0),
Expand Down

0 comments on commit aa3dd95

Please sign in to comment.