Fix some bugs in plugin PromExporter. (#2189)
This commit is contained in:
parent
ca2210331d
commit
284d14b8ca
|
@ -91,7 +91,7 @@ class Gauge : public Metric
|
|||
|
||||
static std::string_view type()
|
||||
{
|
||||
return "counter";
|
||||
return "gauge";
|
||||
}
|
||||
|
||||
void setToCurrentTime()
|
||||
|
|
|
@ -28,6 +28,7 @@ void PromExporter::initAndStart(const Json::Value &config)
|
|||
}
|
||||
auto resp = HttpResponse::newHttpResponse();
|
||||
resp->setBody(thisPtr->exportMetrics());
|
||||
resp->setContentTypeCode(CT_TEXT_PLAIN);
|
||||
resp->setExpiredTime(5);
|
||||
callback(resp);
|
||||
},
|
||||
|
@ -118,12 +119,12 @@ static std::string exportCollector(
|
|||
.append(collector->name())
|
||||
.append(" ")
|
||||
.append(collector->help())
|
||||
.append("\r\n");
|
||||
.append("\n");
|
||||
res.append("# TYPE ")
|
||||
.append(collector->name())
|
||||
.append(" ")
|
||||
.append(collector->type())
|
||||
.append("\r\n");
|
||||
.append("\n");
|
||||
for (auto const &sampleGroup : sampleGroups)
|
||||
{
|
||||
auto const &metricPtr = sampleGroup.metric;
|
||||
|
@ -157,11 +158,11 @@ static std::string exportCollector(
|
|||
res.append(" ")
|
||||
.append(std::to_string(
|
||||
sample.timestamp.microSecondsSinceEpoch() / 1000))
|
||||
.append("\r\n");
|
||||
.append("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
res.append("\r\n");
|
||||
res.append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue