diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index c6de2063cd..101939f3a2 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -8,6 +8,7 @@ The changelog for SRS. ## SRS 6.0 Changelog +* v5.0, 2023-01-17, Merge [#3385](https://github.com/ossrs/srs/pull/3385): API: Support server/pid/service label for exporter and api. v6.0.16 (#3385) * v6.0, 2023-01-17, Merge [#3379](https://github.com/ossrs/srs/pull/3379): H265: Support demux vps/pps info. v6.0.15 * v6.0, 2023-01-08, Merge [#3360](https://github.com/ossrs/srs/pull/3360): H265: Support DVR HEVC stream to MP4. v6.0.14 * v6.0, 2023-01-06, Merge [#3363](https://github.com/ossrs/srs/issues/3363): HTTP: Add CORS Header for private network access. v6.0.13 @@ -29,6 +30,7 @@ The changelog for SRS. ## SRS 5.0 Changelog +* v5.0, 2023-01-17, Merge [#3385](https://github.com/ossrs/srs/pull/3385): API: Support server/pid/service label for exporter and api. v5.0.135 (#3385) * v5.0, 2023-01-17, Merge [#3383](https://github.com/ossrs/srs/pull/3383): GB: Fix PSM parsing indicator bug. v5.0.134 (#3383) * v5.0, 2023-01-08, Merge [#3308](https://github.com/ossrs/srs/pull/3308): DVR: Improve file write performance by fwrite with cache. v5.0.133 * v5.0, 2023-01-06, DVR: Support blackbox test based on hooks. v5.0.132 diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 0be1a27639..22d184d0dd 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -2606,7 +2606,7 @@ srs_error_t SrsConfig::check_normal_config() // TODO: FIXME: remove it in future. if (m == "hls_storage" || m == "hls_mount") { - srs_warn("HLS RAM is removed in SRS3+, read https://github.com/ossrs/srs/issues/513."); + srs_warn("HLS RAM is removed in SRS3+"); } } } else if (n == "http_hooks") { diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 3062231e50..3696f2c1bd 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -184,6 +184,8 @@ srs_error_t SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* urls = SrsJsonAny::object(); obj->set("urls", urls); @@ -222,6 +224,8 @@ srs_error_t SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* urls = SrsJsonAny::object(); obj->set("urls", urls); @@ -248,6 +252,8 @@ srs_error_t SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* urls = SrsJsonAny::object(); obj->set("urls", urls); @@ -297,6 +303,8 @@ srs_error_t SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -326,6 +334,8 @@ srs_error_t SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMes obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); srs_api_dump_summaries(obj); @@ -349,6 +359,8 @@ srs_error_t SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -394,6 +406,8 @@ srs_error_t SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsHtt obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -471,6 +485,8 @@ srs_error_t SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, ISrsH obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -510,6 +526,8 @@ srs_error_t SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -550,6 +568,8 @@ srs_error_t SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -577,6 +597,8 @@ srs_error_t SrsGoApiFeatures::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -645,6 +667,8 @@ srs_error_t SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); SrsJsonObject* data = SrsJsonAny::object(); obj->set("data", data); @@ -700,6 +724,8 @@ srs_error_t SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessag obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); if (r->is_http_get()) { if (!vhost) { @@ -756,6 +782,8 @@ srs_error_t SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); if (r->is_http_get()) { if (!stream) { @@ -816,6 +844,8 @@ srs_error_t SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); obj->set("server", SrsJsonAny::str(stat->server_id().c_str())); + obj->set("service", SrsJsonAny::str(stat->service_id().c_str())); + obj->set("pid", SrsJsonAny::str(stat->service_pid().c_str())); if (r->is_http_get()) { if (!client) { @@ -1121,6 +1151,9 @@ srs_error_t SrsGoApiMetrics::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa ss << "# HELP srs_build_info A metric with a constant '1' value labeled by build_date, version from which SRS was built.\n" << "# TYPE srs_build_info gauge\n" << "srs_build_info{" + << "server=\"" << stat->server_id() << "\"," + << "service=\"" << stat->service_id() << "\"," + << "pid=\"" << stat->service_pid() << "\"," << "build_date=\"" << SRS_BUILD_DATE << "\"," << "major=\"" << VERSION_MAJOR << "\"," << "version=\"" << RTMP_SIG_SRS_VERSION << "\"," diff --git a/trunk/src/app/srs_app_rtc_api.cpp b/trunk/src/app/srs_app_rtc_api.cpp index da932a2a45..1d5a657625 100644 --- a/trunk/src/app/srs_app_rtc_api.cpp +++ b/trunk/src/app/srs_app_rtc_api.cpp @@ -170,6 +170,8 @@ srs_error_t SrsGoApiRtcPlay::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMe res->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); res->set("server", SrsJsonAny::str(SrsStatistic::instance()->server_id().c_str())); + res->set("service", SrsJsonAny::str(SrsStatistic::instance()->service_id().c_str())); + res->set("pid", SrsJsonAny::str(SrsStatistic::instance()->service_pid().c_str())); // TODO: add candidates in response json? res->set("sdp", SrsJsonAny::str(ruc.local_sdp_str_.c_str())); @@ -451,6 +453,8 @@ srs_error_t SrsGoApiRtcPublish::do_serve_http(ISrsHttpResponseWriter* w, ISrsHtt res->set("code", SrsJsonAny::integer(ERROR_SUCCESS)); res->set("server", SrsJsonAny::str(SrsStatistic::instance()->server_id().c_str())); + res->set("service", SrsJsonAny::str(SrsStatistic::instance()->service_id().c_str())); + res->set("pid", SrsJsonAny::str(SrsStatistic::instance()->service_pid().c_str())); // TODO: add candidates in response json? res->set("sdp", SrsJsonAny::str(ruc.local_sdp_str_.c_str())); diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 01954b55b4..a355b84976 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -566,6 +566,24 @@ std::string SrsStatistic::server_id() return server_id_; } +std::string SrsStatistic::service_id() +{ + if (service_id_.empty()) { + service_id_ = srs_random_str(8); + } + + return service_id_; +} + +std::string SrsStatistic::service_pid() +{ + if (service_pid_.empty()) { + service_pid_ = srs_int2str(getpid()); + } + + return service_pid_; +} + srs_error_t SrsStatistic::dumps_vhosts(SrsJsonArray* arr) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 27f684775e..82e6bb6f1e 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -128,6 +128,10 @@ class SrsStatistic static SrsStatistic *_instance; // The id to identify the sever. std::string server_id_; + // The id to identify the service. + std::string service_id_; + // The pid to identify the service process. + std::string service_pid_; private: // The key: vhost id, value: vhost object. std::map vhosts; @@ -201,6 +205,10 @@ class SrsStatistic // Get the server id, used to identify the server. // For example, when restart, the server id must changed. virtual std::string server_id(); + // Get the service id, used to identify the restart of service. + virtual std::string service_id(); + // Get the service pid, used to identify the service process. + virtual std::string service_pid(); // Dumps the vhosts to amf0 array. virtual srs_error_t dumps_vhosts(SrsJsonArray* arr); // Dumps the streams to amf0 array. diff --git a/trunk/src/core/srs_core_version5.hpp b/trunk/src/core/srs_core_version5.hpp index 11c6f1a90d..17b87f69bb 100644 --- a/trunk/src/core/srs_core_version5.hpp +++ b/trunk/src/core/srs_core_version5.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 0 -#define VERSION_REVISION 134 +#define VERSION_REVISION 135 #endif diff --git a/trunk/src/core/srs_core_version6.hpp b/trunk/src/core/srs_core_version6.hpp index 75444c1c85..c4c434e8d1 100644 --- a/trunk/src/core/srs_core_version6.hpp +++ b/trunk/src/core/srs_core_version6.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 6 #define VERSION_MINOR 0 -#define VERSION_REVISION 15 +#define VERSION_REVISION 16 #endif