-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor metrics.utils and change type of luajit metrics
- Loading branch information
1 parent
bdc569f
commit 2b31488
Showing
3 changed files
with
84 additions
and
51 deletions.
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,43 @@ | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
local utils = require('metrics.utils') | ||
|
||
g.test_set_gauge = function() | ||
local gauge = utils.set_gauge('gauge', 'gauge info', 10) | ||
|
||
t.assert_equals(gauge.name, 'tnt_gauge') | ||
t.assert_equals(gauge.help, 'gauge info') | ||
t.assert_equals(gauge.observations[''], 10) | ||
end | ||
|
||
g.test_set_counter = function() | ||
local counter = utils.set_counter('counter', 'counter info', 10) | ||
|
||
t.assert_equals(counter.name, 'tnt_counter') | ||
t.assert_equals(counter.help, 'counter info') | ||
t.assert_equals(counter.observations[''], 10) | ||
|
||
utils.set_counter('counter', 'counter info', 20) | ||
t.assert_equals(counter.observations[''], 20) | ||
end | ||
|
||
g.test_set_gauge_prefix = function() | ||
local gauge = utils.set_gauge('gauge', 'gauge info', 10, nil, 'custom_') | ||
|
||
t.assert_equals(gauge.name, 'custom_gauge') | ||
t.assert_equals(gauge.help, 'gauge info') | ||
t.assert_equals(gauge.observations[''], 10) | ||
end | ||
|
||
g.test_set_counter_prefix = function() | ||
local counter = utils.set_counter('counter', 'counter info', 10, nil, 'custom_') | ||
|
||
t.assert_equals(counter.name, 'custom_counter') | ||
t.assert_equals(counter.help, 'counter info') | ||
t.assert_equals(counter.observations[''], 10) | ||
|
||
utils.set_counter('counter', 'counter info', 20, nil, 'custom_') | ||
t.assert_equals(counter.observations[''], 20) | ||
end | ||
|