static void
json_out_stat(TSRecordType rec_type ATS_UNUSED, void *edata, int registered ATS_UNUSED,
              const char *name, TSRecordDataType data_type,
              TSRecordData *datum) {
  stats_state *my_state = edata;
  unsigned long long int value = 0;

  switch(data_type) {
  case TS_RECORDDATATYPE_COUNTER:
    value = datum->rec_counter ;
    APPEND_STAT_NUMERIC(name, "%llu", value); break;
  case TS_RECORDDATATYPE_INT:
    value = datum->rec_int;
    if ( value > 9223372036854775807) value = 0 ;
    APPEND_STAT_NUMERIC(name, "%llu", value); break;
  case TS_RECORDDATATYPE_FLOAT:
    APPEND_STAT_NUMERIC(name, "%f", datum->rec_float); break;
  case TS_RECORDDATATYPE_STRING:
    APPEND_STAT(name, "%s", datum->rec_string); break;
  default:
    TSDebug("istats", "unknown type for %s: %d", name, data_type);
    break;
  }
}
static void
json_out_stat(TSRecordType rec_type ATS_UNUSED, void *edata, int registered ATS_UNUSED, const char *name,
              TSRecordDataType data_type, TSRecordData *datum)
{
  stats_state *my_state = edata;

  switch (data_type) {
  case TS_RECORDDATATYPE_COUNTER:
    APPEND_STAT_NUMERIC(name, "%" PRIu64, wrap_unsigned_counter(datum->rec_counter));
    break;
  case TS_RECORDDATATYPE_INT:
    APPEND_STAT_NUMERIC(name, "%" PRIu64, wrap_unsigned_counter(datum->rec_int));
    break;
  case TS_RECORDDATATYPE_FLOAT:
    APPEND_STAT_NUMERIC(name, "%f", datum->rec_float);
    break;
  case TS_RECORDDATATYPE_STRING:
    APPEND_STAT(name, "%s", datum->rec_string);
    break;
  default:
    TSDebug(PLUGIN_NAME, "unknown type for %s: %d", name, data_type);
    break;
  }
}