Skip to content

Commit 284d14b

Browse files
authored
Fix some bugs in plugin PromExporter. (#2189)
1 parent ca22103 commit 284d14b

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

lib/inc/drogon/utils/monitoring/Gauge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class Gauge : public Metric
9191

9292
static std::string_view type()
9393
{
94-
return "counter";
94+
return "gauge";
9595
}
9696

9797
void setToCurrentTime()

lib/src/PromExporter.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void PromExporter::initAndStart(const Json::Value &config)
2828
}
2929
auto resp = HttpResponse::newHttpResponse();
3030
resp->setBody(thisPtr->exportMetrics());
31+
resp->setContentTypeCode(CT_TEXT_PLAIN);
3132
resp->setExpiredTime(5);
3233
callback(resp);
3334
},
@@ -118,12 +119,12 @@ static std::string exportCollector(
118119
.append(collector->name())
119120
.append(" ")
120121
.append(collector->help())
121-
.append("\r\n");
122+
.append("\n");
122123
res.append("# TYPE ")
123124
.append(collector->name())
124125
.append(" ")
125126
.append(collector->type())
126-
.append("\r\n");
127+
.append("\n");
127128
for (auto const &sampleGroup : sampleGroups)
128129
{
129130
auto const &metricPtr = sampleGroup.metric;
@@ -157,11 +158,11 @@ static std::string exportCollector(
157158
res.append(" ")
158159
.append(std::to_string(
159160
sample.timestamp.microSecondsSinceEpoch() / 1000))
160-
.append("\r\n");
161+
.append("\n");
161162
}
162163
else
163164
{
164-
res.append("\r\n");
165+
res.append("\n");
165166
}
166167
}
167168
}

0 commit comments

Comments
 (0)