Skip to content

Commit

Permalink
access_log: include dynamic metadata in access logs streamed over gRPC (
Browse files Browse the repository at this point in the history
#4862)

Adds dynamic metadata values set by filters to the access log messages streamed using GrpcAccessLogStreamer.
Risk Level: Low
Testing: Updated unit test.
Docs Changes: N/A
Release Notes: Updated docs/root/intro/version_history.rst.

Signed-off-by: Andrew Schran <[email protected]>
  • Loading branch information
aschran authored and htuch committed Oct 26, 2018
1 parent 7226f82 commit 700b7d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/root/intro/version_history.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Version history
1.9.0 (pending)
===============
* access log: added a :ref:`JSON logging mode <config_access_log_format_dictionaries>` to output access logs in JSON format.
* access log: added dynamic metadata to access log messages streamed over gRPC.
* admin: added support for displaying subject alternate names in :ref:`certs<operations_admin_interface_certs>` end point.
* circuit-breaker: added cx_open, rq_pending_open, rq_open and rq_retry_open gauges to expose live
state via :ref:`circuit breakers statistics <config_cluster_manager_cluster_stats_circuit_breakers>`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers,
// Common log properties.
// TODO(mattklein123): Populate sample_rate field.
// TODO(mattklein123): Populate tls_properties field.
// TODO(mattklein123): Populate metadata field and wire up to filters.
auto* common_properties = log_entry->mutable_common_properties();

if (stream_info.downstreamRemoteAddress() != nullptr) {
Expand Down Expand Up @@ -248,6 +247,9 @@ void HttpGrpcAccessLog::log(const Http::HeaderMap* request_headers,
*stream_info.upstreamLocalAddress(), *common_properties->mutable_upstream_local_address());
}
responseFlagsToAccessLogResponseFlags(*common_properties, stream_info);
if (stream_info.dynamicMetadata().filter_metadata_size() > 0) {
common_properties->mutable_metadata()->MergeFrom(stream_info.dynamicMetadata());
}

if (stream_info.protocol()) {
switch (stream_info.protocol().value()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ TEST_F(HttpGrpcAccessLogTest, Marshalling) {
stream_info.start_time_monotonic_ = MonotonicTime(1h);
stream_info.last_downstream_tx_byte_sent_ = 2ms;
stream_info.setDownstreamLocalAddress(std::make_shared<Network::Address::PipeInstance>("/foo"));
(*stream_info.metadata_.mutable_filter_metadata())["foo"] = ProtobufWkt::Struct();

expectLog(R"EOF(
http_logs:
Expand All @@ -166,6 +167,9 @@ TEST_F(HttpGrpcAccessLogTest, Marshalling) {
seconds: 3600
time_to_last_downstream_tx_byte:
nanos: 2000000
metadata:
filter_metadata:
foo: {}
request: {}
response: {}
)EOF");
Expand Down

0 comments on commit 700b7d0

Please sign in to comment.