@@ -49,6 +49,26 @@ void InfluxDB::escape(std::string& escaped)
4949 boost::replace_all (escaped, " " , " \\ " );
5050}
5151
52+ void InfluxDB::sendMultiple (std::string name, std::vector<Metric>&& metrics)
53+ {
54+ escape (name);
55+ std::stringstream convert;
56+ convert << name << " ," << tagSet << " " ;
57+
58+ for (const auto & metric : metrics) {
59+ std::string value = boost::lexical_cast<std::string>(metric.getValue ());
60+ prepareValue (value, metric.getType ());
61+ convert << metric.getName () << " =" << value << " ," ;
62+ }
63+ convert.seekp (-1 , std::ios_base::end);
64+ convert << " " << convertTimestamp (metrics.back ().getTimestamp ());
65+
66+ try {
67+ transport->send (convert.str ());
68+ } catch (MonitoringInternalException&) {
69+ }
70+ }
71+
5272void InfluxDB::send (const Metric& metric)
5373{
5474 std::string metricTags{};
@@ -57,15 +77,7 @@ void InfluxDB::send(const Metric& metric)
5777 }
5878
5979 std::string value = boost::lexical_cast<std::string>(metric.getValue ());
60- if (metric.getType () == MetricType::STRING) {
61- escape (value);
62- value.insert (value.begin (), ' "' );
63- value.insert (value.end (), ' "' );
64- }
65-
66- if (metric.getType () == MetricType::INT) {
67- value.insert (value.end (), ' i' );
68- }
80+ prepareValue (value, metric.getType ());
6981 std::string name = metric.getName ();
7082 escape (name);
7183
@@ -78,6 +90,19 @@ void InfluxDB::send(const Metric& metric)
7890 }
7991}
8092
93+ void InfluxDB::prepareValue (std::string& value, int type)
94+ {
95+ if (type == MetricType::STRING) {
96+ escape (value);
97+ value.insert (value.begin (), ' "' );
98+ value.insert (value.end (), ' "' );
99+ }
100+
101+ if (type == MetricType::INT) {
102+ value.insert (value.end (), ' i' );
103+ }
104+ }
105+
81106void InfluxDB::addGlobalTag (std::string name, std::string value)
82107{
83108 escape (name); escape (value);
0 commit comments