Skip to content
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
7 changes: 4 additions & 3 deletions runtime/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,9 @@ void f$flush() {
}
string_buffer const* http_body = compress_http_query_body(&oub[ob_system_level]);
string_buffer const* http_headers = nullptr;
if (!php_worker->flushed_http_connection) {
if (!php_worker->flushed_http_code) {
http_headers = get_headers();
php_worker->flushed_http_connection = true;
php_worker->flushed_http_code = http_return_code;
}
http_send_immediate_response(http_headers ? http_headers->buffer() : nullptr, http_headers ? http_headers->size() : 0, http_body->buffer(),
http_body->size());
Expand All @@ -612,7 +612,7 @@ void f$fastcgi_finish_request(int64_t exit_code) {
headers_sent = true;
}
int ob_total_buffer = ob_merge_buffers();
if (php_worker.has_value() && php_worker->flushed_http_connection) {
if (php_worker.has_value() && php_worker->flushed_http_code) {
string const raw_response = oub[ob_total_buffer].str();
http_set_result(nullptr, 0, raw_response.c_str(), raw_response.size(), static_cast<int32_t>(exit_code));
php_assert(0);
Expand Down Expand Up @@ -640,6 +640,7 @@ void f$fastcgi_finish_request(int64_t exit_code) {
set_content_length_header(compressed->size());
}
const string_buffer* headers = get_headers();
php_worker->flushed_http_code = http_return_code;
http_set_result(headers->buffer(), headers->size(), compressed->buffer(), compressed->size(), static_cast<int32_t>(exit_code));

break;
Expand Down
4 changes: 2 additions & 2 deletions server/php-worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ void PhpWorker::state_run() noexcept {
if (conn != nullptr) {
switch (mode) {
case http_worker:
if (!flushed_http_connection) {
if (!flushed_http_code) {
http_return(conn, "ERROR", 5);
}
break;
Expand Down Expand Up @@ -448,7 +448,7 @@ PhpWorker::PhpWorker(php_worker_mode_t mode_, connection *c, php_query_data_t qu
: conn(c)
, data(std::move(query_data))
, paused(false)
, flushed_http_connection(false)
, flushed_http_code(0)
, terminate_flag(false)
, terminate_reason(script_error_t::unclassified_error)
, error_message("no error")
Expand Down
2 changes: 1 addition & 1 deletion server/php-worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class PhpWorker {
php_query_data_t data;

bool paused;
bool flushed_http_connection;
int flushed_http_code;
bool terminate_flag;
script_error_t terminate_reason;
const char *error_message;
Expand Down
2 changes: 1 addition & 1 deletion server/server-stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void ServerStats::add_request_stats(double script_time_sec, double net_time_sec,
stats.add_request_stats(queries_stat, error, script_memory_stats, curl_total_allocated);
shared_stats_->workers.add_worker_stats(queries_stat, worker_process_id_);

StatsHouseManager::get().add_request_stats(script_time.count(), net_time.count(), script_max_running_interval.count(), error, script_memory_stats, builtin_stats, script_queries, long_script_queries,
StatsHouseManager::get().add_request_stats(script_time.count(), net_time.count(), script_max_running_interval.count(), php_worker->flushed_http_code, error, script_memory_stats, builtin_stats, script_queries, long_script_queries,
script_user_time.count(), script_system_time.count(),
script_init_time.count(), http_connection_process_time.count(),
script_rusage.voluntary_context_switches, script_rusage.involuntary_context_switches);
Expand Down
6 changes: 3 additions & 3 deletions server/statshouse/statshouse-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void StatsHouseManager::generic_cron_check_if_tag_host_needed() {
}
}

void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, uint64_t script_max_running_interval_ns, script_error_t error,
void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, uint64_t script_max_running_interval_ns, int flushed_http_code, script_error_t error,
const memory_resource::MemoryStats &script_memory_stats, const std::optional<runtime_builtins_stats::request_stats_t> &builtin_stats,
uint64_t script_queries, uint64_t long_script_queries,
uint64_t script_user_time_ns, uint64_t script_system_time_ns,
Expand All @@ -126,7 +126,7 @@ void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_
client.metric("kphp_request_cpu_time").tag("system").tag(worker_type).tag(status).write_value(script_system_time_ns);
client.metric("kphp_request_init_time").tag(worker_type).tag(status).write_value(script_init_time);
if (process_type == ProcessType::http_worker) {
client.metric("kphp_http_connection_process_time").tag(status).write_value(http_connection_process_time);
client.metric("kphp_http_connection_process_time").tag("flushed_http_code", std::to_string(flushed_http_code)).tag(status).write_value(http_connection_process_time);
}

client.metric("kphp_by_host_request_time", true).tag("script").tag(worker_type).write_value(script_time_ns);
Expand All @@ -135,7 +135,7 @@ void StatsHouseManager::add_request_stats(uint64_t script_time_ns, uint64_t net_
client.metric("kphp_by_host_request_cpu_time", true).tag("system").tag(worker_type).tag(status).write_value(script_system_time_ns);
client.metric("kphp_by_host_request_init_time", true).tag(worker_type).tag(status).write_value(script_init_time);
if (process_type == ProcessType::http_worker) {
client.metric("kphp_by_host_http_connection_process_time", true).tag(status).write_value(http_connection_process_time);
client.metric("kphp_by_host_http_connection_process_time", true).tag("flushed_http_code", std::to_string(flushed_http_code)).tag(status).write_value(http_connection_process_time);
}

if (error != script_error_t::no_error) {
Expand Down
2 changes: 1 addition & 1 deletion server/statshouse/statshouse-manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class StatsHouseManager : vk::not_copyable {
return this->instance_cache_key_normalization_function != nullptr;
}

void add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, uint64_t script_max_running_interval_ns, script_error_t error,
void add_request_stats(uint64_t script_time_ns, uint64_t net_time_ns, uint64_t script_max_running_interval_ns, int flushed_http_code, script_error_t error,
const memory_resource::MemoryStats &script_memory_stats, const std::optional<runtime_builtins_stats::request_stats_t> &builtin_stats,
uint64_t script_queries, uint64_t long_script_queries,
uint64_t script_user_time_ns, uint64_t script_system_time_ns,
Expand Down
Loading