diff options
author | Devtools Arcadia <arcadia-devtools@yandex-team.ru> | 2022-02-07 18:08:42 +0300 |
---|---|---|
committer | Devtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net> | 2022-02-07 18:08:42 +0300 |
commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /library/cpp/monlib/encode/json/ut | |
download | ydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'library/cpp/monlib/encode/json/ut')
24 files changed, 920 insertions, 0 deletions
diff --git a/library/cpp/monlib/encode/json/ut/buffered_test.json b/library/cpp/monlib/encode/json/ut/buffered_test.json new file mode 100644 index 0000000000..53212cf8e1 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/buffered_test.json @@ -0,0 +1,36 @@ +{ + "sensors": + [ + { + "kind":"COUNTER", + "labels": + { + "foo":"bar" + }, + "timeseries": + [ + { + "ts":1, + "value":42 + }, + { + "ts":2, + "value":42 + }, + { + "ts":4, + "value":42 + } + ] + }, + { + "kind":"COUNTER", + "labels": + { + "foo":"baz" + }, + "ts":3, + "value":42 + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/buffered_ts_merge.json b/library/cpp/monlib/encode/json/ut/buffered_ts_merge.json new file mode 100644 index 0000000000..1d27efacb0 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/buffered_ts_merge.json @@ -0,0 +1,13 @@ +{ + "sensors": + [ + { + "kind":"COUNTER", + "labels": + { + "foo":"bar" + }, + "value":45 + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/crash.json b/library/cpp/monlib/encode/json/ut/crash.json Binary files differnew file mode 100644 index 0000000000..8ff4369dc4 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/crash.json diff --git a/library/cpp/monlib/encode/json/ut/empty_series.json b/library/cpp/monlib/encode/json/ut/empty_series.json new file mode 100644 index 0000000000..641e10cdea --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/empty_series.json @@ -0,0 +1,12 @@ +{ + "sensors": + [ + { + "kind":"COUNTER", + "labels": + { + "foo":"bar" + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/expected.json b/library/cpp/monlib/encode/json/ut/expected.json new file mode 100644 index 0000000000..ead853455b --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/expected.json @@ -0,0 +1,92 @@ +{ + "ts":1500000000, + "commonLabels": + { + "project":"solomon" + }, + "sensors": + [ + { + "kind":"COUNTER", + "labels": + { + "metric":"single", + "labels":"l1" + }, + "ts":1509843723, + "value":17 + }, + { + "kind":"RATE", + "labels": + { + "metric":"single", + "labels":"l2" + }, + "ts":1509843723, + "value":17 + }, + { + "kind":"GAUGE", + "labels": + { + "metric":"single", + "labels":"l3" + }, + "ts":1509843723, + "value":3.14 + }, + { + "kind":"IGAUGE", + "labels": + { + "metric":"single_igauge", + "labels":"l4" + }, + "ts":1509843723, + "value":42 + }, + { + "kind":"GAUGE", + "labels": + { + "metric":"multiple", + "labels":"l5" + }, + "timeseries": + [ + { + "ts":1509843723, + "value":"nan" + }, + { + "ts":1509843738, + "value":"inf" + }, + { + "ts":1509843753, + "value":"-inf" + } + ] + }, + { + "kind":"COUNTER", + "timeseries": + [ + { + "ts":1509843723, + "value":1337 + }, + { + "ts":1509843738, + "value":1338 + } + ], + "labels": + { + "metric":"multiple", + "labels":"l6" + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/expected_buffered.json b/library/cpp/monlib/encode/json/ut/expected_buffered.json new file mode 100644 index 0000000000..9a6a1d6201 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/expected_buffered.json @@ -0,0 +1,92 @@ +{ + "ts":1500000000, + "commonLabels": + { + "project":"solomon" + }, + "sensors": + [ + { + "kind":"COUNTER", + "labels": + { + "labels":"l1", + "metric":"single" + }, + "ts":1509843723, + "value":17 + }, + { + "kind":"RATE", + "labels": + { + "labels":"l2", + "metric":"single" + }, + "ts":1509843723, + "value":17 + }, + { + "kind":"GAUGE", + "labels": + { + "labels":"l3", + "metric":"single" + }, + "ts":1509843723, + "value":3.14 + }, + { + "kind":"IGAUGE", + "labels": + { + "labels":"l4", + "metric":"single_igauge" + }, + "ts":1509843723, + "value":42 + }, + { + "kind":"GAUGE", + "labels": + { + "labels":"l5", + "metric":"multiple" + }, + "timeseries": + [ + { + "ts":1509843723, + "value":"nan" + }, + { + "ts":1509843738, + "value":"inf" + }, + { + "ts":1509843753, + "value":"-inf" + } + ] + }, + { + "kind":"COUNTER", + "labels": + { + "labels":"l6", + "metric":"multiple" + }, + "timeseries": + [ + { + "ts":1509843723, + "value":1337 + }, + { + "ts":1509843738, + "value":1338 + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/expected_cloud.json b/library/cpp/monlib/encode/json/ut/expected_cloud.json new file mode 100644 index 0000000000..6184811579 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/expected_cloud.json @@ -0,0 +1,92 @@ +{ + "ts":"2017-07-14T02:40:00.000000Z", + "labels": + { + "project":"solomon" + }, + "metrics": + [ + { + "type":"COUNTER", + "labels": + { + "labels":"l1" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":17 + }, + { + "type":"RATE", + "labels": + { + "labels":"l2" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":17 + }, + { + "type":"DGAUGE", + "labels": + { + "labels":"l3" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":3.14 + }, + { + "type":"IGAUGE", + "labels": + { + "labels":"l4" + }, + "name":"single_igauge", + "ts":"2017-11-05T01:02:03.000000Z", + "value":42 + }, + { + "type":"DGAUGE", + "labels": + { + "labels":"l5" + }, + "name":"multiple", + "timeseries": + [ + { + "ts":"2017-11-05T01:02:03.000000Z", + "value":"nan" + }, + { + "ts":"2017-11-05T01:02:18.000000Z", + "value":"inf" + }, + { + "ts":"2017-11-05T01:02:33.000000Z", + "value":"-inf" + } + ] + }, + { + "type":"COUNTER", + "timeseries": + [ + { + "ts":"2017-11-05T01:02:03.000000Z", + "value":1337 + }, + { + "ts":"2017-11-05T01:02:18.000000Z", + "value":1338 + } + ], + "labels": + { + "labels":"l6" + }, + "name":"multiple" + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json b/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json new file mode 100644 index 0000000000..be237d522b --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/expected_cloud_buffered.json @@ -0,0 +1,92 @@ +{ + "ts":"2017-07-14T02:40:00.000000Z", + "labels": + { + "project":"solomon" + }, + "metrics": + [ + { + "type":"COUNTER", + "labels": + { + "labels":"l1" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":17 + }, + { + "type":"RATE", + "labels": + { + "labels":"l2" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":17 + }, + { + "type":"DGAUGE", + "labels": + { + "labels":"l3" + }, + "name":"single", + "ts":"2017-11-05T01:02:03.000000Z", + "value":3.14 + }, + { + "type":"IGAUGE", + "labels": + { + "labels":"l4" + }, + "name":"single_igauge", + "ts":"2017-11-05T01:02:03.000000Z", + "value":42 + }, + { + "type":"DGAUGE", + "labels": + { + "labels":"l5" + }, + "name":"multiple", + "timeseries": + [ + { + "ts":"2017-11-05T01:02:03.000000Z", + "value":"nan" + }, + { + "ts":"2017-11-05T01:02:18.000000Z", + "value":"inf" + }, + { + "ts":"2017-11-05T01:02:33.000000Z", + "value":"-inf" + } + ] + }, + { + "type":"COUNTER", + "labels": + { + "labels":"l6" + }, + "name":"multiple", + "timeseries": + [ + { + "ts":"2017-11-05T01:02:03.000000Z", + "value":1337 + }, + { + "ts":"2017-11-05T01:02:18.000000Z", + "value":1338 + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/hist_crash.json b/library/cpp/monlib/encode/json/ut/hist_crash.json Binary files differnew file mode 100644 index 0000000000..867d0fce7d --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/hist_crash.json diff --git a/library/cpp/monlib/encode/json/ut/histogram_timeseries.json b/library/cpp/monlib/encode/json/ut/histogram_timeseries.json new file mode 100644 index 0000000000..f6131ffded --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/histogram_timeseries.json @@ -0,0 +1,61 @@ +{ + "sensors": + [ + { + "kind":"HIST_RATE", + "labels": + { + "metric":"responseTimeMillis" + }, + "timeseries": + [ + { + "ts":1509843723, + "hist": + { + "bounds": + [ + 1, + 2, + 4, + 8, + 16 + ], + "buckets": + [ + 1, + 1, + 2, + 4, + 8 + ], + "inf":83 + } + }, + { + "ts":1509843738, + "hist": + { + "bounds": + [ + 1, + 2, + 4, + 8, + 16 + ], + "buckets": + [ + 2, + 2, + 4, + 8, + 16 + ], + "inf":166 + } + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/histogram_value.json b/library/cpp/monlib/encode/json/ut/histogram_value.json new file mode 100644 index 0000000000..ec1ae5cdec --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/histogram_value.json @@ -0,0 +1,33 @@ +{ + "sensors": + [ + { + "kind":"HIST", + "labels": + { + "metric":"responseTimeMillis" + }, + "ts":1509843723, + "hist": + { + "bounds": + [ + 1, + 2, + 4, + 8, + 16 + ], + "buckets": + [ + 1, + 1, + 2, + 4, + 8 + ], + "inf":83 + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/histogram_value_inf_before_bounds.json b/library/cpp/monlib/encode/json/ut/histogram_value_inf_before_bounds.json new file mode 100644 index 0000000000..f8a17c8831 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/histogram_value_inf_before_bounds.json @@ -0,0 +1,33 @@ +{ + "sensors": + [ + { + "kind":"HIST", + "labels": + { + "metric":"responseTimeMillis" + }, + "ts":1509843723, + "hist": + { + "inf":83, + "bounds": + [ + 1, + 2, + 4, + 8, + 16 + ], + "buckets": + [ + 1, + 1, + 2, + 4, + 8 + ] + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/int_gauge.json b/library/cpp/monlib/encode/json/ut/int_gauge.json new file mode 100644 index 0000000000..fbe57f873c --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/int_gauge.json @@ -0,0 +1,31 @@ +{ + "sensors": + [ + { + "kind":"IGAUGE", + "labels": + { + "metric":"a" + }, + "timeseries": + [ + { + "ts":1509843723, + "value":-9223372036854775808 + }, + { + "ts":1509843724, + "value":-1 + }, + { + "ts":1509843725, + "value":0 + }, + { + "ts":1509843726, + "value":9223372036854775807 + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/log_histogram_timeseries.json b/library/cpp/monlib/encode/json/ut/log_histogram_timeseries.json new file mode 100644 index 0000000000..e811a2cc57 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/log_histogram_timeseries.json @@ -0,0 +1,47 @@ +{ + "sensors": + [ + { + "kind":"LOGHIST", + "labels": + { + "metric":"ms" + }, + "timeseries": + [ + { + "ts":1509843723, + "log_hist": + { + "base":1.5, + "zeros_count":1, + "start_power":0, + "buckets": + [ + 0.5, + 0.25, + 0.25, + 0.5 + ] + } + }, + { + "ts":1509843738, + "log_hist": + { + "base":1.5, + "zeros_count":1, + "start_power":0, + "buckets": + [ + 1, + 0.5, + 0.5, + 1 + ] + } + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/log_histogram_value.json b/library/cpp/monlib/encode/json/ut/log_histogram_value.json new file mode 100644 index 0000000000..002478293b --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/log_histogram_value.json @@ -0,0 +1,26 @@ +{ + "sensors": + [ + { + "kind":"LOGHIST", + "labels": + { + "metric":"ms" + }, + "ts":1509843723, + "log_hist": + { + "base":1.5, + "zeros_count":1, + "start_power":0, + "buckets": + [ + 0.5, + 0.25, + 0.25, + 0.5 + ] + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/merged.json b/library/cpp/monlib/encode/json/ut/merged.json new file mode 100644 index 0000000000..ea2c99a33c --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/merged.json @@ -0,0 +1,14 @@ +{ + "sensors": + [ + { + "kind":"RATE", + "labels": + { + "metric":"hello", + "label":"world" + }, + "value":1 + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/metrics.json b/library/cpp/monlib/encode/json/ut/metrics.json new file mode 100644 index 0000000000..2be4617d51 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/metrics.json @@ -0,0 +1,43 @@ +{ + "labels": { + "project": "solomon", + "cluster": "man", + "service": "stockpile" + }, + "metrics": [ + { + "type": "DGAUGE", + "labels": { + "metric": "Memory" + }, + "value": 10 + }, + { + "type": "RATE", + "value": 1, + "labels": { "metric": "UserTime" } + }, + { + "type": "GAUGE", + "value": 3.14159, + "labels": { "export": "Oxygen", "metric": "QueueSize" }, + "ts": "2017-11-05T12:34:56.000Z", + "memOnly": true + }, + { + "type": "GAUGE", + "labels": { "metric": "Writes" }, + "timeseries": [ + { + "ts": "2017-08-28T12:32:11Z", + "value": -10 + }, + { + "value": 20, + "ts": 1503923187 + } + ] + } + ], + "ts": "2017-08-27T12:34:56Z" +} diff --git a/library/cpp/monlib/encode/json/ut/named_metrics.json b/library/cpp/monlib/encode/json/ut/named_metrics.json new file mode 100644 index 0000000000..98f93e8c39 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/named_metrics.json @@ -0,0 +1,22 @@ +{ + "labels": { + "project": "solomon", + "cluster": "prod-sas", + "service": "stockpile" + }, + "metrics": [ + { + "type": "DGAUGE", + "name": "Memory", + "value": 1 + }, + { + "type": "DGAUGE", + "name": "QueueSize", + "labels": { + "export": "Oxygen" + }, + "value": 10 + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/sensors.json b/library/cpp/monlib/encode/json/ut/sensors.json new file mode 100644 index 0000000000..4d979a3c1e --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/sensors.json @@ -0,0 +1,40 @@ +{ + "commonLabels": { + "project": "solomon", + "cluster": "man", + "service": "stockpile" + }, + "sensors": [ + { + "labels": { + "metric": "Memory" + }, + "value": 10 + }, + { + "mode": "deriv", + "value": 1, + "labels": { "metric": "UserTime" } + }, + { + "value": 3.14159, + "labels": { "export": "Oxygen", "metric": "QueueSize" }, + "ts": "2017-11-05T12:34:56.000Z", + "memOnly": true + }, + { + "labels": { "metric": "Writes" }, + "timeseries": [ + { + "ts": "2017-08-28T12:32:11Z", + "value": -10 + }, + { + "value": 20, + "ts": 1503923187 + } + ] + } + ], + "ts": "2017-08-27T12:34:56Z" +} diff --git a/library/cpp/monlib/encode/json/ut/summary_inf.json b/library/cpp/monlib/encode/json/ut/summary_inf.json new file mode 100644 index 0000000000..625a6cd8ad --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/summary_inf.json @@ -0,0 +1,21 @@ +{ + "sensors": + [ + { + "kind":"DSUMMARY", + "labels": + { + "metric":"temperature" + }, + "ts":1509843723, + "summary": + { + "sum":"nan", + "min":"-inf", + "max":"inf", + "last":0.3, + "count":30 + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/summary_timeseries.json b/library/cpp/monlib/encode/json/ut/summary_timeseries.json new file mode 100644 index 0000000000..92007af3e6 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/summary_timeseries.json @@ -0,0 +1,37 @@ +{ + "sensors": + [ + { + "kind":"DSUMMARY", + "labels": + { + "metric":"temperature" + }, + "timeseries": + [ + { + "ts":1509843723, + "summary": + { + "sum":0.8, + "min":-0.5, + "max":1, + "last":1, + "count":3 + } + }, + { + "ts":1509843738, + "summary": + { + "sum":-0.69, + "min":-1.5, + "max":1, + "last":0.01, + "count":5 + } + } + ] + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/summary_value.json b/library/cpp/monlib/encode/json/ut/summary_value.json new file mode 100644 index 0000000000..366394c5e1 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/summary_value.json @@ -0,0 +1,21 @@ +{ + "sensors": + [ + { + "kind":"DSUMMARY", + "labels": + { + "metric":"temperature" + }, + "ts":1509843723, + "summary": + { + "sum":10, + "min":-0.5, + "max":0.5, + "last":0.3, + "count":30 + } + } + ] +} diff --git a/library/cpp/monlib/encode/json/ut/test_decode_to_encode.json b/library/cpp/monlib/encode/json/ut/test_decode_to_encode.json new file mode 100644 index 0000000000..65f0c5c6e2 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/test_decode_to_encode.json @@ -0,0 +1,16 @@ +{ + "commonLabels": { + "project": "solomon", + "cluster": "man", + "service": "stockpile" + }, + "sensors": [ + { + "kind": "GAUGE", + "labels": { "export": "Oxygen", "metric": "QueueSize" }, + "ts": 1509885296, + "value": 3.14159 + } + ], + "ts": 1503837296 +} diff --git a/library/cpp/monlib/encode/json/ut/ya.make b/library/cpp/monlib/encode/json/ut/ya.make new file mode 100644 index 0000000000..e50c4f4903 --- /dev/null +++ b/library/cpp/monlib/encode/json/ut/ya.make @@ -0,0 +1,46 @@ +UNITTEST_FOR(library/cpp/monlib/encode/json) + +OWNER( + g:solomon + jamel +) + +SRCS( + json_decoder_ut.cpp + json_ut.cpp +) + +RESOURCE( + buffered_test.json /buffered_test.json + buffered_ts_merge.json /buffered_ts_merge.json + empty_series.json /empty_series.json + expected.json /expected.json + expected_buffered.json /expected_buffered.json + expected_cloud.json /expected_cloud.json + expected_cloud_buffered.json /expected_cloud_buffered.json + merged.json /merged.json + histogram_timeseries.json /histogram_timeseries.json + histogram_value.json /histogram_value.json + histogram_value_inf_before_bounds.json /histogram_value_inf_before_bounds.json + int_gauge.json /int_gauge.json + sensors.json /sensors.json + metrics.json /metrics.json + named_metrics.json /named_metrics.json + test_decode_to_encode.json /test_decode_to_encode.json + crash.json /crash.json + hist_crash.json /hist_crash.json + summary_value.json /summary_value.json + summary_inf.json /summary_inf.json + summary_timeseries.json /summary_timeseries.json + log_histogram_value.json /log_histogram_value.json + log_histogram_timeseries.json /log_histogram_timeseries.json +) + +PEERDIR( + library/cpp/json + library/cpp/monlib/consumers + library/cpp/monlib/encode/protobuf + library/cpp/resource +) + +END() |