Skip to content

feat: decoupled prometheus exporter's calculation and output #12383

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

SkyeYoung
Copy link
Member

Description

Which issue(s) this PR fixes:

Fixes #

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)

{name = "waiting", var = "ngx_stat_waiting"},
}

-- Use FFI to get nginx status directly from global variables
local function nginx_status()
Copy link
Member Author

@SkyeYoung SkyeYoung Jun 27, 2025

Choose a reason for hiding this comment

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

Because API disabled in the context of ngx.timer, context: ngx.timer.

Here use FFI to rewrite the nginx_status logic.

OLD(master) NEW(current)
image image

Copy link
Contributor

@bzp2010 bzp2010 Jun 27, 2025

Choose a reason for hiding this comment

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

Underhood: The ngx.var is related to the request context, which is inaccessible; nginx subrequests are also not available. Hence the rewrite to FFI.

@@ -454,10 +458,11 @@ local function collect(ctx, stream_only)
local config = core.config.new()

-- config server status
local vars = ngx.var or {}
local hostname = vars.hostname or ""
local hostname = core.utils.gethostname() or ""
Copy link
Member Author

@SkyeYoung SkyeYoung Jun 27, 2025

Choose a reason for hiding this comment

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

Because API disabled in the context of ngx.timer, context: ngx.timer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants