Changeset 27a5e331e0c69b61663894284bea87f17f1ed062

Show
Ignore:
Timestamp:
05/22/12 19:36:13 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1337715373 -0400
git-parent:

[9c34eea8305e4339d255aaaef352640ccc879da8]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1337715373 -0400
Message:

knowing the last known value can also be useful

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules/statsd.c

    rc385b68 r27a5e33  
    152152 
    153153  /* Next the actual data */ 
    154   snprintf(buff, sizeof(buff), "%s`%s", key, 
    155            (type == 'c') ? "rate" : (type == 'g') ? "gauge" : "timing"); 
    156   m = noit_stats_get_metric(check, &ccl->current, buff); 
    157154  if(type == 'c') { 
    158155    double v = diff * (1.0 / sample) / (check->period / 1000.0); 
     156    snprintf(buff, sizeof(buff), "%s`rate", key); 
     157    m = noit_stats_get_metric(check, &ccl->current, buff); 
    159158    if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) { 
    160159      (*m->metric_value.n) += v; 
     
    164163      noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v); 
    165164  } 
    166   else if(type == 'g' || type == 'm') { 
    167     double v = diff; 
    168     if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) { 
    169       (*m->metric_value.n) = v; 
    170       check_stats_set_metric_hook_invoke(check, &ccl->current, m); 
    171     } 
    172     else 
    173       noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &v); 
    174   } 
     165 
     166  snprintf(buff, sizeof(buff), "%s`%s", key, 
     167           (type == 'c') ? "counter" : (type == 'g') ? "gauge" : "timing"); 
     168  m = noit_stats_get_metric(check, &ccl->current, buff); 
     169  if(m && m->metric_type == METRIC_DOUBLE && m->metric_value.n != NULL) { 
     170    (*m->metric_value.n) = diff; 
     171    check_stats_set_metric_hook_invoke(check, &ccl->current, m); 
     172  } 
     173  else 
     174    noit_stats_set_metric(check, &ccl->current, buff, METRIC_DOUBLE, &diff); 
    175175} 
    176176