-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inject event management into report engine #36831
base: master
Are you sure you want to change the base?
Conversation
PR #36831: Size comparison from c55e3ab to f44a7a4 Full report (15 builds for bl602, bl702, bl702l, cc32xx, nrfconnect, qpg, stm32, tizen)
|
PR #36831: Size comparison from c55e3ab to d14ef63 Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
PR #36831: Size comparison from c55e3ab to 1851566 Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yyzhong-g at a recent SWTT standup we decided to try once again for stricter "require tests".
Could you please add a "testing" section to describe how this were tested and since I see no unit tests updated or added as part of this PR to explain why this is ok. If manual testing, explain why this cannot be covered by automated tests (there should be a hight bar for saying "manually tested" because otherwise it is a simple escape hatch of saying "tested manually" on every PR).
Added a testing section in the description. Existing unit tests have coverages. |
PR #36831: Size comparison from c55e3ab to 8809618 Full report (69 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
|
@@ -124,6 +124,16 @@ void EventManagement::Init(Messaging::ExchangeManager * apExchangeManager, uint3 | |||
mBytesWritten = 0; | |||
|
|||
mMonotonicStartupTime = aMonotonicStartupTime; | |||
|
|||
// Should remove using the global instance and rely only on passed in variable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here's my question: this Init method is only called in one place, in Server, right? Why do we need to keep backwards compat here? This is not public API....
But it's probably OK to do that in a followup. What needs to happen then is:
- The followup is filed.
- The comment here points to that issue.
- There is a commitment to fix the issue.
@@ -490,7 +500,10 @@ CHIP_ERROR EventManagement::LogEventPrivate(EventLoggingDelegate * apDelegate, c | |||
opts.mTimestamp.mType == Timestamp::Type::kSystem ? "Sys" : "Epoch", ChipLogValueX64(opts.mTimestamp.mValue)); | |||
#endif // CHIP_CONFIG_EVENT_LOGGING_VERBOSE_DEBUG_LOGS | |||
|
|||
err = InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleEventDelivery(opts.mPath, mBytesWritten); | |||
if (mpEventReporter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can this be null? It should never be null.
* @param[in] apEventReporter Event reporter to deliver the event, default is the reporting | ||
* engine in InteractionModelEngine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param[in] apEventReporter Event reporter to deliver the event, default is the reporting | |
* engine in InteractionModelEngine. | |
* @param[in] apEventReporter Event reporter to be notified when events are generated. |
* Define EventReporter interface. Event reporter is used by EventManagement to notify that events are ready to be reported. | ||
* Usually this is implemented by the Reporting Engine to find the proper ReadHandlers and deliver the events. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Define EventReporter interface. Event reporter is used by EventManagement to notify that events are ready to be reported. | |
* Usually this is implemented by the Reporting Engine to find the proper ReadHandlers and deliver the events. | |
* Interface that EventManagement can use to notify when events are generated and may need reporting. |
* Notify of a new event generated. | ||
* | ||
* @param[in] aPath The path to the event. | ||
* @param[in] aBytesWritten Bytes that the event is written into the buffer in EventManagement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Notify of a new event generated. | |
* | |
* @param[in] aPath The path to the event. | |
* @param[in] aBytesWritten Bytes that the event is written into the buffer in EventManagement. | |
* Notify that an event was generated. | |
* | |
* @param[in] aPath The path that identifies the kind of event that was generated. | |
* @param[in] aBytesWritten The number of bytes needed to store the event in EventManagement. |
* @param[in] aPath The path to the event. | ||
* @param[in] aBytesWritten Bytes that the event is written into the buffer in EventManagement. | ||
*/ | ||
CHIP_ERROR virtual NewEventGenerated(ConcreteEventPath & aPath, uint32_t aBytesWritten) = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we properly document aBytesWritten, it becomes clear that it should be called aBytesConsumed or aBytesNeededToStore or aEventSizeInBytes or something.
@@ -126,11 +126,13 @@ class InteractionModelEngine : public Messaging::UnsolicitedMessageHandler, | |||
* @param[in] apExchangeMgr A pointer to the ExchangeManager object. | |||
* @param[in] apFabricTable A pointer to the FabricTable object. | |||
* @param[in] apCASESessionMgr An optional pointer to a CASESessionManager (used for re-subscriptions). | |||
* @parma[in] eventManagement An optional pointer to a EventManagement. Use the global instance if not presented. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @parma[in] eventManagement An optional pointer to a EventManagement. Use the global instance if not presented. | |
* @parma[in] eventManagement An optional pointer to a EventManagement. If null, the global instance will be used. |
* EventReporter implementations. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* EventReporter implementations. | |
* | |
* EventReporter implementation. |
This PR is to decouple EventManagement with IMEngine singleton.
Inject EventManagement into ReportingEngine so it doesn't look for the global instance.
Creates EventScheduler interface (which is implemented by reporting engine) and inject into EventManagement to schedule events.
Created the EventScheduler to avoid both classes depends on each others. Also both classes are injected during Init call and takes the global one if not provided.
This is beneficial and allow us to have in-process testing (e.g. one client and one server running in parallel as different IM engines).
testing: Code changes are tested by existed unit tests, the tests verify that event are generated.