AI: Remove cloud CLS and APM. v7.0.66 (#4456)

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
This commit is contained in:
Winlin 2025-08-28 10:37:57 -04:00 committed by GitHub
parent 6f039eb605
commit 7a927c5bae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
19 changed files with 24 additions and 3608 deletions

View File

@ -115,11 +115,7 @@ else
srs_undefine_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_APM == YES ]]; then
srs_define_macro "SRS_APM" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_APM" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_UTEST == YES ]]; then
srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H

View File

@ -64,6 +64,7 @@ SRS_SHARED_SRTP=RESERVED
SRS_GCOV=NO
# Whether enable cloud logging and APM(Application Performance Monitor).
SRS_APM=NO
# whether enable the log verbose/info/trace level.
# always enable the warn/error level.
SRS_LOG_VERBOSE=NO
@ -185,7 +186,6 @@ Features:
--gb28181=on|off Whether build the GB28181. Default: $(value2switch $SRS_GB28181)
--ffmpeg-fit=on|off Whether enable the FFmpeg fit(source code). Default: $(value2switch $SRS_FFMPEG_FIT)
--ffmpeg-opus=on|off Whether enable the FFmpeg native opus codec. Default: $(value2switch $SRS_FFMPEG_OPUS)
--apm=on|off Whether enable cloud logging and APM(Application Performance Monitor). Default: $(value2switch $SRS_APM)
--prefix=<path> The absolute installation path. Default: $SRS_PREFIX
--jobs[=N] Allow N jobs at once; infinite jobs with no arg. Default: $SRS_JOBS
@ -265,6 +265,7 @@ Removed:
--cygwin64 No support cygwin64 anymore.
--cxx11=off Always disable C++11, force C++98 compatibility. Default: $(value2switch $SRS_CXX11)
--cxx14=off Always disable C++14, force C++98 compatibility. Default: $(value2switch $SRS_CXX14)
--apm=off No support APM(Application Performance Monitor) anymore.
For example:
./configure
@ -504,7 +505,6 @@ fi
# Apply auto options
#####################################################################################
function apply_auto_options() {
if [[ $SRS_CROSS_BUILD == YES ]]; then
if [[ $SRS_CROSS_BUILD_PREFIX != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
SRS_CROSS_BUILD_HOST=$(echo $SRS_CROSS_BUILD_PREFIX| sed 's/-$//g')
@ -580,8 +580,6 @@ function apply_auto_options() {
SRS_SRTP_ASM=NO
fi
# Force single thread mode always - multi-threading support has been removed
if [[ $SRS_SINGLE_THREAD != YES ]]; then
echo "Warning: Multi-threading support has been removed. Forcing single thread mode."
@ -601,8 +599,9 @@ function apply_auto_options() {
fi
# parse the jobs for make
if [[ ! -z SRS_JOBS ]]; then
if [[ ! -z $SRS_JOBS ]]; then
export SRS_JOBS="--jobs=${SRS_JOBS}"
echo "Export SRS_JOBS=$SRS_JOBS"
fi
# H.265/HEVC is always enabled, see https://github.com/ossrs/srs/issues/4349
@ -610,6 +609,11 @@ function apply_auto_options() {
echo "Warning: --h265 option is deprecated. H.265/HEVC support is always enabled."
SRS_H265=ON
fi
if [[ $SRS_APM == YES ]]; then
echo "Warning: APM(Application Performance Monitor) is no longer supported."
SRS_APM=NO
fi
}
apply_auto_options
@ -693,7 +697,7 @@ function regenerate_options() {
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-trace=$(value2switch $SRS_LOG_TRACE)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --log-level_v2=$(value2switch $SRS_LOG_LEVEL_V2)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --gcov=$(value2switch $SRS_GCOV)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --apm=$(value2switch $SRS_APM)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug=$(value2switch $SRS_DEBUG)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-nack-drop=$(value2switch $SRS_DEBUG_NACK_DROP)"

View File

@ -2159,88 +2159,6 @@ vhost cluster.srs.com {
}
}
#############################################################################################
# Tencent Cloud sections
#############################################################################################
# TencentCloud CLS(Cloud Log Service) config, logging to cloud.
# See https://cloud.tencent.com/document/product/614/11254
tencentcloud_cls {
# Whether CLS is enabled.
# Overwrite by env SRS_TENCENTCLOUD_CLS_ENABLED
# default: off
enabled off;
# The logging label to category the cluster servers.
# Overwrite by env SRS_TENCENTCLOUD_CLS_LABEL
label cn-beijing;
# The logging tag to category the cluster servers.
# Overwrite by env SRS_TENCENTCLOUD_CLS_TAG
tag cn-edge;
# The SecretId to access CLS service, see https://console.cloud.tencent.com/cam/capi
# Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_ID
secret_id AKIDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
# The SecretKey to access CLS service, see https://console.cloud.tencent.com/cam/capi
# Overwrite by env SRS_TENCENTCLOUD_CLS_SECRET_KEY
secret_key xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
# The endpoint of CLS, format as <Region>.cls.tencentcs.com. For example:
# ap-guangzhou.cls.tencentcs.com
# Note that tencentyun.com is for internal network, while tencentcs.com is for public internet.
# See https://cloud.tencent.com/document/product/614/18940
# Overwrite by env SRS_TENCENTCLOUD_CLS_ENDPOINT
endpoint ap-guangzhou.cls.tencentcs.com;
# The topic ID of CLS, see https://cloud.tencent.com/document/product/614/41035
# Overwrite by env SRS_TENCENTCLOUD_CLS_TOPIC_ID
topic_id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx;
# Whether enable logging for each log sending.
# Overwrite by env SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING
# Default: off
debug_logging off;
# Whether enable the heartbeat stat every (5 * heartbeat_ratio)s.
# Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT
# Default: on
stat_heartbeat on;
# Setup the heartbeat interval ratio, 1 means 5s, 2 means 10s, etc.
# Overwrite by env SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO
# Default: 1
heartbeat_ratio 1;
# Whether enable the streams stat every (5 * streams_ratio)s.
# Overwrite by env SRS_TENCENTCLOUD_CLS_STAT_STREAMS
# Default: on
stat_streams on;
# Setup the streams interval ratio, 1 means 5s, 2 means 10s, etc.
# Overwrite by env SRS_TENCENTCLOUD_CLS_STREAMS_RATIO
# Default: 1
streams_ratio 1;
}
# TencentCloud APM(Application Performance Management) config.
# See https://cloud.tencent.com/document/product/1463/57462
tencentcloud_apm {
# Whether APM is enabled.
# Overwrite by env SRS_TENCENTCLOUD_APM_ENABLED
# default: off
enabled on;
# The APM team or business system ID, to which spans belongs to. For example, the team is apm-FsOsPOIMl (just an
# example, not available), please get your team from https://console.cloud.tencent.com/apm/monitor/team
# Overwrite by env SRS_TENCENTCLOUD_APM_TEAM
team apm-xxxxxxxxx;
# The APM token for authentication. For example, the token is xzddEaegsxGadEpGEDFx (just an example, not available),
# please get your token from https://console.cloud.tencent.com/apm/monitor/access
# Overwrite by env SRS_TENCENTCLOUD_APM_TOKEN
token xxxxxxxx;
# The APM endpoint. See https://github.com/open-telemetry/opentelemetry-go/tree/main/exporters/otlp/otlptrace
# Please note that 4317 is for GRPC/HTTP2, while SRS only support HTTP and the port shoule be 55681.
# Overwrite by env SRS_TENCENTCLOUD_APM_ENDPOINT
endpoint ap-guangzhou.apm.tencentcs.com:55681;
# The service.name of resource.
# Overwrite by env SRS_TENCENTCLOUD_APM_SERVICE_NAME
# Default: srs-server
service_name srs-server;
# Whether enable logging for each log sending.
# Overwrite by env SRS_TENCENTCLOUD_APM_DEBUG_LOGGING
# Default: off
debug_logging off;
}
#############################################################################################
# heartbeat/stats sections
#############################################################################################

4
trunk/configure vendored
View File

@ -329,9 +329,7 @@ MODULE_FILES+=("srs_app_rtc_conn" "srs_app_rtc_dtls" "srs_app_rtc_sdp" "srs_app_
if [[ $SRS_RTSP == YES ]]; then
MODULE_FILES+=("srs_app_rtsp_source" "srs_app_rtsp_conn")
fi
if [[ $SRS_APM == YES ]]; then
MODULE_FILES+=("srs_app_tencentcloud")
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
MODULE_FILES+=("srs_app_rtc_codec")
fi

View File

@ -7,6 +7,7 @@ The changelog for SRS.
<a name="v7-changes"></a>
## SRS 7.0 Changelog
* v7.0, 2025-08-28, Merge [#4456](https://github.com/ossrs/srs/pull/4456): AI: Remove cloud CLS and APM. v7.0.66 (#4456)
* v7.0, 2025-08-27, Merge [#4455](https://github.com/ossrs/srs/pull/4455): Gather utility functions to kernel or protocol. v7.0.65 (#4455)
* v7.0, 2025-08-27, Merge [#4454](https://github.com/ossrs/srs/pull/4454): AI: Config: Move RTMP configs to rtmp{} section. v7.0.64 (#4454)
* v7.0, 2025-08-26, Merge [#4451](https://github.com/ossrs/srs/pull/4451): RTC: Fix null pointer crash in RTC2RTMP when start packet is missing. v7.0.63 (#4451)

View File

@ -3437,348 +3437,6 @@ int SrsConfig::get_dying_pulse()
return ::atoi(conf->arg0().c_str());
}
bool SrsConfig::get_tencentcloud_cls_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_cls.enabled"); // SRS_TENCENTCLOUD_CLS_ENABLED
static bool DEFAULT = false;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("enabled");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_FALSE(conf->arg0());
}
bool SrsConfig::get_tencentcloud_cls_stat_heartbeat()
{
SRS_OVERWRITE_BY_ENV_BOOL2("srs.tencentcloud_cls.stat_heartbeat"); // SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT
static bool DEFAULT = true;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("stat_heartbeat");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_TRUE(conf->arg0());
}
bool SrsConfig::get_tencentcloud_cls_stat_streams()
{
SRS_OVERWRITE_BY_ENV_BOOL2("srs.tencentcloud_cls.stat_streams"); // SRS_TENCENTCLOUD_CLS_STAT_STREAMS
static bool DEFAULT = true;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("stat_streams");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_TRUE(conf->arg0());
}
bool SrsConfig::get_tencentcloud_cls_debug_logging()
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_cls.debug_logging"); // SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING
static bool DEFAULT = false;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("debug_logging");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_FALSE(conf->arg0());
}
int SrsConfig::get_tencentcloud_cls_heartbeat_ratio()
{
SRS_OVERWRITE_BY_ENV_INT("srs.tencentcloud_cls.heartbeat_ratio"); // SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO
static int DEFAULT = 1;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("heartbeat_ratio");
if (!conf) {
return DEFAULT;
}
return ::atoi(conf->arg0().c_str());
}
int SrsConfig::get_tencentcloud_cls_streams_ratio()
{
SRS_OVERWRITE_BY_ENV_INT("srs.tencentcloud_cls.streams_ratio"); // SRS_TENCENTCLOUD_CLS_STREAMS_RATIO
static int DEFAULT = 1;
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("streams_ratio");
if (!conf) {
return DEFAULT;
}
return ::atoi(conf->arg0().c_str());
}
string SrsConfig::get_tencentcloud_cls_label()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.label"); // SRS_TENCENTCLOUD_CLS_LABEL
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("label");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_cls_tag()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.tag"); // SRS_TENCENTCLOUD_CLS_TAG
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("tag");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_cls_secret_id()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.secret_id"); // SRS_TENCENTCLOUD_CLS_SECRET_ID
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("secret_id");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_cls_secret_key()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.secret_key"); // SRS_TENCENTCLOUD_CLS_SECRET_KEY
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("secret_key");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_cls_endpoint()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.endpoint"); // SRS_TENCENTCLOUD_CLS_ENDPOINT
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("endpoint");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_cls_topic_id()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_cls.topic_id"); // SRS_TENCENTCLOUD_CLS_TOPIC_ID
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_cls");
if (!conf) {
return DEFAULT;
}
conf = conf->get("topic_id");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
bool SrsConfig::get_tencentcloud_apm_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_apm.enabled"); // SRS_TENCENTCLOUD_APM_ENABLED
static bool DEFAULT = false;
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("enabled");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_FALSE(conf->arg0());
}
string SrsConfig::get_tencentcloud_apm_team()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.team"); // SRS_TENCENTCLOUD_APM_TEAM
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("team");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_apm_token()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.token"); // SRS_TENCENTCLOUD_APM_TOKEN
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("token");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_apm_endpoint()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.endpoint"); // SRS_TENCENTCLOUD_APM_ENDPOINT
static string DEFAULT = "";
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("endpoint");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
string SrsConfig::get_tencentcloud_apm_service_name()
{
SRS_OVERWRITE_BY_ENV_STRING("srs.tencentcloud_apm.service_name"); // SRS_TENCENTCLOUD_APM_SERVICE_NAME
static string DEFAULT = "srs-server";
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("service_name");
if (!conf) {
return DEFAULT;
}
return conf->arg0();
}
bool SrsConfig::get_tencentcloud_apm_debug_logging()
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.tencentcloud_apm.debug_logging"); // SRS_TENCENTCLOUD_APM_DEBUG_LOGGING
static bool DEFAULT = false;
SrsConfDirective *conf = root->get("tencentcloud_apm");
if (!conf) {
return DEFAULT;
}
conf = conf->get("debug_logging");
if (!conf) {
return DEFAULT;
}
return SRS_CONF_PREFER_FALSE(conf->arg0());
}
bool SrsConfig::get_exporter_enabled()
{
SRS_OVERWRITE_BY_ENV_BOOL("srs.exporter.enabled"); // SRS_EXPORTER_ENABLED

View File

@ -486,26 +486,7 @@ public:
virtual int get_critical_pulse();
virtual int get_dying_threshold();
virtual int get_dying_pulse();
// TencentCloud service section.
public:
virtual bool get_tencentcloud_cls_enabled();
virtual bool get_tencentcloud_cls_stat_heartbeat();
virtual bool get_tencentcloud_cls_stat_streams();
virtual bool get_tencentcloud_cls_debug_logging();
virtual int get_tencentcloud_cls_heartbeat_ratio();
virtual int get_tencentcloud_cls_streams_ratio();
virtual std::string get_tencentcloud_cls_label();
virtual std::string get_tencentcloud_cls_tag();
virtual std::string get_tencentcloud_cls_secret_id();
virtual std::string get_tencentcloud_cls_secret_key();
virtual std::string get_tencentcloud_cls_endpoint();
virtual std::string get_tencentcloud_cls_topic_id();
virtual bool get_tencentcloud_apm_enabled();
virtual std::string get_tencentcloud_apm_team();
virtual std::string get_tencentcloud_apm_token();
virtual std::string get_tencentcloud_apm_endpoint();
virtual std::string get_tencentcloud_apm_service_name();
virtual bool get_tencentcloud_apm_debug_logging();
// stream_caster section
public:
// Get all stream_caster in config file.

View File

@ -20,7 +20,7 @@ using namespace std;
#include <srs_app_rtmp_conn.hpp>
#include <srs_app_source.hpp>
#include <srs_app_st.hpp>
#include <srs_app_tencentcloud.hpp>
#include <srs_app_utility.hpp>
#include <srs_core_autofree.hpp>
#include <srs_kernel_balance.hpp>
@ -109,11 +109,6 @@ srs_error_t SrsEdgeRtmpUpstream::connect(ISrsRequest *r, SrsLbRoundRobin *lb)
srs_utime_t sto = SRS_CONSTS_RTMP_PULSE;
sdk = new SrsSimpleRtmpClient(url, cto, sto);
#ifdef SRS_APM
// Create a client span and store it to an AMF0 propagator.
SrsUniquePtr<ISrsApmSpan> span_client(_srs_apm->inject(_srs_apm->span("edge-pull")->set_kind(SrsApmKindClient)->as_child(_srs_apm->load()), sdk->extra_args()));
#endif
if ((err = sdk->connect()) != srs_success) {
return srs_error_wrap(err, "edge pull %s failed, cto=%dms, sto=%dms.", url.c_str(), srsu2msi(cto), srsu2msi(sto));
}
@ -431,13 +426,6 @@ srs_error_t SrsEdgeIngester::initialize(SrsSharedPtr<SrsLiveSource> s, SrsPlayEd
edge = e;
req = r;
#ifdef SRS_APM
// We create a dedicate span for edge ingester, and all players will link to this one.
// Note that we use a producer span and end it immediately.
srs_assert(!span_main_);
span_main_ = _srs_apm->span("edge")->set_kind(SrsApmKindProducer)->end();
#endif
return srs_success;
}
@ -490,13 +478,6 @@ srs_error_t SrsEdgeIngester::cycle()
{
srs_error_t err = srs_success;
#ifdef SRS_APM
// Save span from parent coroutine to current coroutine context, so that we can load if in this coroutine, for
// example to use it in SrsEdgeRtmpUpstream which use RTMP or FLV client to connect to upstream server.
_srs_apm->store(span_main_);
srs_assert(span_main_);
#endif
while (true) {
// We always check status first.
// @see https://github.com/ossrs/srs/issues/1634#issuecomment-597571561
@ -807,12 +788,6 @@ srs_error_t SrsEdgeForwarder::start()
srs_utime_t sto = SRS_CONSTS_RTMP_TIMEOUT;
sdk = new SrsSimpleRtmpClient(url, cto, sto);
#ifdef SRS_APM
// Create a client span and store it to an AMF0 propagator.
// Note that we are able to load the span from coroutine context because in the same coroutine.
SrsUniquePtr<ISrsApmSpan> span_client(_srs_apm->inject(_srs_apm->span("edge-push")->set_kind(SrsApmKindClient)->as_child(_srs_apm->load()), sdk->extra_args()));
#endif
if ((err = sdk->connect()) != srs_success) {
return srs_error_wrap(err, "sdk connect %s failed, cto=%dms, sto=%dms.", url.c_str(), srsu2msi(cto), srsu2msi(sto));
}
@ -1006,17 +981,6 @@ srs_error_t SrsPlayEdge::on_client_play()
return srs_error_new(ERROR_RTMP_EDGE_PLAY_STATE, "state is stopping");
}
#ifdef SRS_APM
// APM bind client span to edge span, which fetch stream from upstream server.
// We create a new span to link the two span, because these two spans might be ended.
if (ingester->span() && _srs_apm->load()) {
ISrsApmSpan *from = _srs_apm->span("play-link")->as_child(_srs_apm->load());
ISrsApmSpan *to = _srs_apm->span("edge-link")->as_child(ingester->span())->link(from);
srs_freep(from);
srs_freep(to);
}
#endif
return err;
}

View File

@ -33,7 +33,6 @@ class SrsHttpClient;
class ISrsHttpMessage;
class SrsHttpFileReader;
class SrsFlvDecoder;
class ISrsApmSpan;
// The state of edge, auto machine
enum SrsEdgeState {
@ -158,9 +157,7 @@ private:
SrsCoroutine *trd;
SrsLbRoundRobin *lb;
SrsEdgeUpstream *upstream;
#ifdef SRS_APM
ISrsApmSpan *span_main_;
#endif
public:
SrsEdgeIngester();
virtual ~SrsEdgeIngester();
@ -170,10 +167,7 @@ public:
virtual srs_error_t start();
virtual void stop();
virtual std::string get_curr_origin();
#ifdef SRS_APM
// Get the current main span. Note that it might be NULL.
ISrsApmSpan *span();
#endif
// Interface ISrsReusableThread2Handler
public:
virtual srs_error_t cycle();

View File

@ -21,7 +21,7 @@
#include <srs_app_server.hpp>
#include <srs_app_source.hpp>
#include <srs_app_stream_token.hpp>
#include <srs_app_tencentcloud.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_utility.hpp>
@ -347,16 +347,6 @@ srs_error_t SrsHybridServer::initialize()
return srs_error_wrap(err, "dvr async");
}
#ifdef SRS_APM
// Initialize TencentCloud CLS object.
if ((err = _srs_cls->initialize()) != srs_success) {
return srs_error_wrap(err, "cls client");
}
if ((err = _srs_apm->initialize()) != srs_success) {
return srs_error_wrap(err, "apm client");
}
#endif
// Register some timers.
timer20ms_->subscribe(clock_monitor_);
timer5s_->subscribe(this);
@ -585,20 +575,6 @@ srs_error_t SrsHybridServer::on_timer(srs_utime_t interval)
epoll_desc.c_str(), sched_desc.c_str(), clock_desc.c_str(),
thread_desc.c_str(), free_desc.c_str(), objs_desc.c_str());
#ifdef SRS_APM
// Report logs to CLS if enabled.
if ((err = _srs_cls->report()) != srs_success) {
srs_warn("ignore cls err %s", srs_error_desc(err).c_str());
srs_freep(err);
}
// Report logs to APM if enabled.
if ((err = _srs_apm->report()) != srs_success) {
srs_warn("ignore apm err %s", srs_error_desc(err).c_str());
srs_freep(err);
}
#endif
return err;
}
@ -811,12 +787,6 @@ srs_error_t srs_global_initialize()
// Create global async worker for DVR.
_srs_dvr_async = new SrsAsyncCallWorker();
#ifdef SRS_APM
// Initialize global TencentCloud CLS object.
_srs_cls = new SrsClsClient();
_srs_apm = new SrsApmClient();
#endif
_srs_reload_err = srs_success;
_srs_reload_state = SrsReloadStateInit;
_srs_reload_id = srs_rand_gen_str(7);

View File

@ -10,7 +10,7 @@
#include <srs_app_http_client.hpp>
#include <srs_app_http_conn.hpp>
#include <srs_app_statistic.hpp>
#include <srs_app_tencentcloud.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_uuid.hpp>
#include <srs_core_autofree.hpp>
@ -172,14 +172,6 @@ void srs_build_features(stringstream &ss)
SRS_CHECK_FEATURE(transcode, ss);
SRS_CHECK_FEATURE(security, ss);
SRS_CHECK_FEATURE2(_srs_config_by_env, "env", ss);
#ifdef SRS_APM
SRS_CHECK_FEATURE2(_srs_cls->enabled(), "cls", ss);
SRS_CHECK_FEATURE3(_srs_cls->nn_logs(), "logs", _srs_cls->nn_logs(), ss);
SRS_CHECK_FEATURE2(_srs_apm->enabled(), "apm", ss);
SRS_CHECK_FEATURE3(_srs_apm->nn_spans(), "spans", _srs_apm->nn_spans(), ss);
#endif
}
SrsLatestVersion::SrsLatestVersion()

View File

@ -29,7 +29,7 @@ using namespace std;
#include <srs_app_st.hpp>
#include <srs_app_statistic.hpp>
#include <srs_app_stream_token.hpp>
#include <srs_app_tencentcloud.hpp>
#include <srs_app_utility.hpp>
#include <srs_core_autofree.hpp>
#include <srs_core_performance.hpp>
@ -188,11 +188,7 @@ SrsRtmpConn::SrsRtmpConn(SrsServer *svr, SrsRtmpTransport *transport, string cip
ip = cip;
port = cport;
create_time = srsu2ms(srs_time_now_cached());
#ifdef SRS_APM
span_main_ = _srs_apm->dummy();
span_connect_ = _srs_apm->dummy();
span_client_ = _srs_apm->dummy();
#endif
trd = new SrsSTCoroutine("rtmp", this, _srs_context->get_id());
kbps = new SrsNetworkKbps();
@ -260,14 +256,6 @@ srs_error_t SrsRtmpConn::do_cycle()
{
srs_error_t err = srs_success;
#ifdef SRS_APM
// We should keep the root span to alive util connection closed.
// Note that we use producer and consumer span because RTMP connection is long polling connection.
// Note that we also store this span in coroutine context, so that edge could load it.
srs_freep(span_main_);
span_main_ = _srs_apm->span("rtmp")->set_kind(SrsApmKindServer)->attr("cip", ip)->attr("cid", _srs_context->get_id().c_str());
#endif
#ifdef SRS_APM
srs_trace("RTMP client transport=%s, ip=%s:%d, fd=%d, trace=%s, span=%s", transport_->transport_type(), ip.c_str(), port, srs_netfd_fileno(transport_->fd()),
span_main_->format_trace_id(), span_main_->format_span_id());
@ -292,15 +280,6 @@ srs_error_t SrsRtmpConn::do_cycle()
srs_trace("RTMP proxy real client ip=%s", rips.c_str());
}
#ifdef SRS_APM
// Update the real IP of client, also set the HTTP fields.
span_main_->attr("rip", rip ? rips : ip)->attr("http.client_ip", rip ? rips : ip);
// The span for RTMP connecting to application.
srs_freep(span_connect_);
span_connect_ = _srs_apm->span("connect")->as_child(span_main_);
#endif
ISrsRequest *req = info->req;
if ((err = rtmp->connect_app(req)) != srs_success) {
return srs_error_wrap(err, "rtmp connect tcUrl");
@ -339,12 +318,6 @@ srs_error_t SrsRtmpConn::do_cycle()
srs_trace("edge-srs ip=%s, version=%s, pid=%d, id=%d",
srs_server_ip.c_str(), srs_version.c_str(), srs_pid, srs_id);
}
#ifdef SRS_APM
// Load the span from the AMF0 object propagator.
// Note that we will update the trace id, so please make sure no spans are ended before this.
_srs_apm->extract(span_main_, req->args);
#endif
}
if ((err = service_cycle()) != srs_success) {
@ -598,22 +571,11 @@ srs_error_t SrsRtmpConn::stream_service_cycle()
srs_trace("client identified, type=%s, vhost=%s, app=%s, stream=%s, param=%s, duration=%dms",
srs_client_type_string(info->type).c_str(), req->vhost.c_str(), req->app.c_str(), req->stream.c_str(), req->param.c_str(), srsu2msi(req->duration));
#ifdef SRS_APM
// Start APM only when client is identified, because it might republish.
srs_freep(span_client_);
span_client_ = _srs_apm->span("client")->as_child(span_connect_)->attr("type", srs_client_type_string(info->type))->attr("url", req->get_stream_url())->attr("http.url", req->get_stream_url());
// We store the span to coroutine context, for edge to load it.
_srs_apm->store(span_client_);
#endif
// discovery vhost, resolve the vhost from config
SrsConfDirective *parsed_vhost = _srs_config->get_vhost(req->vhost);
if (parsed_vhost) {
req->vhost = parsed_vhost->arg0();
}
#ifdef SRS_APM
span_client_->attr("vhost", req->vhost)->attr("http.host", req->host)->attr("http.server_name", req->vhost)->attr("http.target", srs_fmt_sprintf("/%s/%s", req->app.c_str(), req->stream.c_str()));
#endif
if (req->schema.empty() || req->vhost.empty() || req->port == 0 || req->app.empty()) {
return srs_error_new(ERROR_RTMP_REQ_TCURL, "discovery tcUrl failed, tcUrl=%s, schema=%s, vhost=%s, port=%d, app=%s",
@ -912,10 +874,6 @@ srs_error_t SrsRtmpConn::do_playing(SrsSharedPtr<SrsLiveSource> source, SrsLiveC
srs_trace("start play smi=%dms, mw_sleep=%d, mw_msgs=%d, realtime=%d, tcp_nodelay=%d",
srsu2msi(send_min_interval), srsu2msi(mw_sleep), mw_msgs, realtime, tcp_nodelay);
#ifdef SRS_APM
SrsUniquePtr<ISrsApmSpan> span(_srs_apm->span("play-cycle")->set_kind(SrsApmKindProducer)->as_child(span_client_)->attr("realtime", srs_fmt_sprintf("%d", realtime))->end());
#endif
while (true) {
// when source is set to expired, disconnect it.
if ((err = trd->pull()) != srs_success) {
@ -1711,15 +1669,6 @@ srs_error_t SrsRtmpConn::cycle()
// Serve the client.
err = do_cycle();
#ifdef SRS_APM
// Final APM span, parent is the last span, not the root span. Note that only client or server kind will be filtered
// for error or exception report.
SrsUniquePtr<ISrsApmSpan> span_final(_srs_apm->span("final")->set_kind(SrsApmKindServer)->as_child(span_client_));
if (srs_error_code(err) != 0) {
span_final->record_error(err)->set_status(SrsApmStatusError, srs_fmt_sprintf("fail code=%d", srs_error_code(err)));
}
#endif
// Update statistic when done.
SrsStatistic *stat = SrsStatistic::instance();
stat->kbps_add_delta(get_id().c_str(), delta_);

View File

@ -39,7 +39,7 @@ class ISrsWakable;
class SrsCommonMessage;
class SrsPacket;
class SrsNetworkDelta;
class ISrsApmSpan;
class SrsSslConnection;
// The simple rtmp client for SRS.
@ -169,10 +169,6 @@ private:
// The create time in milliseconds.
// for current connection to log self create time and calculate the living time.
int64_t create_time;
// The span for tracing connection establishment.
ISrsApmSpan *span_main_;
ISrsApmSpan *span_connect_;
ISrsApmSpan *span_client_;
public:
SrsRtmpConn(SrsServer *svr, SrsRtmpTransport *transport, std::string cip, int port);

View File

@ -12,7 +12,7 @@ using namespace std;
#include <srs_app_config.hpp>
#include <srs_app_conn.hpp>
#include <srs_app_tencentcloud.hpp>
#include <srs_app_utility.hpp>
#include <srs_kernel_kbps.hpp>
#include <srs_kernel_utility.hpp>

File diff suppressed because it is too large Load Diff

View File

@ -1,609 +0,0 @@
//
// Copyright (c) 2013-2025 The SRS Authors
//
// SPDX-License-Identifier: MIT
//
#ifndef SRS_APP_TENCENTCLOUD_HPP
#define SRS_APP_TENCENTCLOUD_HPP
#include <srs_core.hpp>
#ifdef SRS_APM
#include <srs_kernel_buffer.hpp>
#include <string>
#include <vector>
class SrsBuffer;
class SrsClsLogGroupList;
class SrsClsLogGroup;
class SrsClsLog;
class SrsOtelSpan;
class SrsApmContext;
class SrsAmf0Object;
class SrsApmSpan;
class SrsOtelResourceSpans;
class SrsOtelResource;
class SrsOtelScopeSpans;
class SrsOtelAttribute;
class SrsOtelAnyValue;
class SrsOtelScope;
class SrsOtelStatus;
class SrsOtelEvent;
class SrsOtelLink;
class SrsClsSugar : public ISrsEncoder
{
private:
SrsClsLog *log_;
SrsClsLogGroup *log_group_;
SrsClsLogGroupList *log_groups_;
public:
SrsClsSugar();
virtual ~SrsClsSugar();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
public:
bool empty();
SrsClsSugar *kv(std::string k, std::string v);
};
class SrsClsSugars : public ISrsEncoder
{
private:
std::vector<SrsClsSugar *> sugars;
public:
SrsClsSugars();
virtual ~SrsClsSugars();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
public:
SrsClsSugar *create();
SrsClsSugars *slice(int max_size);
bool empty();
int size();
};
class SrsClsClient
{
private:
bool enabled_;
bool stat_heartbeat_;
bool stat_streams_;
bool debug_logging_;
int heartbeat_ratio_;
int streams_ratio_;
std::string label_;
std::string tag_;
private:
std::string secret_id_;
std::string endpoint_;
std::string topic_;
private:
SrsClsSugars *sugars_;
uint64_t nn_logs_;
public:
SrsClsClient();
virtual ~SrsClsClient();
public:
bool enabled();
std::string label();
std::string tag();
uint64_t nn_logs();
public:
srs_error_t initialize();
srs_error_t report();
private:
srs_error_t do_send_logs(ISrsEncoder *sugar, int count, int total);
srs_error_t send_logs(SrsClsSugars *sugars);
srs_error_t dump_summaries(SrsClsSugars *sugars);
srs_error_t dump_streams(SrsClsSugars *sugars);
};
extern SrsClsClient *_srs_cls;
enum SrsApmKind {
SrsApmKindUnspecified = 0,
SrsApmKindInternal = 1,
SrsApmKindServer = 2,
SrsApmKindClient = 3,
SrsApmKindProducer = 4,
SrsApmKindConsumer = 5,
};
enum SrsApmStatus {
SrsApmStatusUnset = 0,
SrsApmStatusOk = 1,
SrsApmStatusError = 2,
};
class SrsOtelExportTraceServiceRequest : public ISrsEncoder
{
private:
// repeated opentelemetry.proto.trace.v1.ResourceSpans resource_spans = 1;
std::vector<SrsOtelResourceSpans *> spans_;
public:
SrsOtelExportTraceServiceRequest();
virtual ~SrsOtelExportTraceServiceRequest();
public:
SrsOtelResourceSpans *append();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelResourceSpans : public ISrsEncoder
{
private:
// opentelemetry.proto.resource.v1.Resource resource = 1;
SrsOtelResource *resource_;
// repeated ScopeSpans scope_spans = 2;
std::vector<SrsOtelScopeSpans *> spans_;
public:
SrsOtelResourceSpans();
virtual ~SrsOtelResourceSpans();
public:
SrsOtelResource *resource();
SrsOtelScopeSpans *append();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelResource : public ISrsEncoder
{
private:
// repeated opentelemetry.proto.common.v1.KeyValue attributes = 1;
std::vector<SrsOtelAttribute *> attributes_;
public:
SrsOtelResource();
virtual ~SrsOtelResource();
public:
SrsOtelResource *add_addr(SrsOtelAttribute *v);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelAttribute : public ISrsEncoder
{
private:
// string key = 1;
std::string key_;
// AnyValue value = 2;
SrsOtelAnyValue *value_;
private:
SrsOtelAttribute();
public:
virtual ~SrsOtelAttribute();
public:
const std::string &key();
public:
static SrsOtelAttribute *kv(std::string k, std::string v);
static SrsOtelAttribute *kvi(std::string k, int64_t v);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelAnyValue : public ISrsEncoder
{
private:
// Default to string(1). Please change it if use other value, such as int(3).
uint8_t used_field_id_;
private:
// string string_value = 1;
std::string string_value_;
// bool bool_value = 2;
// int64 int_value = 3;
int64_t int_value_;
// double double_value = 4;
// ArrayValue array_value = 5;
// KeyValueList kvlist_value = 6;
// bytes bytes_value = 7;
public:
SrsOtelAnyValue();
virtual ~SrsOtelAnyValue();
public:
SrsOtelAnyValue *set_string(const std::string &v);
SrsOtelAnyValue *set_int(int64_t v);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelScopeSpans : public ISrsEncoder
{
private:
// opentelemetry.proto.common.v1.InstrumentationScope scope = 1;
SrsOtelScope *scope_;
// repeated Span spans = 2;
std::vector<SrsOtelSpan *> spans_;
public:
SrsOtelScopeSpans();
virtual ~SrsOtelScopeSpans();
public:
SrsOtelScope *scope();
SrsOtelScopeSpans *swap(std::vector<SrsOtelSpan *> &spans);
int size();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelScope : public ISrsEncoder
{
public:
// string name = 1;
std::string name_;
// string version = 2;
// repeated KeyValue attributes = 3;
// uint32 dropped_attributes_count = 4;
public:
SrsOtelScope();
virtual ~SrsOtelScope();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelSpan : public ISrsEncoder
{
public:
// bytes trace_id = 1; // This field is required.
std::string trace_id_;
// bytes span_id = 2; // This field is required.
std::string span_id_;
// string trace_state = 3;
// bytes parent_span_id = 4;
std::string parent_span_id_;
// string name = 5; // This field is required.
std::string name_;
// SpanKind kind = 6;
SrsApmKind kind_;
// fixed64 start_time_unix_nano = 7;
int64_t start_time_unix_nano_;
// fixed64 end_time_unix_nano = 8;
int64_t end_time_unix_nano_;
// repeated opentelemetry.proto.common.v1.KeyValue attributes = 9;
std::vector<SrsOtelAttribute *> attributes_;
// uint32 dropped_attributes_count = 10;
// repeated Event events = 11;
std::vector<SrsOtelEvent *> events_;
// uint32 dropped_events_count = 12;
// repeated Link links = 13;
std::vector<SrsOtelLink *> links_;
// uint32 dropped_links_count = 14;
// Status status = 15;
SrsOtelStatus *status_;
public:
SrsOtelSpan();
virtual ~SrsOtelSpan();
public:
SrsOtelAttribute *attr(const std::string k);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelEvent : public ISrsEncoder
{
public:
// fixed64 time_unix_nano = 1;
int64_t time_;
// string name = 2;
std::string name_;
// repeated opentelemetry.proto.common.v1.KeyValue attributes = 3;
std::vector<SrsOtelAttribute *> attributes_;
// uint32 dropped_attributes_count = 4;
public:
SrsOtelEvent();
virtual ~SrsOtelEvent();
public:
static SrsOtelEvent *create(std::string v);
SrsOtelEvent *add_attr(SrsOtelAttribute *v);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelLink : public ISrsEncoder
{
private:
// bytes trace_id = 1;
std::string trace_id_;
// bytes span_id = 2;
std::string span_id_;
// string trace_state = 3;
// repeated opentelemetry.proto.common.v1.KeyValue attributes = 4;
// uint32 dropped_attributes_count = 5;
private:
SrsOtelLink();
public:
virtual ~SrsOtelLink();
public:
static SrsOtelLink *create();
SrsOtelLink *set_id(const std::string &trace_id, const std::string &span_id);
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsOtelStatus : public ISrsEncoder
{
public:
// string message = 2;
std::string message_;
// StatusCode code = 3;
SrsApmStatus code_;
public:
SrsOtelStatus();
virtual ~SrsOtelStatus();
public:
virtual uint64_t nb_bytes();
srs_error_t encode(SrsBuffer *b);
};
class SrsApmContext
{
private:
friend class SrsApmSpan;
private:
SrsApmSpan *span_;
SrsApmContext *parent_;
std::vector<SrsApmContext *> childs_;
// Encode the id in hex string.
std::string str_trace_id_;
std::string str_span_id_;
private:
std::string name_;
SrsApmKind kind_;
std::string trace_id_;
std::string span_id_;
// Note that parent span id might not be empty, while parent might be NULL, when extract span from propagator.
std::string parent_span_id_;
srs_utime_t start_time_;
SrsApmStatus status_;
std::string description_;
srs_error_t err_;
std::vector<SrsOtelAttribute *> attributes_;
std::vector<SrsOtelLink *> links_;
private:
bool ended_;
private:
SrsApmContext(const std::string &name);
public:
virtual ~SrsApmContext();
private:
// Update the trace id and format it as hex string id.
void set_trace_id(std::string v);
// Update the span id and format it as hex string id.
void set_span_id(std::string v);
public:
const char *format_trace_id();
const char *format_span_id();
SrsApmContext *root();
void set_parent(SrsApmContext *parent);
void set_status(SrsApmStatus status, const std::string &description);
bool all_ended();
int count_spans();
void update_trace_id(std::string v);
void link(SrsApmContext *to);
void end();
};
class ISrsApmSpan
{
private:
friend class SrsApmClient;
public:
ISrsApmSpan()
{
}
virtual ~ISrsApmSpan()
{
}
public:
// Get the formatted trace ID in hex string.
virtual const char *format_trace_id()
{
return "";
}
// Get the formatted span ID in hex string.
virtual const char *format_span_id()
{
return "";
}
public:
// Set the name of span.
virtual ISrsApmSpan *set_name(const std::string &name)
{
return this;
}
// Set the kind of span.
virtual ISrsApmSpan *set_kind(SrsApmKind kind)
{
return this;
}
// Set span as child span of parent span.
virtual ISrsApmSpan *as_child(ISrsApmSpan *parent)
{
return this;
}
// Set the status of span, and error description by fmt.
// Note that ignore description except for error status.
virtual ISrsApmSpan *set_status(SrsApmStatus status, const std::string &description)
{
return this;
}
// RecordError will record err as an exception span event for this span. An
// additional call to SetStatus is required if the Status of the Span should
// be set to Error, as this method does not change the Span status. If this
// span is not being recorded or err is nil then this method does nothing.
virtual ISrsApmSpan *record_error(srs_error_t err)
{
return this;
}
// Add an attribute with all string kv to span.
virtual ISrsApmSpan *attr(const std::string &k, const std::string &v)
{
return this;
}
// Link with another span.
virtual ISrsApmSpan *link(ISrsApmSpan *span)
{
return this;
}
// End the span, snapshot and upload(in a while) a otel span to APM server.
virtual ISrsApmSpan *end()
{
return this;
}
};
class SrsApmSpan : public ISrsApmSpan
{
private:
friend class SrsApmContext;
friend class SrsApmClient;
private:
bool child_;
SrsApmContext *ctx_;
private:
SrsApmSpan(const std::string &name);
public:
virtual ~SrsApmSpan();
// Span operations.
public:
const char *format_trace_id();
const char *format_span_id();
ISrsApmSpan *set_name(const std::string &name);
ISrsApmSpan *set_kind(SrsApmKind kind);
ISrsApmSpan *as_child(ISrsApmSpan *parent);
ISrsApmSpan *set_status(SrsApmStatus status, const std::string &description);
ISrsApmSpan *record_error(srs_error_t err);
ISrsApmSpan *attr(const std::string &k, const std::string &v);
ISrsApmSpan *link(ISrsApmSpan *span);
ISrsApmSpan *end();
// Inject or extract for propagator.
private:
ISrsApmSpan *extract(SrsAmf0Object *h);
ISrsApmSpan *inject(SrsAmf0Object *h);
std::string text_propagator();
// Store or load with coroutine context.
private:
ISrsApmSpan *store();
static ISrsApmSpan *load();
};
class SrsApmClient
{
private:
bool enabled_;
uint64_t nn_spans_;
std::string team_;
std::string token_;
std::string endpoint_;
std::string service_name_;
bool debug_logging_;
std::vector<SrsOtelSpan *> spans_;
public:
SrsApmClient();
virtual ~SrsApmClient();
public:
srs_error_t initialize();
srs_error_t report();
private:
srs_error_t do_report();
public:
bool enabled();
uint64_t nn_spans();
public:
// Create a span with specified name.
ISrsApmSpan *span(const std::string &name);
// Create dummy span for default.
ISrsApmSpan *dummy();
public:
// Extract and inject for propagator.
ISrsApmSpan *extract(ISrsApmSpan *v, SrsAmf0Object *h);
ISrsApmSpan *inject(ISrsApmSpan *v, SrsAmf0Object *h);
// Store the span to coroutine context.
void store(ISrsApmSpan *span);
// Get or load span from coroutine context.
// Note that a dummy span will be returned if no span in coroutine context.
// Note that user should never free the returned span.
ISrsApmSpan *load();
// Internal APIs.
public:
void snapshot(SrsOtelSpan *span);
};
extern SrsApmClient *_srs_apm;
#endif
#endif

View File

@ -9,6 +9,6 @@
#define VERSION_MAJOR 7
#define VERSION_MINOR 0
#define VERSION_REVISION 65
#define VERSION_REVISION 66
#endif

View File

@ -453,7 +453,6 @@ srs_error_t run_directly_or_daemon()
return err;
}
#include <srs_app_tencentcloud.hpp>
srs_error_t run_hybrid_server()
{
srs_error_t err = srs_success;
@ -477,12 +476,6 @@ srs_error_t run_hybrid_server()
return srs_error_wrap(err, "init circuit breaker");
}
#ifdef SRS_APM
// When startup, create a span for server information.
ISrsApmSpan *span = _srs_apm->span("main")->set_kind(SrsApmKindServer);
srs_freep(span);
#endif
// Should run util hybrid servers all done.
if ((err = _srs_hybrid->run()) != srs_success) {
return srs_error_wrap(err, "hybrid run");

View File

@ -4792,78 +4792,6 @@ VOID TEST(ConfigEnvTest, CheckEnvValuesCircuitBreaker)
}
}
VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudCls)
{
if (true) {
MockSrsConfig conf;
SrsSetEnvConfig(conf, tencentcloud_cls_enabled, "SRS_TENCENTCLOUD_CLS_ENABLED", "on");
EXPECT_TRUE(conf.get_tencentcloud_cls_enabled());
SrsSetEnvConfig(conf, tencentcloud_cls_label, "SRS_TENCENTCLOUD_CLS_LABEL", "xxx");
EXPECT_STREQ("xxx", conf.get_tencentcloud_cls_label().c_str());
SrsSetEnvConfig(conf, tencentcloud_cls_tag, "SRS_TENCENTCLOUD_CLS_TAG", "xxx2");
EXPECT_STREQ("xxx2", conf.get_tencentcloud_cls_tag().c_str());
SrsSetEnvConfig(conf, tencentcloud_cls_secret_id, "SRS_TENCENTCLOUD_CLS_SECRET_ID", "xxx3");
EXPECT_STREQ("xxx3", conf.get_tencentcloud_cls_secret_id().c_str());
SrsSetEnvConfig(conf, tencentcloud_cls_secret_key, "SRS_TENCENTCLOUD_CLS_SECRET_KEY", "xxx4");
EXPECT_STREQ("xxx4", conf.get_tencentcloud_cls_secret_key().c_str());
SrsSetEnvConfig(conf, tencentcloud_cls_endpoint, "SRS_TENCENTCLOUD_CLS_ENDPOINT", "yyy");
EXPECT_STREQ("yyy", conf.get_tencentcloud_cls_endpoint().c_str());
SrsSetEnvConfig(conf, tencentcloud_cls_topic_id, "SRS_TENCENTCLOUD_CLS_TOPIC_ID", "yyy2");
EXPECT_STREQ("yyy2", conf.get_tencentcloud_cls_topic_id().c_str());
}
if (true) {
MockSrsConfig conf;
SrsSetEnvConfig(conf, tencentcloud_cls_debug_logging, "SRS_TENCENTCLOUD_CLS_DEBUG_LOGGING", "on");
EXPECT_TRUE(conf.get_tencentcloud_cls_debug_logging());
SrsSetEnvConfig(conf, tencentcloud_cls_stat_heartbeat, "SRS_TENCENTCLOUD_CLS_STAT_HEARTBEAT", "off");
EXPECT_FALSE(conf.get_tencentcloud_cls_stat_heartbeat());
SrsSetEnvConfig(conf, tencentcloud_cls_heartbeat_ratio, "SRS_TENCENTCLOUD_CLS_HEARTBEAT_RATIO", "2");
EXPECT_EQ(2, conf.get_tencentcloud_cls_heartbeat_ratio());
SrsSetEnvConfig(conf, tencentcloud_cls_stat_streams, "SRS_TENCENTCLOUD_CLS_STAT_STREAMS", "off");
EXPECT_FALSE(conf.get_tencentcloud_cls_stat_streams());
SrsSetEnvConfig(conf, tencentcloud_cls_streams_ratio, "SRS_TENCENTCLOUD_CLS_STREAMS_RATIO", "2");
EXPECT_EQ(2, conf.get_tencentcloud_cls_streams_ratio());
}
}
VOID TEST(ConfigEnvTest, CheckEnvValuesTencentcloudApm)
{
if (true) {
MockSrsConfig conf;
SrsSetEnvConfig(conf, tencentcloud_apm_enabled, "SRS_TENCENTCLOUD_APM_ENABLED", "on");
EXPECT_TRUE(conf.get_tencentcloud_apm_enabled());
SrsSetEnvConfig(conf, tencentcloud_apm_team, "SRS_TENCENTCLOUD_APM_TEAM", "xxx");
EXPECT_STREQ("xxx", conf.get_tencentcloud_apm_team().c_str());
SrsSetEnvConfig(conf, tencentcloud_apm_token, "SRS_TENCENTCLOUD_APM_TOKEN", "xxx2");
EXPECT_STREQ("xxx2", conf.get_tencentcloud_apm_token().c_str());
SrsSetEnvConfig(conf, tencentcloud_apm_endpoint, "SRS_TENCENTCLOUD_APM_ENDPOINT", "xxx3");
EXPECT_STREQ("xxx3", conf.get_tencentcloud_apm_endpoint().c_str());
SrsSetEnvConfig(conf, tencentcloud_apm_service_name, "SRS_TENCENTCLOUD_APM_SERVICE_NAME", "srs");
EXPECT_STREQ("srs", conf.get_tencentcloud_apm_service_name().c_str());
SrsSetEnvConfig(conf, tencentcloud_apm_debug_logging, "SRS_TENCENTCLOUD_APM_DEBUG_LOGGING", "on");
EXPECT_TRUE(conf.get_tencentcloud_apm_debug_logging());
}
}
VOID TEST(ConfigEnvTest, CheckEnvValuesExporter)
{
if (true) {