Skip to content

fix: Set upstream and upstream_latency vars in ext-plugin-post-resp for logging#13018

Open
MariaLapovska wants to merge 1 commit intoapache:masterfrom
MariaLapovska:fix/missing-vars-post-resp
Open

fix: Set upstream and upstream_latency vars in ext-plugin-post-resp for logging#13018
MariaLapovska wants to merge 1 commit intoapache:masterfrom
MariaLapovska:fix/missing-vars-post-resp

Conversation

@MariaLapovska
Copy link
Copy Markdown

Description

When using ext-plugin-post-resp and http-logger, some values are missing from the logs, specifically the ones related to upstream - upstream and upstream_latency.
This is happening because upstream_response_time and upstream_addr nginx vars are unavailable, so when log-util.lua is trying to inject them into logs, no value is present.
This PR adds these two vars to ext-plugin-post-resp, they are now set explicitly after the call to upstream.

Which issue(s) this PR fixes:

Fixes #13016

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Feb 17, 2026
@MariaLapovska MariaLapovska changed the title Set upstream and upstream_latency vars in ext-plugin-post-resp for logging fix: Set upstream and upstream_latency vars in ext-plugin-post-resp for logging Feb 17, 2026
@janiussyafiq
Copy link
Copy Markdown
Contributor

would you be able to add test case that cover your fix?

@MariaLapovska
Copy link
Copy Markdown
Author

@janiussyafiq I'm not sure which test case I can add for this, since it simply adds two vars to nginx context. Would you be able to help me out?

@shreemaan-abhishek
Copy link
Copy Markdown
Contributor

@MariaLapovska you should add tests that verify that the variables you newly introduced are actually taking effect and hold correct values.

@Baoyuantop Baoyuantop added the wait for update wait for the author's response in this issue/PR label Feb 24, 2026
@Baoyuantop
Copy link
Copy Markdown
Contributor

Hi @MariaLapovska, following up on the previous review comments. Please let us know if you have any updates. Thank you.

Copy link
Copy Markdown
Member

@moonming moonming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @MariaLapovska, thank you for fixing the missing upstream variables in ext-plugin-post-resp!

Setting upstream and upstream_latency vars in the ext-plugin-post-resp phase for logging is a valid fix — these variables should be available for downstream loggers to capture.

One requirement: This PR needs test cases to verify:

  1. The upstream variable is populated correctly after ext-plugin-post-resp runs
  2. The upstream_latency variable reflects the actual upstream response time
  3. Logger plugins (e.g., http-logger) correctly capture these values when used alongside ext-plugin-post-resp

The fix is only 5 lines, so adding focused test cases should be straightforward. Looking forward to the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working need test cases size:XS This PR changes 0-9 lines, ignoring generated files. wait for update wait for the author's response in this issue/PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Some nginx vars related to upstream are missing when using ext-plugin-post-resp

5 participants