Browse Source

TT#156052 use `destroyed` timestamp for call duration stats

Change-Id: I464269ffc85c7552e38abdbe326c8675b3175f19
pull/1421/head
Richard Fuchs 4 years ago
parent
commit
49b79e8b2f
2 changed files with 9 additions and 7 deletions
  1. +7
    -5
      daemon/statistics.c
  2. +2
    -2
      t/test-stats.c

+ 7
- 5
daemon/statistics.c View File

@ -111,7 +111,6 @@ void statistics_update_oneway(struct call* c) {
GList *k, *o; GList *k, *o;
int found = 0; int found = 0;
GList *l; GList *l;
struct timeval tim_result_duration;
// --- for statistics getting one way stream or no relay at all // --- for statistics getting one way stream or no relay at all
int total_nopacket_relayed_sess = 0; int total_nopacket_relayed_sess = 0;
@ -159,8 +158,6 @@ void statistics_update_oneway(struct call* c) {
if (c->monologues.head) { if (c->monologues.head) {
ml = c->monologues.head->data; ml = c->monologues.head->data;
timeval_subtract(&tim_result_duration, &rtpe_now, &ml->started);
if (IS_OWN_CALL(c)) { if (IS_OWN_CALL(c)) {
if (ml->term_reason==TIMEOUT) if (ml->term_reason==TIMEOUT)
RTPE_STATS_INC(timeout_sess); RTPE_STATS_INC(timeout_sess);
@ -173,8 +170,12 @@ void statistics_update_oneway(struct call* c) {
else if (ml->term_reason==FORCED) else if (ml->term_reason==FORCED)
RTPE_STATS_INC(forced_term_sess); RTPE_STATS_INC(forced_term_sess);
RTPE_STATS_ADD(call_duration, timeval_us(&tim_result_duration));
RTPE_STATS_INC(managed_sess); RTPE_STATS_INC(managed_sess);
if (!c->destroyed.tv_sec)
c->destroyed = rtpe_now;
long long duration = timeval_diff(&c->destroyed, &c->created);
RTPE_STATS_ADD(call_duration, duration);
} }
if (ml->term_reason==FINAL_TIMEOUT) if (ml->term_reason==FINAL_TIMEOUT)
@ -387,7 +388,8 @@ GQueue *statistics_gather_metrics(void) {
PROMLAB("type=\"mixed\""); PROMLAB("type=\"mixed\"");
num_sessions = atomic64_get(&rtpe_stats_cumulative.managed_sess); num_sessions = atomic64_get(&rtpe_stats_cumulative.managed_sess);
long long avg_us = num_sessions ? atomic64_get(&rtpe_stats_cumulative.call_duration) / num_sessions : 0;
uint64_t total_duration = atomic64_get(&rtpe_stats_cumulative.call_duration);
long long avg_us = num_sessions ? total_duration / num_sessions : 0;
timeval_from_us(&avg, avg_us); timeval_from_us(&avg, avg_us);
HEADER("}", ""); HEADER("}", "");


+ 2
- 2
t/test-stats.c View File

@ -3434,8 +3434,8 @@ int main(void) {
struct call_monologue *ml1 = call_get_or_create_monologue(call1, &callid1); struct call_monologue *ml1 = call_get_or_create_monologue(call1, &callid1);
struct call *call2 = call_get_or_create(&callid2, false, true); struct call *call2 = call_get_or_create(&callid2, false, true);
struct call_monologue *ml2 = call_get_or_create_monologue(call2, &callid2); struct call_monologue *ml2 = call_get_or_create_monologue(call2, &callid2);
ml1->started = (struct timeval) {157,0};
ml2->started = (struct timeval) {57,0};
call1->created = ml1->started = (struct timeval) {157,0};
call2->created = ml2->started = (struct timeval) {57,0};
graph_str = print_graphite_data(); graph_str = print_graphite_data();
assert_g_string_eq(graph_str, assert_g_string_eq(graph_str,


Loading…
Cancel
Save