Example #1
0
static void
stats_format_csv(StatsCluster *sc, gint type, StatsCounterItem *counter, gpointer user_data)
{
  GString *csv = (GString *) user_data;
  gchar *s_id, *s_instance, *tag_name;
  gchar buf[32];
  gchar state;

  s_id = stats_format_csv_escapevar(sc->key.id);
  s_instance = stats_format_csv_escapevar(sc->key.instance);

  if (sc->dynamic)
    state = 'd';
  else if (sc->use_count == 0)
    state = 'o';
  else
    state = 'a';

  tag_name = stats_format_csv_escapevar(stats_cluster_get_type_name(sc, type));
  g_string_append_printf(csv, "%s;%s;%s;%c;%s;%"G_GSIZE_FORMAT"\n",
                         stats_cluster_get_component_name(sc, buf, sizeof(buf)),
                         s_id, s_instance, state, tag_name, stats_counter_get(&sc->counter_group.counters[type]));
  g_free(tag_name);
  g_free(s_id);
  g_free(s_instance);
}
Example #2
0
static void
assert_stats_component_name(gint component, const gchar *expected)
{
  gchar buf[32];
  const gchar *name;
  StatsCluster *sc = stats_cluster_new(component, NULL, NULL);
  
  name = stats_cluster_get_component_name(sc, buf, sizeof(buf));
  assert_string(name, expected, "component name mismatch");
  stats_cluster_free(sc);
}
Example #3
0
static void
stats_log_format_counter(StatsCluster *sc, gint type, StatsCounterItem *item, gpointer user_data)
{
  EVTREC *e = (EVTREC *) user_data;
  EVTTAG *tag;
  gchar buf[32];

  tag = evt_tag_printf(stats_cluster_get_type_name(type), "%s(%s%s%s)=%u", 
                       stats_cluster_get_component_name(sc, buf, sizeof(buf)),
                       sc->id,
                       (sc->id[0] && sc->instance[0]) ? "," : "",
                       sc->instance,
                       stats_counter_get(&sc->counters[type]));
  evt_rec_add_tag(e, tag);
}