access_log: add extension filter to allow runtime filter registration.#7435
access_log: add extension filter to allow runtime filter registration.#7435mattklein123 merged 27 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Misha Efimov <mef@chromium.org>
|
This is a WIP of my first PR, and it is NOT ready for review yet. |
|
Thanks @efimki. I will take a look when you are ready! /wait |
…xtension Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
|
I think it is now ready for review. This is my first Envoy PR, so I apologize if I've missed something. |
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
efimki
left a comment
There was a problem hiding this comment.
Hi Auni, thanks for your comments!
I've addressed them, PTAL.
|
@junr03 Could you take a look when you have a chance? I'll appreciate your input. Thanks in advance! |
…xtension Signed-off-by: Misha Efimov <mef@google.com>
|
sorry for the delay. Will get to this today |
| // Custom configuration that depends on the filter being instantiated. | ||
| oneof config_type { | ||
| google.protobuf.Struct config = 2; | ||
| google.protobuf.Any typed_config = 3; |
There was a problem hiding this comment.
I've found @htuch article [1] that suggests that Struct and Any have different benefits in terms of type checking and flexibility. It also matches pattern used in message AccessLog.
There was a problem hiding this comment.
I thought the plan here is that we aren't going to allow Struct for any new things, as a Struct can be embedded in any Any? @htuch?
There was a problem hiding this comment.
I kind of feel we should just be consistent in v2 and in UDPA we can make a clean break.
| // Custom configuration that depends on the filter being instantiated. | ||
| oneof config_type { | ||
| google.protobuf.Struct config = 2; | ||
| google.protobuf.Any typed_config = 3; |
There was a problem hiding this comment.
I've found @htuch article [1] that suggests that Struct and Any have different benefits in terms of type checking and flexibility. It also matches pattern used in message AccessLog.
| } | ||
|
|
||
| private: | ||
| size_t current_ = 0; |
There was a problem hiding this comment.
Nit: prefer using unsigned explicit sized integers in Envoy, rather than size_t (which you can use for buffer sizes etc.)
There was a problem hiding this comment.
Done, thanks for suggestion!
| config, Envoy::ProtobufMessage::getNullValidationVisitor(), *this); | ||
| const Json::ObjectSharedPtr filter_config = | ||
| MessageUtil::getJsonObjectFromMessage(*factory_config); | ||
| return FilterPtr{new SampleExtensionFilter(filter_config->getInteger("rate"))}; |
There was a problem hiding this comment.
Nit: you can make all these Ptr{ new .. just std::make_unique
There was a problem hiding this comment.
Thanks for suggestion! Done.
| // For rate=5 expect 1st request to be recorded, 2nd-5th skipped, and 6th recorded. | ||
| EXPECT_CALL(*file_, write(_)); | ||
| logger->log(&request_headers_, &response_headers_, &response_trailers_, stream_info_); | ||
| for (int i = 2; i <= 5; ++i) { |
There was a problem hiding this comment.
Done. I was trying to express that requests 2-5 are skipped.
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov <mef@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM with one small doc request. Thank you!
/wait
| Access log filters | ||
| ================== | ||
|
|
||
| Envoy supports several built-in access log filters. Currently supported filters are: |
There was a problem hiding this comment.
Can you ref link into the actual filter config docs? It's up to you if you want to replicate all of the filters here as they may get out of date vs. just link to the filter structure. I mostly just wanted to call out that extension filters are available. https://www.envoyproxy.io/docs/envoy/latest/api-v2/config/filter/accesslog/v2/accesslog.proto#envoy-api-msg-config-filter-accesslog-v2-accesslog
There was a problem hiding this comment.
I'll be happy to ref link into the actual filter config docs, but I can't figure out how.
Is there an example that I could follow?
There was a problem hiding this comment.
@efimki see how this is done here: https://github.com/envoyproxy/envoy/blame/master/docs/root/configuration/runtime.rst#L22
There was a problem hiding this comment.
Thanks! I think I've done the right thing now, but not 100% sure.
I'm totally confused about msg vs field in references like <envoy_api_msg_config.filter.accesslog.v2.AccessLogFilter> <envoy_api_field_config.filter.accesslog.v2.AccessLogFilter.extension_filter>.
Signed-off-by: Misha Efimov <mef@google.com>
mattklein123
left a comment
There was a problem hiding this comment.
Thanks looks great. Sorry one more thing: please add a release note otherwise LGTM!
/wait
Signed-off-by: Misha Efimov <mef@google.com>
docs/root/intro/version_history.rst
Outdated
| * tls: added verification of IP address SAN fields in certificates against configured SANs in the | ||
| certificate validation context. | ||
| * upstream: added network filter chains to upstream connections, see :ref:`filters<envoy_api_field_Cluster.filters>`. | ||
| * config: added access log :ref:`extension filter<envoy_api_field_config.filter.accesslog.v2.AccessLogFilter.extension_filter>`. |
Signed-off-by: Misha Efimov <mef@google.com>
Signed-off-by: Misha Efimov mef@google.com
Description: Add AccessLog ExtensionFilter to allow runtime filter registration.
Risk Level: Medium
Testing: unit test
Docs Changes: Add AccessLog ExtensionFilter documentation.
Release Notes: updated.
Fixes #7326