-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(log-serializer): add source
property to log-serializer
#12052
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most LGTM, But I want to clarify that not all the response code errors can be captured by Kong Lua code, Like 400 or Nginx internal error. it can not be captured in our implementation of get_source
PDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor comments; otherwise, LGTM
kong/pdk/log.lua
Outdated
if response_source == "exit" or response_source == "error" then | ||
response_source = "kong" | ||
elseif response_source == "service" then | ||
response_source = "upstream" | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so okong.response.get_source(ongx.ctx)
only have 3 values , exit
, error
or service
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct.
Lines 345 to 364 in 6077171
function _RESPONSE.get_source(ctx) | |
if ctx == nil then | |
check_phase(header_body_log) | |
ctx = ngx.ctx | |
end | |
if ctx.KONG_UNEXPECTED then | |
return "error" | |
end | |
if ctx.KONG_EXITED then | |
return "exit" | |
end | |
if ctx.KONG_PROXIED then | |
return "service" | |
end | |
return "error" | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to use a constant table to contain these three values to prevent if someone change function _RESPONSE.get_source(ctx)
but forget to update it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vm-001 any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have any strong opinions on this. Just feel replacing the if conditions with a constant table may be not completed. The vars defined in _RESPONSE.get_source
function should also be changed. Please ref the latest commit to get what I'm saying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand @vm-001's point and agree this would be an improvement; in the interest of keeping things moving, let's merge this as-is, and, if you both think this is a desirable improvement, please create a JIRA to track it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @gszr. @tzssangglass Checkout the latest commit to see if it addresses your concern. If yes. please resolve this comment. Otherwise, open a ticket then we can track it.
53e67d9
to
d2604f8
Compare
d2604f8
to
436ff7d
Compare
Successfully created cherry-pick PR for |
Summary:
Add a new property
source
to indicate the response is generated bykong
orupstream
.FTI-5522