Add static registration of AccessLog::Instance implementations.#1609
Add static registration of AccessLog::Instance implementations.#1609htuch merged 11 commits intoenvoyproxy:masterfrom
Conversation
htuch
left a comment
There was a problem hiding this comment.
Looks good, some code structure questions..
source/common/config/filter_json.cc
Outdated
|
|
||
| // Statically registered access logs are a v2-only feature, so use the standard internal file | ||
| // access log for json config conversion. | ||
| access_log.set_name("envoy.file_access_log"); |
There was a problem hiding this comment.
We should probably have a centralized list of well known names in the Envoy namespace. I started one for metadata in source/common/config/metadata.h, but we should probably expand to cover this.
| ProtobufTypes::MessagePtr message = factory->createEmptyConfigProto(); | ||
| if (config.has_config()) { | ||
| MessageUtil::jsonConvert(config.config(), *message); | ||
| } |
There was a problem hiding this comment.
This pattern is now in at least 4 places. What do you think about refactoring?
include/envoy/http/access_log.h
Outdated
| * @param config the custom configuration for this access log type. | ||
| * @param filter filter to determine whether a particular request should be logged. If no filter | ||
| * was specified in the configuration, argument will be nullptr. | ||
| * @param log_manager interface through which filesystem access logs are created. |
There was a problem hiding this comment.
Is this the only way to plumb this for the filesystem logs? Seems like a vestigial feature for everyone else.
There was a problem hiding this comment.
We could do something more general, like provide an "environment" or "context" to give general access to conditionally useful variables so that this api can be expanded with new use cases (for instance, we will likely need to provide the ability to access the cluster manager for RPC logs) as is done for http filters now. We could also make the log_manager a singleton, but that seems like it would be more troublesome for each additional object.
There was a problem hiding this comment.
+1 I think a context is good, it leaves room for future expansion without having to modify the filter interface, which causes breaking/deprecating changes.
|
Added singleton of well known names and replaced uses with references to the class, used the |
mattklein123
left a comment
There was a problem hiding this comment.
looks great. small doc nit.
| * @param config the custom configuration for this access log type. | ||
| * @param filter filter to determine whether a particular request should be logged. If no filter | ||
| * was specified in the configuration, argument will be nullptr. | ||
| * @param log_manager interface through which filesystem access logs are created. |
| class NetworkFilterNameValues { | ||
| public: | ||
| // Client ssl auth filter | ||
| const std::string CLIENT_SSL_AUTH = "client_ssl_auth"; |
There was a problem hiding this comment.
I'm wondering for the network/HTTP names whether we want to make it that we retain existing names without a envoy. prefix for v1, but for v2 make these envoy.ratelimit etc. We could just do the prefix step during the JSON -> proto translation steps and then we have a consistent naming scheme across all filters/pluggables for v2.
| @@ -0,0 +1,96 @@ | |||
| #pragma once | |||
There was a problem hiding this comment.
Thanks for adding this. Can you merge https://github.com/lyft/envoy/blob/master/source/common/config/metadata.h#L43 into this as well?
| const std::string ROUTER = "envoy.router"; | ||
|
|
||
| HttpFilterNameValues() { | ||
| const std::vector<std::string> prefixed_v2_names = { |
There was a problem hiding this comment.
This thing seems fragile to me but I can't really think of a better way to do it. Can we potentially at least share this code with above via some small helper class that takes an array of strings as part of the constructor?
There was a problem hiding this comment.
Yeah, my bad. Should've been done that way in the first place.
mattklein123
left a comment
There was a problem hiding this comment.
Nice LGTM pending @htuch final look.
htuch
left a comment
There was a problem hiding this comment.
Thanks for the epic cleanup on filter namespace. A very minor nit (ENVOY_ROUTER redundancy), otherwise LGTM.
| route: { host_rewrite: www.google.com, cluster: service_google } | ||
| http_filters: | ||
| - name: router | ||
| - name: envoy.router |
There was a problem hiding this comment.
Really appreciate the cleanup here! :)
| throw EnvoyException(fmt::format( | ||
| "Attempted to create a conversion for a v2 name that isn't prefixed by {}", prefix)); | ||
| } | ||
| v1_to_v2_names_[name.substr(prefix.size())] = name; |
There was a problem hiding this comment.
I think this could be done a bit simpler by just prefixing on ingest, but it seems alright, and will eventually be deprecated.
| // Filter namespace for built-in load balancer. | ||
| const std::string ENVOY_LB = "envoy.lb"; | ||
| // Filter namespace for built-in router opaque data. | ||
| const std::string ENVOY_ROUTER = "envoy.router"; |
There was a problem hiding this comment.
I think ENVOY_ROUTER is a dupe of ROUTER above. The idea in the metadata namespace is you use the filter name as key.
There was a problem hiding this comment.
Does this mean that these should all just be treated as filter names and we should remove this class altogether?
Description: Remove the designated initializer I used in `engine_builder.cc` and instead populate `null_logger` field-by-field. Turns out this syntax is one of this parts of C++ that's _not_ the same as C. Risk Level: Low Testing: `bazel test //test/...` Docs Changes: N/A Release Notes: N/A Signed-off-by: Cerek Hillen <chillen@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Description: Remove the designated initializer I used in `engine_builder.cc` and instead populate `null_logger` field-by-field. Turns out this syntax is one of this parts of C++ that's _not_ the same as C. Risk Level: Low Testing: `bazel test //test/...` Docs Changes: N/A Release Notes: N/A Signed-off-by: Cerek Hillen <chillen@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
This enables custom access log implementations to be substituted in place of the existing file access log. This feature is only available in the v2 api. For v1 api users, there should be no changes. This change increments the commit hash of
envoy-apito get related api changes.The implementation follows the static registration pattern for other components relatively closely.