Add support for nested JSON format in json logging mode#12602
Add support for nested JSON format in json logging mode#12602zuercher merged 7 commits intoenvoyproxy:masterfrom
Conversation
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
zuercher
left a comment
There was a problem hiding this comment.
Thanks!
Have you run the substitution_formatter_speed_test before/after this change? It doesn't seem like it should change the performance for flat json formats, but I'd like to confirm.
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
|
@zuercher thank you for the review, updated according to your comments. |
|
🎉 happy to see this going through so quickly! |
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
|
Can you run the speed test noted above and confirm there’s no significant degradation? Thanks. |
|
Oh, sorry @zuercher, I've totally missed your comment about the speed test! master feature branch The numbers seem comparable. |
dio
left a comment
There was a problem hiding this comment.
Thanks, very well done! Few comments:
|
|
||
| JsonFormatterImpl::JsonFormatMap | ||
| JsonFormatterImpl::toFormatMap(const ProtobufWkt::Struct& json_format) const { | ||
| auto output = std::make_unique<std::map<std::string, JsonFormatterImpl::JsonFormatMapValue>>(); |
There was a problem hiding this comment.
I assume we want to preserve order here? Do you mind adding comments here so we understand why we choose std::map?
There was a problem hiding this comment.
Done. Given that I've made aliases per the other comment, the explanation comment is now in the header file where the type's defined.
| using JsonFormatMapValue = | ||
| absl::variant<const std::vector<FormatterProviderPtr>, const JsonFormatMap>; | ||
| struct JsonFormatMap { | ||
| std::unique_ptr<std::map<std::string, JsonFormatMapValue>> value_; |
There was a problem hiding this comment.
We usually have a typedef for this. But I don't feel strongly about it.
There was a problem hiding this comment.
Added some aliases. Looks more readable indeed now.
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
| using JsonFormatMapValue = | ||
| absl::variant<const std::vector<FormatterProviderPtr>, const JsonFormatMapWrapper>; | ||
| // Although not required for JSON, it is nice to have the order of properties | ||
| // preserved between the format and the log entry, thus std::map |
There was a problem hiding this comment.
Since you need to fix format anyway, please end this with full-stop. Thanks.
| // preserved between the format and the log entry, thus std::map | ||
| using JsonFormatMap = std::map<std::string, JsonFormatMapValue>; | ||
| using JsonFormatMapPtr = std::unique_ptr<JsonFormatMap>; | ||
| struct JsonFormatMapWrapper{ |
There was a problem hiding this comment.
Here. Missing space between JsonFormatMapWrapper and {.
Signed-off-by: Petr Pchelko <ppchelko@wikimedia.org>
|
/retest |
|
Retrying Azure Pipelines, to retry CircleCI checks, use |
* envoy/master: (90 commits) cleanup: use structured binding (envoyproxy#12791) docs: fix header name for retries in gRPC services (envoyproxy#12790) docs: clarify meaning of HeaderValueOption.append (envoyproxy#12792) doc: clarify handling of duplicate xDS resource names (envoyproxy#12756) Dependencies: build updates. (envoyproxy#12786) Ratelimit: Add optional descriptor key to generic_key action (envoyproxy#12734) test: refactor header inclusion to speed up building (for test/mocks/upstream:upstream_mocks) (envoyproxy#12407) docs: Fix omitted word (envoyproxy#12782) ci: avoid uploading dwp as separate artifact (envoyproxy#12777) doc: Fix small typos (envoyproxy#12769) fix cache factory category (envoyproxy#12765) docs: fix typo v1.15.0.rst (envoyproxy#12680) Add clang-cl RBE toolchain for Windows (envoyproxy#12776) fuzz: add router fuzz proto (envoyproxy#12727) header: New HeaderMatcher and StringMatcher type - Contains (envoyproxy#12623) tcp_proxy: use dynamicMetadata() from StreamInfo for load balancing (envoyproxy#12595) network: add io handle recv function for http inspector (envoyproxy#12736) jwt_authn: supports jwt payload without "iss" field (envoyproxy#12744) Add support for nested JSON format in json logging mode (envoyproxy#12602) http: fixing a fuzz flake by setting details on connection teardown (envoyproxy#12737) ... Signed-off-by: Scott LaVigne <lavignes@amazon.com>
This adds support for nesting in JSON logging mode. There is another opportunity for improvement - support static non-string values, but I guess we can do this separately.
Commit Message: Add support for nested JSON format in JSON logging mode.
Risk Level: Low, feature only used if nested objects are configured, thus opt-in.
Testing: unit tests
Docs Changes: yes
Release Notes: added to current.rst
Fixes #12582
Signed-off-by: Petr Pchelko ppchelko@wikimedia.org