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()
|
static std::string_view type()
|
||||||
{
|
{
|
||||||
return "counter";
|
return "gauge";
|
||||||
}
|
}
|
||||||
|
|
||||||
void setToCurrentTime()
|
void setToCurrentTime()
|
||||||
|
|
|
@ -28,6 +28,7 @@ void PromExporter::initAndStart(const Json::Value &config)
|
||||||
}
|
}
|
||||||
auto resp = HttpResponse::newHttpResponse();
|
auto resp = HttpResponse::newHttpResponse();
|
||||||
resp->setBody(thisPtr->exportMetrics());
|
resp->setBody(thisPtr->exportMetrics());
|
||||||
|
resp->setContentTypeCode(CT_TEXT_PLAIN);
|
||||||
resp->setExpiredTime(5);
|
resp->setExpiredTime(5);
|
||||||
callback(resp);
|
callback(resp);
|
||||||
},
|
},
|
||||||
|
@ -118,12 +119,12 @@ static std::string exportCollector(
|
||||||
.append(collector->name())
|
.append(collector->name())
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(collector->help())
|
.append(collector->help())
|
||||||
.append("\r\n");
|
.append("\n");
|
||||||
res.append("# TYPE ")
|
res.append("# TYPE ")
|
||||||
.append(collector->name())
|
.append(collector->name())
|
||||||
.append(" ")
|
.append(" ")
|
||||||
.append(collector->type())
|
.append(collector->type())
|
||||||
.append("\r\n");
|
.append("\n");
|
||||||
for (auto const &sampleGroup : sampleGroups)
|
for (auto const &sampleGroup : sampleGroups)
|
||||||
{
|
{
|
||||||
auto const &metricPtr = sampleGroup.metric;
|
auto const &metricPtr = sampleGroup.metric;
|
||||||
|
@ -157,11 +158,11 @@ static std::string exportCollector(
|
||||||
res.append(" ")
|
res.append(" ")
|
||||||
.append(std::to_string(
|
.append(std::to_string(
|
||||||
sample.timestamp.microSecondsSinceEpoch() / 1000))
|
sample.timestamp.microSecondsSinceEpoch() / 1000))
|
||||||
.append("\r\n");
|
.append("\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res.append("\r\n");
|
res.append("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue