Skip to content

Commit

Permalink
Fix some bugs in plugin PromExporter. (drogonframework#2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanglong3bf authored Oct 21, 2024
1 parent ca22103 commit 284d14b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/inc/drogon/utils/monitoring/Gauge.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Gauge : public Metric

static std::string_view type()
{
return "counter";
return "gauge";
}

void setToCurrentTime()
Expand Down
9 changes: 5 additions & 4 deletions lib/src/PromExporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
}
}
Expand Down

0 comments on commit 284d14b

Please sign in to comment.