1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

API: support metrics for prometheus.(#2899) (#3189)

* API: support metrics for prometheus.

* Metrics: optimize metrics statistics info.

* Refine: remove redundant code.

* Refine: fix metrics srs_streams param.

* Metrics: add major param.

* Metrics: refine params and metric comments.

* For #2899: API: Support exporter for Prometheus. v5.0.67

Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
chundonglinlin 2022-09-27 15:39:26 +08:00 committed by GitHub
parent e31f3b0e64
commit 981cab40d3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 236 additions and 10 deletions

View file

@ -139,6 +139,11 @@ private:
std::map<std::string, SrsStatisticClient*> clients;
// The server total kbps.
SrsKbps* kbps;
private:
// The total of clients connections.
int64_t nb_clients_;
// The total of clients errors.
int64_t nb_errs_;
private:
SrsStatistic();
virtual ~SrsStatistic();
@ -177,7 +182,7 @@ public:
// @remark the on_disconnect always call, while the on_client is call when
// only got the request object, so the client specified by id maybe not
// exists in stat.
virtual void on_disconnect(std::string id);
virtual void on_disconnect(std::string id, srs_error_t err);
private:
// Cleanup the stream if stream is not active and for the last client.
void cleanup_stream(SrsStatisticStream* stream);
@ -210,6 +215,9 @@ public:
private:
virtual SrsStatisticVhost* create_vhost(SrsRequest* req);
virtual SrsStatisticStream* create_stream(SrsStatisticVhost* vhost, SrsRequest* req);
public:
// Dumps exporter metrics.
virtual srs_error_t dumps_metrics(int64_t& send_bytes, int64_t& recv_bytes, int64_t& nstreams, int64_t& nclients, int64_t& total_nclients, int64_t& nerrs);
};
// Generate a random string id, with constant prefix.