Merge branch 'pr2633' into dev

This commit is contained in:
Thomas Basler
2025-04-09 17:15:54 +02:00
2 changed files with 8 additions and 2 deletions

View File

@@ -42,7 +42,7 @@ build_unflags =
-std=gnu++11
lib_deps =
ESP32Async/ESPAsyncWebServer @ 3.7.4
ESP32Async/ESPAsyncWebServer @ 3.7.6
bblanchon/ArduinoJson @ 7.3.1
https://github.com/bertmelis/espMqttClient.git#v1.7.0
nrf24/RF24 @ 1.4.11

View File

@@ -20,12 +20,14 @@ void WebApiPrometheusClass::init(AsyncWebServer& server, Scheduler& scheduler)
void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* request)
{
static size_t initialResponseBufferSize = 1024;
if (!WebApi.checkCredentialsReadonly(request)) {
return;
}
try {
auto stream = request->beginResponseStream("text/plain; charset=utf-8", 40960);
auto stream = request->beginResponseStream("text/plain; charset=utf-8", initialResponseBufferSize);
stream->print("# HELP opendtu_build Build info\n");
stream->print("# TYPE opendtu_build gauge\n");
@@ -109,6 +111,10 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
}
}
stream->addHeader("Cache-Control", "no-cache");
if (stream->available() > initialResponseBufferSize) {
initialResponseBufferSize = stream->available();
MessageOutput.printf("Increased /api/prometheus/metrics initialResponseBufferSize to %" PRIu32 " bytes\r\n", initialResponseBufferSize);
}
request->send(stream);
} catch (std::bad_alloc& bad_alloc) {