Skip to content
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

Feat: include class and function in trace performance #317

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ seaslog.trace_performance_start_depth = 1
;Performance Tracking Depth Level. 5(Default)
seaslog.trace_performance_max_depth = 5

;Performance trace namespace/class filtering, empty default, multiple values concatenated with a comma (used to limit the scope of the class trace, the following example will trace App\xxoo or Service\xxoo, commonly used in frameworks, specifying the trace namespace)
seaslog.trace_performance_include_class_prefix=App,Services

;Performance trace Function name filter, default null, multiple values concatenated with a comma (used to limit the scope of Function tracing for non-class members, the following example will trace only two functions, config() and app()).
seaslog.trace_performance_include_function_prefix=config,app

;Maximum number of functions per layer in descending order of wall_time for performance tracking.
;Top default top5
seaslog.trace_performance_max_functions_per_depth = 5
Expand Down
6 changes: 6 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ seaslog.trace_performance_start_depth = 1
;性能追踪时深度层级 默认5层
seaslog.trace_performance_max_depth = 5

;性能追踪 命名空间/类 过滤,默认为空,多个值用半角逗号连接(用于限定类追踪范围,下面示例将会追踪 App\xxoo 或 Service\xxoo,常用于框架,指定追踪命名空间)
seaslog.trace_performance_include_class_prefix=App,Services

;性能追踪 函数名 过滤,默认为空,多个值用半角逗号连接(用于限定非类成员Function追踪范围,下面示例只会追踪 config() 和 app() 两个Function)
seaslog.trace_performance_include_function_prefix=config,app

;性能追踪时每层的函数最大数 按wall_time降序排列top 默认top5
seaslog.trace_performance_max_functions_per_depth = 5

Expand Down
4 changes: 4 additions & 0 deletions include/Performance.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ void seaslog_peak_memory_usage(smart_str *buf TSRMLS_DC);
void init_zend_hooks(TSRMLS_D);
void recovery_zend_hooks(TSRMLS_D);

void init_performance(TSRMLS_D);
void clear_performance(TSRMLS_D);
void include_prefix_list(char *include_str, int *res_include_list_count, char ***res_include_list TSRMLS_DC);

void seaslog_rinit_performance(TSRMLS_D);
void seaslog_clear_performance(zend_class_entry *ce TSRMLS_DC);
int seaslog_check_performance_active(TSRMLS_D);
Expand Down
6 changes: 6 additions & 0 deletions php_seaslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ ZEND_BEGIN_MODULE_GLOBALS(seaslog)
zend_bool trace_error;
zend_bool trace_exception;

int trace_performance_include_class_prefix_count;
int trace_performance_include_function_prefix_count;
char *trace_performance_include_class_prefix;
char *trace_performance_include_function_prefix;
char **trace_performance_include_class_prefix_list;
char **trace_performance_include_function_prefix_list;
int trace_performance_active;
int trace_performance_sample_active;
zend_bool trace_performance;
Expand Down
5 changes: 5 additions & 0 deletions seaslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ STD_PHP_INI_BOOLEAN("seaslog.throw_exception", "1", PHP_INI_ALL, OnUpdateBool, t
STD_PHP_INI_BOOLEAN("seaslog.ignore_warning", "1", PHP_INI_ALL, OnUpdateBool, ignore_warning, zend_seaslog_globals, seaslog_globals)

STD_PHP_INI_BOOLEAN("seaslog.trace_performance", "0", PHP_INI_SYSTEM, OnUpdateBool, trace_performance, zend_seaslog_globals, seaslog_globals)
STD_PHP_INI_ENTRY("seaslog.trace_performance_include_class_prefix", "", PHP_INI_ALL, OnUpdateString, trace_performance_include_class_prefix, zend_seaslog_globals, seaslog_globals)
STD_PHP_INI_ENTRY("seaslog.trace_performance_include_function_prefix", "", PHP_INI_ALL, OnUpdateString, trace_performance_include_function_prefix, zend_seaslog_globals, seaslog_globals)
STD_PHP_INI_ENTRY("seaslog.trace_performance_sample_rate", "10", PHP_INI_ALL, OnUpdateLongGEZero, trace_performance_sample_rate, zend_seaslog_globals, seaslog_globals)
STD_PHP_INI_ENTRY("seaslog.trace_performance_start_depth", "1", PHP_INI_ALL, OnUpdateLongGEZero, trace_performance_start_depth, zend_seaslog_globals, seaslog_globals)
STD_PHP_INI_ENTRY("seaslog.trace_performance_max_depth", "5", PHP_INI_ALL, OnUpdateLongGEZero, trace_performance_max_depth, zend_seaslog_globals, seaslog_globals)
Expand Down Expand Up @@ -315,12 +317,15 @@ PHP_MINIT_FUNCTION(seaslog)
init_buffer_switch(TSRMLS_C);
init_remote_timeout(TSRMLS_C);
init_zend_hooks(TSRMLS_C);
init_performance(TSRMLS_C);

return SUCCESS;
}

PHP_MSHUTDOWN_FUNCTION(seaslog)
{
clear_performance(TSRMLS_C);

recovery_error_hooks(TSRMLS_C);
recovery_exception_hooks(TSRMLS_C);
recovery_zend_hooks(TSRMLS_C);
Expand Down
Loading