aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2025-01-30 00:11:41 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2025-01-30 00:24:09 +0300
commite3a485514230672eb07f60514d2bb2094af6dabd (patch)
tree408729f20808b52b67e40c6cc4793afac40e934b
parent8c87a67e781ed7ef2027914c5d42a787f075d2e9 (diff)
downloadydb-e3a485514230672eb07f60514d2bb2094af6dabd.tar.gz
Intermediate changes
commit_hash:c284e5d683d750f2d89e1bcccb3f4d334b47d60c
-rw-r--r--contrib/python/responses/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/responses/py3/responses/py.typed2
-rw-r--r--contrib/python/responses/py3/ya.make3
-rw-r--r--library/cpp/monlib/encode/unistat/unistat.h16
-rw-r--r--library/cpp/monlib/encode/unistat/unistat_decoder.cpp43
-rw-r--r--library/cpp/monlib/encode/unistat/unistat_ut.cpp16
6 files changed, 65 insertions, 17 deletions
diff --git a/contrib/python/responses/py3/.dist-info/METADATA b/contrib/python/responses/py3/.dist-info/METADATA
index 0b507faad2..69687eb48a 100644
--- a/contrib/python/responses/py3/.dist-info/METADATA
+++ b/contrib/python/responses/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: responses
-Version: 0.25.5
+Version: 0.25.6
Summary: A utility library for mocking out the `requests` Python library.
Home-page: https://github.com/getsentry/responses
Author: David Cramer
diff --git a/contrib/python/responses/py3/responses/py.typed b/contrib/python/responses/py3/responses/py.typed
new file mode 100644
index 0000000000..6fb4e473fa
--- /dev/null
+++ b/contrib/python/responses/py3/responses/py.typed
@@ -0,0 +1,2 @@
+# Marker file for PEP 561. The mypy package uses inline types.
+# file must be here according to https://peps.python.org/pep-0561/#packaging-type-information
diff --git a/contrib/python/responses/py3/ya.make b/contrib/python/responses/py3/ya.make
index 98126673c8..f706b20e79 100644
--- a/contrib/python/responses/py3/ya.make
+++ b/contrib/python/responses/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(0.25.5)
+VERSION(0.25.6)
LICENSE(Apache-2.0)
@@ -26,6 +26,7 @@ RESOURCE_FILES(
PREFIX contrib/python/responses/py3/
.dist-info/METADATA
.dist-info/top_level.txt
+ responses/py.typed
)
END()
diff --git a/library/cpp/monlib/encode/unistat/unistat.h b/library/cpp/monlib/encode/unistat/unistat.h
index 300fb6270f..2847c2c1b1 100644
--- a/library/cpp/monlib/encode/unistat/unistat.h
+++ b/library/cpp/monlib/encode/unistat/unistat.h
@@ -6,8 +6,18 @@
namespace NMonitoring {
/// Decodes unistat-style metrics
/// https://wiki.yandex-team.ru/golovan/stat-handle
- void DecodeUnistat(TStringBuf data, class IMetricConsumer* c, TStringBuf metricNameLabel = "sensor", TInstant ts = TInstant::Zero());
+ void DecodeUnistat(
+ TStringBuf data,
+ class IMetricConsumer* c,
+ TStringBuf metricNameLabel = "sensor",
+ TStringBuf metricNamePrefix = "",
+ TInstant ts = TInstant::Zero());
/// Assumes consumer's stream is open by the caller
- void DecodeUnistatToStream(TStringBuf data, class IMetricConsumer* c, TStringBuf metricNameLabel = "sensor", TInstant ts = TInstant::Zero());
-}
+ void DecodeUnistatToStream(
+ TStringBuf data,
+ class IMetricConsumer* c,
+ TStringBuf metricNameLabel = "sensor",
+ TStringBuf metricNamePrefix = "",
+ TInstant ts = TInstant::Zero());
+} // namespace NMonitoring
diff --git a/library/cpp/monlib/encode/unistat/unistat_decoder.cpp b/library/cpp/monlib/encode/unistat/unistat_decoder.cpp
index 9484e6768a..9b56e0b6a2 100644
--- a/library/cpp/monlib/encode/unistat/unistat_decoder.cpp
+++ b/library/cpp/monlib/encode/unistat/unistat_decoder.cpp
@@ -116,9 +116,15 @@ namespace NMonitoring {
class TDecoderUnistat {
private:
public:
- explicit TDecoderUnistat(IMetricConsumer* consumer, IInputStream* is, TStringBuf metricNameLabel, TInstant ts)
+ explicit TDecoderUnistat(
+ IMetricConsumer* consumer,
+ IInputStream* is,
+ TStringBuf metricNameLabel,
+ TStringBuf metricNamePrefix,
+ TInstant ts)
: Consumer_{consumer},
- MetricNameLabel(metricNameLabel),
+ MetricNameLabel_(metricNameLabel),
+ MetricNamePrefix_(metricNamePrefix),
Timestamp_{ts} {
ReadJsonTree(is, &Json_, /* throw */ true);
}
@@ -252,7 +258,7 @@ namespace NMonitoring {
Consumer_->OnMetricBegin(MetricContext_.Type);
Consumer_->OnLabelsBegin();
- Consumer_->OnLabel(MetricNameLabel, TString{MetricContext_.Name});
+ Consumer_->OnLabel(MetricNameLabel_, TStringBuilder{} << MetricNamePrefix_ << MetricContext_.Name);
for (auto&& l : MetricContext_.Labels) {
Consumer_->OnLabel(l.Name(), l.Value());
}
@@ -284,7 +290,8 @@ namespace NMonitoring {
private:
IMetricConsumer* Consumer_;
NJson::TJsonValue Json_;
- TStringBuf MetricNameLabel;
+ TStringBuf MetricNameLabel_;
+ TStringBuf MetricNamePrefix_;
TInstant Timestamp_;
struct {
@@ -299,15 +306,27 @@ namespace NMonitoring {
}
- void DecodeUnistat(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel, TInstant ts) {
- c->OnStreamBegin();
- DecodeUnistatToStream(data, c, metricNameLabel, ts);
- c->OnStreamEnd();
+ void DecodeUnistat(
+ TStringBuf data,
+ IMetricConsumer* c,
+ TStringBuf metricNameLabel,
+ TStringBuf metricNamePrefix,
+ TInstant ts)
+ {
+ c->OnStreamBegin();
+ DecodeUnistatToStream(data, c, metricNameLabel, metricNamePrefix, ts);
+ c->OnStreamEnd();
}
- void DecodeUnistatToStream(TStringBuf data, IMetricConsumer* c, TStringBuf metricNameLabel, TInstant ts) {
- TMemoryInput in{data.data(), data.size()};
- TDecoderUnistat decoder(c, &in, metricNameLabel, ts);
- decoder.Decode();
+ void DecodeUnistatToStream(
+ TStringBuf data,
+ IMetricConsumer* c,
+ TStringBuf metricNameLabel,
+ TStringBuf metricNamePrefix,
+ TInstant ts)
+ {
+ TMemoryInput in{data.data(), data.size()};
+ TDecoderUnistat decoder(c, &in, metricNameLabel, metricNamePrefix, ts);
+ decoder.Decode();
}
}
diff --git a/library/cpp/monlib/encode/unistat/unistat_ut.cpp b/library/cpp/monlib/encode/unistat/unistat_ut.cpp
index 08b4c602ee..da31469053 100644
--- a/library/cpp/monlib/encode/unistat/unistat_ut.cpp
+++ b/library/cpp/monlib/encode/unistat/unistat_ut.cpp
@@ -23,6 +23,22 @@ Y_UNIT_TEST_SUITE(TUnistatDecoderTest) {
UNIT_ASSERT_VALUES_EQUAL(label.GetName(), "metric_name_label");
}
+ Y_UNIT_TEST(MetricNamePrefix) {
+ constexpr auto input = TStringBuf(R"([["something_axxx", 42]])");
+
+ NProto::TMultiSamplesList samples;
+ auto encoder = EncoderProtobuf(&samples);
+
+ DecodeUnistat(input, encoder.Get(), "metric_name_label", "prefix.");
+
+ UNIT_ASSERT_VALUES_EQUAL(samples.SamplesSize(), 1);
+ auto sample = samples.GetSamples(0);
+
+ auto label = sample.GetLabels(0);
+ UNIT_ASSERT_VALUES_EQUAL(label.GetName(), "metric_name_label");
+ UNIT_ASSERT_VALUES_EQUAL(label.GetValue(), "prefix.something_axxx");
+ }
+
Y_UNIT_TEST(ScalarMetric) {
constexpr auto input = TStringBuf(R"([["something_axxx", 42]])");