Skip to content

Introduce event_tracer_filter_base class #9467

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

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions runtime/core/event_tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <executorch/runtime/core/array_ref.h>
#include <executorch/runtime/core/evalue.h>
#include <executorch/runtime/core/result.h>
#include <executorch/runtime/platform/platform.h>
#include <stdlib.h>
#include <cstdint>
Expand Down Expand Up @@ -67,6 +68,43 @@ enum class EventTracerDebugLogLevel {
kIntermediateOutputs,
};

/**
* EventTracerFilterBase is an abstract base class that provides an interface
* for filtering events based on their name or delegate debug index.
* Derived classes should implement the filter method to define specific
* filtering logic.
*/
class EventTracerFilterBase {
public:
/**
* Filters events based on the given name or delegate debug index.
*
* Note that only one of either the name or delegate_debug_index should be
* passed in.
*
* @param[in] name A pointer to a string representing the `name` of the
* event. If `delegate_debug_index` is not set to kUnsetDebugHandle, `name`
* should be set to nullptr.
*
* @param[in] delegate_debug_index A DebugHandle representing the debug index
* of the delegate. If `name` is not nullptr, this should be set to
* kUnsetDebugHandle.
*
* @return A Result<bool> indicating whether the event matches the filter
* criteria.
* - True if the event matches the filter.
* - False if the event does not match or is unknown.
* - An error code if an error occurs during filtering.
*/
virtual Result<bool> filter(char* name, DebugHandle delegate_debug_index);

/**
* Virtual destructor for the EventTracerFilterBase class.
* Ensures proper cleanup of derived class objects.
*/
virtual ~EventTracerFilterBase();
};

/**
* Indicates the level of profiling that should be enabled. Profiling
* events will be logged in increasing order of verbosity as we go down the
Expand Down Expand Up @@ -443,6 +481,12 @@ class EventTracer {
event_tracer_profiling_level_ = profiling_level;
}

/**
* Set the filter of event tracer for delegation intermediate outputs.
*/
void set_delegation_intermediate_output_filter(
EventTracerFilterBase* event_tracer_filter);

/**
* Return the current level of event tracer profiling.
*/
Expand Down
Loading