mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Disable CLS and APM by default. v5.0.101
This commit is contained in:
parent
8adb1693cc
commit
e86e0c8999
20 changed files with 104 additions and 9 deletions
|
@ -110,9 +110,11 @@ srs_error_t SrsEdgeRtmpUpstream::connect(SrsRequest* 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.
|
||||
ISrsApmSpan* span_client = _srs_apm->inject(_srs_apm->span("edge-pull")->set_kind(SrsApmKindClient)->as_child(_srs_apm->load()), sdk->extra_args());
|
||||
SrsAutoFree(ISrsApmSpan, span_client);
|
||||
#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));
|
||||
|
@ -393,7 +395,9 @@ SrsEdgeIngester::SrsEdgeIngester()
|
|||
source = NULL;
|
||||
edge = NULL;
|
||||
req = NULL;
|
||||
#ifdef SRS_APM
|
||||
span_main_ = NULL;
|
||||
#endif
|
||||
|
||||
upstream = new SrsEdgeRtmpUpstream("");
|
||||
lb = new SrsLbRoundRobin();
|
||||
|
@ -404,7 +408,9 @@ SrsEdgeIngester::~SrsEdgeIngester()
|
|||
{
|
||||
stop();
|
||||
|
||||
#ifdef SRS_APM
|
||||
srs_freep(span_main_);
|
||||
#endif
|
||||
srs_freep(upstream);
|
||||
srs_freep(lb);
|
||||
srs_freep(trd);
|
||||
|
@ -416,10 +422,12 @@ srs_error_t SrsEdgeIngester::initialize(SrsLiveSource* s, SrsPlayEdge* e, SrsReq
|
|||
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;
|
||||
}
|
||||
|
@ -458,11 +466,13 @@ string SrsEdgeIngester::get_curr_origin()
|
|||
return lb->selected();
|
||||
}
|
||||
|
||||
#ifdef SRS_APM
|
||||
ISrsApmSpan* SrsEdgeIngester::span()
|
||||
{
|
||||
srs_assert(span_main_);
|
||||
return span_main_;
|
||||
}
|
||||
#endif
|
||||
|
||||
// when error, edge ingester sleep for a while and retry.
|
||||
#define SRS_EDGE_INGESTER_CIMS (3 * SRS_UTIME_SECONDS)
|
||||
|
@ -471,10 +481,12 @@ 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.
|
||||
|
@ -483,18 +495,22 @@ srs_error_t SrsEdgeIngester::cycle()
|
|||
return srs_error_wrap(err, "edge ingester");
|
||||
}
|
||||
|
||||
#ifdef SRS_APM
|
||||
srs_assert(span_main_);
|
||||
ISrsApmSpan* start = _srs_apm->span("edge-start")->set_kind(SrsApmKindConsumer)->as_child(span_main_)->end();
|
||||
srs_freep(start);
|
||||
#endif
|
||||
|
||||
if ((err = do_cycle()) != srs_success) {
|
||||
srs_warn("EdgeIngester: Ignore error, %s", srs_error_desc(err).c_str());
|
||||
srs_freep(err);
|
||||
}
|
||||
|
||||
#ifdef SRS_APM
|
||||
srs_assert(span_main_);
|
||||
ISrsApmSpan* stop = _srs_apm->span("edge-stop")->set_kind(SrsApmKindConsumer)->as_child(span_main_)->end();
|
||||
srs_freep(stop);
|
||||
#endif
|
||||
|
||||
// Check whether coroutine is stopped, see https://github.com/ossrs/srs/issues/2901
|
||||
if ((err = trd->pull()) != srs_success) {
|
||||
|
@ -771,10 +787,12 @@ 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.
|
||||
ISrsApmSpan* span_client = _srs_apm->inject(_srs_apm->span("edge-push")->set_kind(SrsApmKindClient)->as_child(_srs_apm->load()), sdk->extra_args());
|
||||
SrsAutoFree(ISrsApmSpan, span_client);
|
||||
#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));
|
||||
|
@ -962,6 +980,7 @@ 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()) {
|
||||
|
@ -969,6 +988,7 @@ srs_error_t SrsPlayEdge::on_client_play()
|
|||
ISrsApmSpan* to = _srs_apm->span("edge-link")->as_child(ingester->span())->link(from);
|
||||
srs_freep(from); srs_freep(to);
|
||||
}
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue