1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

APM: Update statistic for APM.

This commit is contained in:
winlin 2022-09-16 21:04:43 +08:00
parent 3e2f8622f8
commit e63c02e928
3 changed files with 20 additions and 0 deletions

View file

@ -159,6 +159,9 @@ void srs_build_features(stringstream& ss)
SRS_CHECK_FEATURE2(_srs_cls->enabled(), "cls", ss); SRS_CHECK_FEATURE2(_srs_cls->enabled(), "cls", ss);
SRS_CHECK_FEATURE3(_srs_cls->nn_logs(), "logs", _srs_cls->nn_logs(), 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);
} }
SrsLatestVersion::SrsLatestVersion() SrsLatestVersion::SrsLatestVersion()

View file

@ -2086,6 +2086,7 @@ ISrsApmSpan* SrsApmSpan::load()
SrsApmClient::SrsApmClient() SrsApmClient::SrsApmClient()
{ {
enabled_ = false; enabled_ = false;
nn_spans_ = 0;
} }
SrsApmClient::~SrsApmClient() SrsApmClient::~SrsApmClient()
@ -2121,6 +2122,9 @@ srs_error_t SrsApmClient::report()
if (spans_.empty()) return err; if (spans_.empty()) return err;
// Update statistaic for APM.
nn_spans_ += spans_.size();
SrsOtelExportTraceServiceRequest* sugar = new SrsOtelExportTraceServiceRequest(); SrsOtelExportTraceServiceRequest* sugar = new SrsOtelExportTraceServiceRequest();
SrsAutoFree(SrsOtelExportTraceServiceRequest, sugar); SrsAutoFree(SrsOtelExportTraceServiceRequest, sugar);
@ -2200,6 +2204,16 @@ srs_error_t SrsApmClient::report()
return err; return err;
} }
bool SrsApmClient::enabled()
{
return enabled_;
}
uint64_t SrsApmClient::nn_spans()
{
return nn_spans_;
}
ISrsApmSpan* SrsApmClient::span(const std::string& name) ISrsApmSpan* SrsApmClient::span(const std::string& name)
{ {
if (!enabled_) return new ISrsApmSpan(); if (!enabled_) return new ISrsApmSpan();

View file

@ -492,6 +492,7 @@ class SrsApmClient
{ {
private: private:
bool enabled_; bool enabled_;
uint64_t nn_spans_;
std::string token_; std::string token_;
std::string endpoint_; std::string endpoint_;
std::string service_name_; std::string service_name_;
@ -503,6 +504,8 @@ public:
public: public:
srs_error_t initialize(); srs_error_t initialize();
srs_error_t report(); srs_error_t report();
bool enabled();
uint64_t nn_spans();
public: public:
// Create a span with specified name. // Create a span with specified name.
ISrsApmSpan* span(const std::string& name); ISrsApmSpan* span(const std::string& name);