File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717#pragma once
1818
19+ #include < unistd.h>
20+
1921#include < photon/common/conststr.h>
2022#include < photon/common/estring.h>
2123#include < photon/common/metric-meter/metrics.h>
@@ -50,8 +52,18 @@ struct ExposeRender : public photon::net::http::HTTPHandler {
5052 EXPOSE_PHOTON_METRICLIST (count, Metric::AddCounter);
5153 EXPOSE_PHOTON_METRICLIST (cache, Metric::ValueCounter);
5254
55+ std::string node_name;
56+
5357 template <typename ... Args>
54- ExposeRender (Args&&... args) {}
58+ ExposeRender (Args&&... args) {
59+ char hostname[256 ];
60+ if (gethostname (hostname, sizeof (hostname)) == 0 ) {
61+ hostname[sizeof (hostname) - 1 ] = ' \0 ' ;
62+ node_name = hostname;
63+ } else {
64+ node_name = " unknown" ;
65+ }
66+ }
5567
5668 std::string render () {
5769 EXPOSE_TEMPLATE (alive, OverlayBD_Alive : gauge{node});
@@ -65,7 +77,7 @@ struct ExposeRender : public photon::net::http::HTTPHandler {
6577 ret.append (" \n " )
6678 .append (alive.type_str ())
6779 .append (" \n " )
68- .append (alive.render (1 ))
80+ .append (alive.render (1 , node_name. c_str () ))
6981 .append (" \n\n " );
7082 LOOP_APPEND_METRIC (ret, throughput);
7183 LOOP_APPEND_METRIC (ret, qps);
You can’t perform that action at this time.
0 commit comments