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

fix: disable log buffering and add more requests stats #10622

Merged
merged 3 commits into from
Jul 30, 2024
Merged
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
8 changes: 4 additions & 4 deletions conf/obf-log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ log4perl.PatternLayout.cspec.J = sub { my $context = Log::Log4perl::MDC->get_con
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/srv/obf/logs/log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.autoflush=0
log4perl.appender.LOGFILE.autoflush=1
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.MONGODB_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.MONGODB_LOGFILE.filename=/srv/obf/logs/mongodb_log4perl.log
log4perl.appender.MONGODB_LOGFILE.mode=append
log4perl.appender.MONGODB_LOGFILE.autoflush=0
log4perl.appender.MONGODB_LOGFILE.autoflush=1
log4perl.appender.MONGODB_LOGFILE.layout=PatternLayout
log4perl.appender.MONGODB_LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.RATELIMITER_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.RATELIMITER_LOGFILE.filename=/srv/obf/logs/ratelimiter_log4perl.log
log4perl.appender.RATELIMITER_LOGFILE.mode=append
log4perl.appender.RATELIMITER_LOGFILE.autoflush=0
log4perl.appender.RATELIMITER_LOGFILE.autoflush=1
log4perl.appender.RATELIMITER_LOGFILE.layout=PatternLayout
log4perl.appender.RATELIMITER_LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.REQUESTSTATS_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.REQUESTSTATS_LOGFILE.filename=/srv/obf/logs/requeststats_log4perl.log
log4perl.appender.REQUESTSTATS_LOGFILE.mode=append
log4perl.appender.REQUESTSTATS_LOGFILE.autoflush=0
log4perl.appender.REQUESTSTATS_LOGFILE.autoflush=1
log4perl.appender.REQUESTSTATS_LOGFILE.layout=PatternLayout
log4perl.appender.REQUESTSTATS_LOGFILE.layout.ConversionPattern=%J %n
9 changes: 5 additions & 4 deletions conf/off-log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ log4perl.PatternLayout.cspec.J = sub { my $context = Log::Log4perl::MDC->get_con
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/srv/off/logs/log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.autoflush=0
# note: autoflush=0 results in multiple log entries being mixed (probably because there are several Apache processes writing to the same file)
log4perl.appender.LOGFILE.autoflush=1
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.MONGODB_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.MONGODB_LOGFILE.filename=/srv/off/logs/mongodb_log4perl.log
log4perl.appender.MONGODB_LOGFILE.mode=append
log4perl.appender.MONGODB_LOGFILE.autoflush=0
log4perl.appender.MONGODB_LOGFILE.autoflush=1
log4perl.appender.MONGODB_LOGFILE.layout=PatternLayout
log4perl.appender.MONGODB_LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.RATELIMITER_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.RATELIMITER_LOGFILE.filename=/srv/off/logs/ratelimiter_log4perl.log
log4perl.appender.RATELIMITER_LOGFILE.mode=append
log4perl.appender.RATELIMITER_LOGFILE.autoflush=0
log4perl.appender.RATELIMITER_LOGFILE.autoflush=1
log4perl.appender.RATELIMITER_LOGFILE.layout=PatternLayout
log4perl.appender.RATELIMITER_LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n

log4perl.appender.REQUESTSTATS_LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.REQUESTSTATS_LOGFILE.filename=/srv/off/logs/requeststats_log4perl.log
log4perl.appender.REQUESTSTATS_LOGFILE.mode=append
log4perl.appender.REQUESTSTATS_LOGFILE.autoflush=0
log4perl.appender.REQUESTSTATS_LOGFILE.autoflush=1
log4perl.appender.REQUESTSTATS_LOGFILE.layout=PatternLayout
log4perl.appender.REQUESTSTATS_LOGFILE.layout.ConversionPattern=%J %n
2 changes: 1 addition & 1 deletion conf/off-minion_log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ log4perl.PatternLayout.cspec.S = sub { my $context = Log::Log4perl::MDC->get_con
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/srv/off/logs/minion_log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.autoflush=0
log4perl.appender.LOGFILE.autoflush=1
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%r] %F %L %c %S %m{chomp}%n
2 changes: 1 addition & 1 deletion conf/off-pro-log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ log4perl.PatternLayout.cspec.S = sub { my $context = Log::Log4perl::MDC->get_con
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/mnt/off-pro/logs/off-pro/log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.autoflush=0
log4perl.appender.LOGFILE.autoflush=1
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%d] %F %L %c %S %m{chomp}%n
2 changes: 1 addition & 1 deletion conf/off-pro-minion_log.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ log4perl.PatternLayout.cspec.S = sub { my $context = Log::Log4perl::MDC->get_con
log4perl.appender.LOGFILE=Log::Log4perl::Appender::File
log4perl.appender.LOGFILE.filename=/mnt/off-pro/logs/off-pro/minion_log4perl.log
log4perl.appender.LOGFILE.mode=append
log4perl.appender.LOGFILE.autoflush=0
log4perl.appender.LOGFILE.autoflush=1
log4perl.appender.LOGFILE.layout=PatternLayout
log4perl.appender.LOGFILE.layout.ConversionPattern=[%r] %F %L %c %S %m{chomp}%n
2 changes: 2 additions & 0 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@ CSS
}
) if $log->is_debug();

set_request_stats_value($request_ref->{stats}, "cc", $request_ref->{cc});
set_request_stats_value($request_ref->{stats}, "lc", $request_ref->{lc});
set_request_stats_value($request_ref->{stats}, "hostname", $hostname);
set_request_stats_value($request_ref->{stats}, "original_query_string", $request_ref->{original_query_string});
set_request_stats_value($request_ref->{stats}, "ip", remote_addr());
Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/RequestStats.pm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ sub init_request_stats() {

my $stats_ref = {};
set_request_stats_time_start($stats_ref, "request");
set_request_stats_value($stats_ref, "request_t", time());
set_request_stats_value($stats_ref, "pid", $$);
return $stats_ref;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/ProductOpener/Routing.pm
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ sub api_route($request_ref, @components) {

set_request_stats_value($request_ref->{stats}, "route", "api");
set_request_stats_value($request_ref->{stats}, "api_action", $request_ref->{api_action});
set_request_stats_value($request_ref->{stats}, "api_method", $request_ref->{api_method});
set_request_stats_value($request_ref->{stats}, "api_version", $request_ref->{api_version});

return 1;
}
Expand Down
Loading