Skip to content
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
4 changes: 4 additions & 0 deletions src/api_manager/service_control/proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ const char kLogFieldNameLogMessage[] = "log_message";
const char kLogFieldNameRequestLatency[] = "request_latency_in_ms";
const char kLogFieldNameUrl[] = "url";
const char kLogFieldNameErrorCause[] = "error_cause";
const char kLogFieldNameClientIp[] = "client_ip";

// Convert timestamp from time_point to Timestamp
Timestamp CreateTimestamp(std::chrono::system_clock::time_point tp) {
Expand Down Expand Up @@ -1083,6 +1084,9 @@ void FillLogEntry(const ReportRequestInfo& info, const std::string& name,
if (!info.method.empty()) {
(*fields)[kLogFieldNameHttpMethod].set_string_value(info.method);
}
if (!info.client_ip.empty()) {
(*fields)[kLogFieldNameClientIp].set_string_value(info.client_ip);
}
if (info.response_code >= 400) {
(*fields)[kLogFieldNameErrorCause].set_string_value(
Status::ErrorCauseToString(info.status.error_cause()));
Expand Down
1 change: 1 addition & 0 deletions src/nginx/t/ServiceControl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ sub gen_log_entry {
$payload->{url} = $in->{url} if exists $in->{url};
$payload->{http_method} = $in->{http_method} if exists $in->{http_method};
$payload->{error_cause} = $in->{error_cause} if exists $in->{error_cause};
$payload->{client_ip} = "127.0.0.1";

my $severity = 'INFO';
if ($in->{response_code} >= 400) {
Expand Down
1 change: 1 addition & 0 deletions src/nginx/t/multiple_apis.t
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ my $expected_report_body = {
'request_size_in_bytes' => 55,
'response_size_in_bytes' => 90,
'http_method' => 'GET',
'client_ip' => '127.0.0.1',
'service_agent' => ServiceControl::service_agent(),
'service_config_id' => '2016-08-25r1'
},
Expand Down