Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2d4b36f9
Commit
2d4b36f9
authored
Jul 03, 2020
by
Reuben Pereira
Committed by
Peter Leitzen
Jul 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add comments to public methods of ProxyVariableSubstitutionService
parent
272ae406
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
app/services/prometheus/proxy_variable_substitution_service.rb
...ervices/prometheus/proxy_variable_substitution_service.rb
+42
-0
No files found.
app/services/prometheus/proxy_variable_substitution_service.rb
View file @
2d4b36f9
...
@@ -19,10 +19,52 @@ module Prometheus
...
@@ -19,10 +19,52 @@ module Prometheus
:substitute_params
,
:substitute_params
,
:substitute_variables
:substitute_variables
# @param environment [Environment]
# @param params [Hash<Symbol,Any>]
# @param params - query [String] The Prometheus query string.
# @param params - start [String] (optional) A time string in the rfc3339 format.
# @param params - start_time [String] (optional) A time string in the rfc3339 format.
# @param params - end [String] (optional) A time string in the rfc3339 format.
# @param params - end_time [String] (optional) A time string in the rfc3339 format.
# @param params - variables [ActionController::Parameters] (optional) Variables with their values.
# The keys in the Hash should be the name of the variable. The value should be the value of the
# variable. Ex: `ActionController::Parameters.new(variable1: 'value 1', variable2: 'value 2').permit!`
# @return [Prometheus::ProxyVariableSubstitutionService]
#
# Example:
# Prometheus::ProxyVariableSubstitutionService.new(environment, {
# params: {
# start_time: '2020-07-03T06:08:36Z',
# end_time: '2020-07-03T14:08:52Z',
# query: 'up{instance="{{instance}}"}',
# variables: { instance: 'srv1' }
# }
# })
def
initialize
(
environment
,
params
=
{})
def
initialize
(
environment
,
params
=
{})
@environment
,
@params
=
environment
,
params
.
deep_dup
@environment
,
@params
=
environment
,
params
.
deep_dup
end
end
# @return - params [Hash<Symbol,Any>] Returns a Hash containing a params key which is
# similar to the `params` that is passed to the initialize method with 2 differences:
# 1. Variables in the query string are substituted with their values.
# If a variable present in the query string has no known value (values
# are obtained from the `variables` Hash in `params` or from
# `Gitlab::Prometheus::QueryVariables.call`), it will not be substituted.
# 2. `start` and `end` keys are added, with their values copied from `start_time`
# and `end_time`.
#
# Example output:
#
# {
# params: {
# start_time: '2020-07-03T06:08:36Z',
# start: '2020-07-03T06:08:36Z',
# end_time: '2020-07-03T14:08:52Z',
# end: '2020-07-03T14:08:52Z',
# query: 'up{instance="srv1"}',
# variables: { instance: 'srv1' }
# }
# }
def
execute
def
execute
execute_steps
execute_steps
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment