diff options
author | Valery Piashchynski <[email protected]> | 2020-02-10 17:12:11 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2020-02-10 17:12:11 +0300 |
commit | 04f8180bae119d0aa9be53db52165d3391a58efa (patch) | |
tree | c556ac35977a4bd2e80a4b28be46cca264ff96a3 /service/metrics/rpc_test.go | |
parent | 02be3eec1d8323a16031e86c1ddcc5c52c440176 (diff) |
Update go.mod/go.sum
New Register method
Diffstat (limited to 'service/metrics/rpc_test.go')
-rw-r--r-- | service/metrics/rpc_test.go | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/service/metrics/rpc_test.go b/service/metrics/rpc_test.go index 3fe48818..332f0f65 100644 --- a/service/metrics/rpc_test.go +++ b/service/metrics/rpc_test.go @@ -240,6 +240,58 @@ func Test_Sub_RPC_Vector(t *testing.T) { assert.Contains(t, out, `user_gauge{section="first",type="core"} 90`) } +func Test_Register_RPC(t *testing.T) { + client, c := setup( + t, + `"user_gauge":{ + "type": "gauge", + "labels": ["type", "section"] + }`, + "2319", + ) + defer c.Stop() + + var ok bool + assert.NoError(t, client.Call("metrics.Register", &NamedCollector{ + Name: "custom_histogram", + Collector: Collector{ + Namespace: "test_histogram", + Subsystem: "test_histogram", + Type: "histogram", + Help: "test_histogram", + Labels: nil, + Buckets: nil, + }, + }, &ok)) + assert.True(t, ok) + + var ok2 bool + // histogram does not support Add, should be an error + assert.Error(t, client.Call("metrics.Add", Metric{ + Name: "custom_histogram", + }, &ok2)) + // ok should became false + assert.False(t, ok2) + + + + + + // reset ok + //ok = false + // + //assert.NoError(t, client.Call("metrics.Sub", Metric{ + // Name: "user_gauge", + // Value: 10.0, + // Labels: []string{"core", "first"}, + //}, &ok)) + //assert.True(t, ok) + // + //out, _, err := get("http://localhost:2119/metrics") + //assert.NoError(t, err) + //assert.Contains(t, out, `user_gauge{section="first",type="core"} 90`) +} + func Test_Sub_RPC_CollectorError(t *testing.T) { client, c := setup( t, |