fix: otel sink json access logging without text field#5498
fix: otel sink json access logging without text field#5498arkodg merged 4 commits intoenvoyproxy:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5498 +/- ##
==========================================
+ Coverage 65.25% 65.26% +0.01%
==========================================
Files 213 213
Lines 34063 34069 +6
==========================================
+ Hits 22228 22236 +8
+ Misses 10500 10499 -1
+ Partials 1335 1334 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ece73ca to
43133c3
Compare
internal/xds/translator/accesslog.go
Outdated
There was a problem hiding this comment.
Should we also do a separate check for JSON logging? I.e. check if JSON attributes are defined or not, and in case not, default to EnvoyJSONLogFields?
Something along the lines
if len(otel.Attributes) != 0 {
al.Attributes = convertToKeyValueList(otel.Attributes, true)
formatters = accessLogOpenTelemetryFormatters(format, otel.Attributes)
} else {
// if there are no attributes, use the default EnvoyJSONLogFields
al.Attributes = convertToKeyValueList(EnvoyJSONLogFields, true)
formatters = accessLogOpenTelemetryFormatters(format, EnvoyJSONLogFields)
}There was a problem hiding this comment.
Sorry this took a bit of time. Went through the OpenTelemetry specs and documentation on the field. Implemented following:
- When no text or JSON type is set, default to
EnvoyJSONLogFields, similar to previous implementation with the respective text format prior to v1.3.1/v1.2.7
The JSON fields are populated to the accessLog Attributes field as before with the JSON fields. Went through the OpenTelemetry specification discussion on this and relevant docs and to me it seems that this should be an OK way to go.
Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi>
0468e3d to
9381a23
Compare
Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi>
9381a23 to
5ea3f3b
Compare
guydc
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing this and adding a test!
internal/xds/translator/accesslog.go
Outdated
There was a problem hiding this comment.
doesnt this feel weird, if we have a format its part of Body, else Attributes
There was a problem hiding this comment.
can we move this to another GH issue and only have the fix around
if otel.Text != nil && *otel.Text != "" {
format = *otel.Text
in this PR so we can add it into v1.3.2 , releasing soon
There was a problem hiding this comment.
Can be done! Only concern is, how does this behave in case no output type or format/attributes are defined? As JSON logging is now default, does it render logs empty for users who have neither defined? Previously in v1.3.0, the EnvoyTextLogFormat was set as default and then it was checked if log format was defined. https://github.com/envoyproxy/gateway/blob/v1.3.0/internal/xds/translator/accesslog.go#L325-L336
There was a problem hiding this comment.
this looks good, sorry for the confusion
|
@kraashen can you fix DCO and force push |
Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi>
f7c0dbf to
fac129c
Compare
* fix otel sink json access logging without text field Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * use json format as default when format or type is not set Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * set formatters only if the slice of formatters is not empty Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> --------- Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> (cherry picked from commit cb3ffd2) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
* fix otel sink json access logging without text field Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * use json format as default when format or type is not set Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * set formatters only if the slice of formatters is not empty Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> --------- Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> (cherry picked from commit cb3ffd2) Signed-off-by: Guy Daich <guy.daich@sap.com>
* load BackendTLSPolicy in standalone mode (#5431) Signed-off-by: Arko Dasgupta <arko@tetrate.io> (cherry picked from commit 4d914ae) Signed-off-by: Guy Daich <guy.daich@sap.com> * Wasm: cache Wasm OCI image permission check results (#5358) * add TTL for wasm permission check Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * change Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * refresh the cache Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * purge the cache Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * refactor Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * on retry on retriable errors Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add release note Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> (cherry picked from commit 672de8a) Signed-off-by: Guy Daich <guy.daich@sap.com> * Load EnvoyExtensionPolicy in standalone mode (#5460) * load EnvoyExtensionPolicy in standalone mode Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * more Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * release note Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * review: use a valid target name instead of myapp Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * gen Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> (cherry picked from commit 4be098d) Signed-off-by: Guy Daich <guy.daich@sap.com> * fix: check for mirror backendRef in httproute index (#5497) * check for mirror backendRef Signed-off-by: mark winter <mark.winter@thetradedesk.com> (cherry picked from commit 72b72c4) Signed-off-by: Guy Daich <guy.daich@sap.com> * fix: dont return an err when gatewayclass is not accepted (#5524) * bug: dont return an err when gatewayclass is not accepted this is a user generated error, we shouldnt log it as a system error, and return with an error Signed-off-by: Arko Dasgupta <arko@tetrate.io> * release notes Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> (cherry picked from commit 51e87ca) Signed-off-by: Guy Daich <guy.daich@sap.com> * fix: host header should not be allowed to modify (#5533) * host header is not allowed to be modified Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> (cherry picked from commit 54efa34) Signed-off-by: Guy Daich <guy.daich@sap.com> * fix: retrigger reconciliation when backendRef of type ServiceImport is updated (#5461) * fix: retrigger reconilation when backendRef of type ServiceImport is updated Signed-off-by: Teju Nareddy <tejunareddy@gmail.com> (cherry picked from commit e2f8978) Signed-off-by: Guy Daich <guy.daich@sap.com> * pin envoy and ratelimit Signed-off-by: Guy Daich <guy.daich@sap.com> * fix: otel sink json access logging without text field (#5498) * fix otel sink json access logging without text field Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * use json format as default when format or type is not set Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * set formatters only if the slice of formatters is not empty Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> --------- Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> (cherry picked from commit cb3ffd2) Signed-off-by: Guy Daich <guy.daich@sap.com> * [release/v1.3] v1.3.2 release notes (#5584) v1.3.2 release notes Signed-off-by: Guy Daich <guy.daich@sap.com> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: Guy Daich <guy.daich@sap.com> Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Signed-off-by: mark winter <mark.winter@thetradedesk.com> Signed-off-by: Teju Nareddy <tejunareddy@gmail.com> Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Co-authored-by: Mark Winter <wintermarkedward@gmail.com> Co-authored-by: Teju Nareddy <tejunareddy@gmail.com> Co-authored-by: Tomi Juntunen <tomi.juntunen@iki.fi>
* bump envoy to v1.32.4 Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix: host header should not be allowed to modify (#5533) * host header is not allowed to be modified Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * address comment Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> (cherry picked from commit 54efa34) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add release note Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * bump ratelimit to 0141a24 Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * Wasm: cache Wasm OCI image permission check results (#5358) * add TTL for wasm permission check Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix test Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * change Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * refresh the cache Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * purge the cache Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * refactor Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * on retry on retriable errors Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add release note Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> (cherry picked from commit 672de8a) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * load BackendTLSPolicy in standalone mode (#5431) Signed-off-by: Arko Dasgupta <arko@tetrate.io> (cherry picked from commit 4d914ae) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix: check for mirror backendRef in httproute index (#5497) * check for mirror backendRef Signed-off-by: mark winter <mark.winter@thetradedesk.com> (cherry picked from commit 72b72c4) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix: dont return an err when gatewayclass is not accepted (#5524) * bug: dont return an err when gatewayclass is not accepted this is a user generated error, we shouldnt log it as a system error, and return with an error Signed-off-by: Arko Dasgupta <arko@tetrate.io> * release notes Signed-off-by: Arko Dasgupta <arko@tetrate.io> --------- Signed-off-by: Arko Dasgupta <arko@tetrate.io> (cherry picked from commit 51e87ca) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * update release note Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * update reatelimit Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix gen Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * Load EnvoyExtensionPolicy in standalone mode (#5460) * load EnvoyExtensionPolicy in standalone mode Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * more Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * release note Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * review: use a valid target name instead of myapp Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> * gen Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> (cherry picked from commit 4be098d) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * add security update to release note Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * fix: otel sink json access logging without text field (#5498) * fix otel sink json access logging without text field Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * use json format as default when format or type is not set Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> * set formatters only if the slice of formatters is not empty Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> --------- Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> (cherry picked from commit cb3ffd2) Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * update release date Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> * update release date Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com> Signed-off-by: Arko Dasgupta <arko@tetrate.io> Signed-off-by: mark winter <mark.winter@thetradedesk.com> Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Signed-off-by: Tomi Juntunen <tomi.juntunen@iki.fi> Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com> Co-authored-by: Mark Winter <wintermarkedward@gmail.com> Co-authored-by: Takeshi Yoneda <t.y.mathetake@gmail.com> Co-authored-by: Tomi Juntunen <tomi.juntunen@iki.fi>
What type of PR is this?
This PR attempts to fix issue #5481 by passing only the JSON attributes to the otel formatter builder. It does this by leaving the text format empty when JSON type is specified but text is not.
What this PR does / why we need it:
As described in the linked issue, this leads to a situation where HTTPRoutes are not registering to listeners due to error returned in situations where JSON logging is used. This issue seemed to be rising when OpenTelemetry sink type is used without
textfield in the configuration.Tested this in a local cluster calling the test API, and logs seemed to be produced in Loki when queried with

exporter=OTELlabel.Which issue(s) this PR fixes:
Fixes #5481
Release Notes: Yes
Note
I have little to none prior experience of Envoy Gateway development. Went through the guidelines with best effort, but I'm a bit unsure if there are any possible other downstream consequences to this change. Any advice would be appreciated!