Improvement: Add tracing for subscription-states#678
Conversation
87f92e0 to
1f1481e
Compare
|
The required CI workflows appear to be awaiting maintainer approval before execution. Could one of the maintainers please approve the workflow run |
|
@Rutuja-Patil-Bosch can you pleaes clean up the git history of this PR? To have only your changes included and no merge commits? |
|
Can you then please also add necessary tests for the added code? Then a more in depth review makes sense. I will mark the PR as draft in the meantime - please feel free to mark it again ready. |
@castler : Yes, test cases are ready. I'll rebase the PR so that no merged commit will be visible & will commit test cases also |
There was a problem hiding this comment.
Pull request overview
Adds proxy-side tracing support for subscription-state related operations so the tracing runtime can emit the configured tracepoints for state changes and subscription-state-change handler lifecycle/callbacks.
Changes:
- Added new proxy tracing entry points for subscription state change and handler register/deregister/callback tracepoints.
- Wired
ProxyEventBase::{Set,Unset}SubscriptionStateChangeHandler()to emit tracing when called. - Updated
comtrace_config_schema.jsonto indicate LoLa support for the previously unimplemented tracepoints.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| score/mw/com/impl/tracing/proxy_event_tracing.h | Declares new tracing functions for subscription-state tracepoints. |
| score/mw/com/impl/tracing/proxy_event_tracing.cpp | Implements new tracepoint emitters (state changed, handler register/deregister, handler callback). |
| score/mw/com/impl/tracing/configuration/comtrace_config_schema.json | Removes _lola_support: false markers for subscription-state tracepoints in proxy-side config sections. |
| score/mw/com/impl/proxy_event_base.cpp | Calls tracing on subscription-state-change handler register/deregister. |
Comments suppressed due to low confidence (1)
score/mw/com/impl/proxy_event_base.cpp:169
- The new null-check only guards the trace call, but the function still unconditionally dereferences binding_base_. This is inconsistent with the check and can still crash when the binding is invalid. Also, unlike most other ProxyEventBase APIs, this method does not delegate to proxy_event_base_mock_ when a mock is injected.
if (binding_base_ != nullptr)
{
tracing::TraceUnsetSubscriptionStateChangeHandler(tracing_data_, *binding_base_);
}
return binding_base_->UnsetSubscriptionStateChangeHandler();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Result<void> ProxyEventBase::SetSubscriptionStateChangeHandler(SubscriptionStateChangeHandler handler) noexcept | ||
| { | ||
| if (binding_base_ != nullptr) | ||
| { | ||
| tracing::TraceSetSubscriptionStateChangeHandler(tracing_data_, *binding_base_); | ||
| } | ||
| return binding_base_->SetSubscriptionStateChangeHandler(std::move(handler)); | ||
| } |
| void TraceSubscriptionStateChanged(ProxyEventTracingData& proxy_event_tracing_data, | ||
| const ProxyEventBindingBase& proxy_event_binding_base, | ||
| SubscriptionState new_state) noexcept | ||
| { | ||
| if (proxy_event_tracing_data.enable_subscription_state_changed) |
| void TraceCallSubscriptionStateChangeHandler(ProxyEventTracingData& proxy_event_tracing_data, | ||
| const ProxyEventBindingBase& proxy_event_binding_base, | ||
| SubscriptionState new_state) noexcept | ||
| { | ||
| if (proxy_event_tracing_data.enable_call_subscription_state_change_handler) |
| void TraceSetSubscriptionStateChangeHandler(ProxyEventTracingData& proxy_event_tracing_data, | ||
| const ProxyEventBindingBase& proxy_event_binding_base) noexcept | ||
| { | ||
| if (proxy_event_tracing_data.enable_set_subcription_state_change_handler) | ||
| { |
0dfeff2 to
1b69f0e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
score/mw/com/impl/proxy_event_base.cpp:160
- The null-check around tracing does not prevent dereferencing binding_base_; if binding_base_ is ever null (e.g. moved-from object), this still crashes, and the guard makes the code look safer than it is. Either assert binding_base_ is set (consistent with other methods) or return an error when it is null.
if (binding_base_ != nullptr)
{
tracing::TraceSetSubscriptionStateChangeHandler(tracing_data_, *binding_base_);
}
return binding_base_->SetSubscriptionStateChangeHandler(std::move(handler));
score/mw/com/impl/proxy_event_base.cpp:169
- Same as SetSubscriptionStateChangeHandler(): the tracing guard checks binding_base_ for null, but the method still unconditionally dereferences binding_base_ afterwards. Prefer an assertion (or early error return) and then trace/call the binding.
if (binding_base_ != nullptr)
{
tracing::TraceUnsetSubscriptionStateChangeHandler(tracing_data_, *binding_base_);
}
return binding_base_->UnsetSubscriptionStateChangeHandler();
score/mw/com/impl/tracing/proxy_event_tracing.cpp:421
- TraceSubscriptionStateChanged() and TraceCallSubscriptionStateChangeHandler() are added, but there are currently no call sites for either helper in the codebase. This means the tracepoints "trace_subscription_state_changed" and "trace_subscription_state_change_handler_callback" will still never be emitted (despite being enabled in config/schema).
void TraceSubscriptionStateChanged(ProxyEventTracingData& proxy_event_tracing_data,
const ProxyEventBindingBase& proxy_event_binding_base,
SubscriptionState new_state) noexcept
{
if (proxy_event_tracing_data.enable_subscription_state_changed)
score/mw/com/impl/tracing/proxy_event_tracing.cpp:420
- There are existing unit tests for other proxy event tracing helpers (e.g. TraceSubscribe/TraceUnsubscribe), but the newly added subscription-state trace helpers are not covered. Adding UTs would help validate the correct trace point selection (event vs field) and that the local data chunk contains the 1-byte SubscriptionState value for the *_changed and *_callback tracepoints.
void TraceSubscriptionStateChanged(ProxyEventTracingData& proxy_event_tracing_data,
const ProxyEventBindingBase& proxy_event_binding_base,
SubscriptionState new_state) noexcept
{
#449