Skip to content

Commit 693f97e

Browse files
Gasoonjiafacebook-github-bot
authored andcommitted
Introduce event_tracer_filter_base class
Summary: This update introduces event_tracer_filter_base class as the base class for delegation intermediate output filtering. Details can be found in #9260 Differential Revision: D71569728
1 parent f721779 commit 693f97e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

runtime/core/event_tracer.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <executorch/runtime/core/array_ref.h>
1010
#include <executorch/runtime/core/evalue.h>
11+
#include <executorch/runtime/core/result.h>
1112
#include <executorch/runtime/platform/platform.h>
1213
#include <stdlib.h>
1314
#include <cstdint>
@@ -67,6 +68,37 @@ enum class EventTracerDebugLogLevel {
6768
kIntermediateOutputs,
6869
};
6970

71+
/**
72+
* EventTracerFilterBase is an abstract base class that provides an interface
73+
* for filtering events based on their name or delegate debug index.
74+
* Derived classes should implement the filter method to define specific
75+
* filtering logic.
76+
*/
77+
class EventTracerFilterBase {
78+
public:
79+
/**
80+
* Filters events based on the given name or delegate debug index.
81+
*
82+
* @param[in] name A pointer to a character array representing the name of the
83+
* event.
84+
* @param[in] delegate_debug_index A DebugHandle representing the debug index
85+
* of the delegate.
86+
*
87+
* @return A Result<bool> indicating whether the event matches the filter
88+
* criteria.
89+
* - True if the event matches the filter.
90+
* - False if the event does not match or is unknown.
91+
* - An error code if an error occurs during filtering.
92+
*/
93+
virtual Result<bool> filter(char* name, DebugHandle delegate_debug_index);
94+
95+
/**
96+
* Virtual destructor for the EventTracerFilterBase class.
97+
* Ensures proper cleanup of derived class objects.
98+
*/
99+
virtual ~EventTracerFilterBase();
100+
};
101+
70102
/**
71103
* Indicates the level of profiling that should be enabled. Profiling
72104
* events will be logged in increasing order of verbosity as we go down the
@@ -443,6 +475,12 @@ class EventTracer {
443475
event_tracer_profiling_level_ = profiling_level;
444476
}
445477

478+
/**
479+
* Set the filter of event tracer for delegation intermediate outputs.
480+
*/
481+
void set_delegation_intermediate_output_filter(
482+
EventTracerFilterBase* event_tracer_filter);
483+
446484
/**
447485
* Return the current level of event tracer profiling.
448486
*/

0 commit comments

Comments
 (0)