Skip to content

Commit a828307

Browse files
authored
Introduce event_tracer_filter_base class
Differential Revision: D71569728 Pull Request resolved: #9467
1 parent ce7aedf commit a828307

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

runtime/core/event_tracer.h

Lines changed: 44 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,43 @@ 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+
* Note that only one of either the name or delegate_debug_index should be
83+
* passed in.
84+
*
85+
* @param[in] name A pointer to a string representing the `name` of the
86+
* event. If `delegate_debug_index` is not set to kUnsetDebugHandle, `name`
87+
* should be set to nullptr.
88+
*
89+
* @param[in] delegate_debug_index A DebugHandle representing the debug index
90+
* of the delegate. If `name` is not nullptr, this should be set to
91+
* kUnsetDebugHandle.
92+
*
93+
* @return A Result<bool> indicating whether the event matches the filter
94+
* criteria.
95+
* - True if the event matches the filter.
96+
* - False if the event does not match or is unknown.
97+
* - An error code if an error occurs during filtering.
98+
*/
99+
virtual Result<bool> filter(char* name, DebugHandle delegate_debug_index);
100+
101+
/**
102+
* Virtual destructor for the EventTracerFilterBase class.
103+
* Ensures proper cleanup of derived class objects.
104+
*/
105+
virtual ~EventTracerFilterBase();
106+
};
107+
70108
/**
71109
* Indicates the level of profiling that should be enabled. Profiling
72110
* events will be logged in increasing order of verbosity as we go down the
@@ -443,6 +481,12 @@ class EventTracer {
443481
event_tracer_profiling_level_ = profiling_level;
444482
}
445483

484+
/**
485+
* Set the filter of event tracer for delegation intermediate outputs.
486+
*/
487+
void set_delegation_intermediate_output_filter(
488+
EventTracerFilterBase* event_tracer_filter);
489+
446490
/**
447491
* Return the current level of event tracer profiling.
448492
*/

0 commit comments

Comments
 (0)