@@ -56,27 +56,29 @@ void StdOut::sendMultiple(std::string measurement, std::vector<Metric>&& metrics
5656 if (!metricTags.empty ()) {
5757 metricTags = " ," + metricTags;
5858 }
59- mStream << " [METRIC] " << measurement << " /" << metric.getName () << " ," << metric.getType () << " "
59+ mStream << " [METRIC] " << measurement << " /" << metric.getConstName () << " ," << metric.getType () << " "
6060 << metric.getValue () << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString
6161 << metricTags << " \n " ;
6262 }
6363}
6464
6565void StdOut::send (const Metric& metric)
6666{
67- std::string metricTags{};
68- for (const auto & tag : metric.getTags ()) {
69- if (!metricTags.empty ()) {
70- metricTags += " ," ;
67+ if (metric.tagSize () == 0 ) {
68+ mStream << " [METRIC] " << metric.getConstName () << " ," << metric.getType () << " " << metric.getValue ()
69+ << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString << " \n " ;
70+ } else {
71+ std::string metricTags{};
72+ for (const auto & tag : metric.getTags ()) {
73+ metricTags += " ," + tag.name + " =" + tag.value ;
7174 }
72- metricTags += tag.name + " =" + tag.value ;
73- }
74- if (!metricTags.empty ()) {
75- metricTags = " ," + metricTags;
75+ if (tagString.empty ()) {
76+ metricTags.erase (0 , 1 );
77+ }
78+
79+ mStream << " [METRIC] " << metric.getConstName () << " ," << metric.getType () << " " << metric.getValue ()
80+ << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString << metricTags << " \n " ;
7681 }
77- mStream << " [METRIC] " << metric.getName () << " ," << metric.getType () << " " << metric.getValue ()
78- << " " << convertTimestamp (metric.getTimestamp ()) << " " << tagString << metricTags
79- << " \n " ;
8082}
8183
8284} // namespace backends
0 commit comments