Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/filesystem/filesystem.h" 4 : 5 : #include "source/server/admin/admin_html_util.h" 6 : #include "source/server/admin/stats_render.h" 7 : 8 : namespace Envoy { 9 : namespace Server { 10 : 11 : class StatsHtmlRender : public StatsTextRender { 12 : public: 13 : StatsHtmlRender(Http::ResponseHeaderMap& response_headers, Buffer::Instance& response, 14 : const StatsParams& params); 15 : 16 : /** 17 : * Writes the header and starts the body for a stats page based on the 18 : * supplied stats parameters. 19 : * 20 : * @param url_handler The stats URL handler. 21 : * @param params The parameters for the stats page. 22 : * @param response The buffer in which to write the HTML. 23 : */ 24 : void setupStatsPage(const Admin::UrlHandler& url_handler, const StatsParams& params, 25 : Buffer::Instance& response); 26 : 27 : // StatsTextRender 28 : void noStats(Buffer::Instance&, absl::string_view types) override; 29 : void generate(Buffer::Instance& response, const std::string& name, 30 : const std::string& value) override; 31 : 32 : // This matches the superclass impl exactly, but is needed to allow gcc to compile, which 33 : // warns about hidden overrides if we omit it. 34 0 : void generate(Buffer::Instance& response, const std::string& name, uint64_t value) override { 35 0 : StatsTextRender::generate(response, name, value); 36 0 : } 37 : 38 : void generate(Buffer::Instance&, const std::string& name, 39 : const Stats::ParentHistogram& histogram) override; 40 : void finalize(Buffer::Instance&) override; 41 : 42 : private: 43 : const bool active_{false}; 44 : bool json_histograms_{false}; 45 : bool first_histogram_{true}; 46 : }; 47 : 48 : } // namespace Server 49 : } // namespace Envoy