-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
fix(prometheus): disable features when prometheus plugin is turned off #11117
Merged
moonming
merged 11 commits into
apache:master
from
shreemaan-abhishek:fix/prometheus-disable-perf-problem
Apr 10, 2024
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
039e656
fix: disable features when plugin is turned off
shreemaan-abhishek a435804
support reloading
shreemaan-abhishek 7b9cd26
tests for batch processor
shreemaan-abhishek f30eaa9
remove logs
shreemaan-abhishek eab64d3
test stream hot reload
shreemaan-abhishek ad32299
remove check for log phase as they are called only when prometheus is…
shreemaan-abhishek 7ab3625
need not check stream
shreemaan-abhishek 2e65e5c
remove stream tests
shreemaan-abhishek 9d5689c
fix lint
shreemaan-abhishek 669dc18
code review
shreemaan-abhishek ee5972f
remove sleep
shreemaan-abhishek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
. ./t/cli/common.sh | ||
|
||
git checkout conf/config.yaml | ||
|
||
make run | ||
|
||
sleep 2 | ||
|
||
echo "removing prometheus from the plugins list" | ||
echo ' | ||
deployment: | ||
role: traditional | ||
role_traditional: | ||
config_provider: etcd | ||
admin: | ||
admin_key: null | ||
apisix: | ||
node_listen: 1984 | ||
plugins: | ||
- ip-restriction' > conf/config.yaml | ||
|
||
echo "fetch metrics, should not contain {}" | ||
|
||
if curl -i http://127.0.0.1:9091/apisix/prometheus/metrics | grep "{}" > /dev/null; then | ||
echo "failed: metrics should not contain '{}' when prometheus is enabled" | ||
exit 1 | ||
fi | ||
|
||
echo "calling reload API to actually disable prometheus" | ||
|
||
curl -i http://127.0.0.1:9090/v1/plugins/reload -XPUT | ||
|
||
sleep 2 | ||
|
||
echo "fetch metrics after reload should contain {}" | ||
|
||
if ! curl -i http://127.0.0.1:9091/apisix/prometheus/metrics | grep "{}" > /dev/null; then | ||
echo "failed: metrics should contain '{}' when prometheus is disabled" | ||
exit 1 | ||
fi | ||
|
||
echo "re-enable prometheus" | ||
|
||
echo ' | ||
deployment: | ||
role: traditional | ||
role_traditional: | ||
config_provider: etcd | ||
admin: | ||
admin_key: null | ||
apisix: | ||
node_listen: 1984 | ||
plugins: | ||
- prometheus' > conf/config.yaml | ||
|
||
echo "fetching metrics without reloading should give same result as before" | ||
|
||
if ! curl -i http://127.0.0.1:9091/apisix/prometheus/metrics | grep "{}" > /dev/null; then | ||
echo "failed: metrics should contain '{}' when prometheus is disabled" | ||
exit 1 | ||
fi | ||
|
||
echo "calling reload API to actually enable prometheus" | ||
|
||
curl -i http://127.0.0.1:9090/v1/plugins/reload -XPUT | ||
|
||
sleep 2 | ||
|
||
if curl -i http://127.0.0.1:9091/apisix/prometheus/metrics | grep "{}" > /dev/null; then | ||
echo "failed: metrics should not contain '{}' when prometheus is enabled" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we don't need to get the active status.
Since the
exporter.destroy
is harmless.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.
you are right
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.
And so do line355 ~ line357
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.
no I think the second if check needs the
active
status. Consider this case:In this case
enabled == true
andactive == true
. But we need not callhttp_init()
in prometheus because it is already running during this operation.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.
Got it.