Exemple #1
0
struct brubeck_backend *
brubeck_carbon_new(struct brubeck_server *server, json_t *settings, int shard_n)
{
	struct brubeck_carbon *carbon = xcalloc(1, sizeof(struct brubeck_carbon));
	char *address;
	const char *global_prefix = carbon_global_prefix;
	const char *global_count_prefix = carbon_global_count_prefix;
	const char *prefix_counter = carbon_prefix_counter;
	const char *prefix_timer = carbon_prefix_timer;
	const char *prefix_gauge = carbon_prefix_gauge;
	int port, frequency, pickle, namespacing = 0;
	int legacy_namespace = 1;

	json_unpack_or_die(settings,
		"{s:s, s:i, s?:b, s:i, s?:b, s?:b, s?:s, s?:s, s?:s, s?:s, s?:s}",
		"address", &address,
		"port", &port,
		"pickle", &pickle,
		"frequency", &frequency,

		"namespacing", &namespacing,
		"legacy_namespace", &legacy_namespace,
		"global_prefix", &global_prefix,
		"global_count_prefix", &global_count_prefix,
		"prefix_counter", &prefix_counter,
		"prefix_timer", &prefix_timer,
		"prefix_gauge", &prefix_gauge);

	carbon->backend.type = BRUBECK_BACKEND_CARBON;
	carbon->backend.shard_n = shard_n;
	carbon->backend.connect = &carbon_connect;

	if (pickle) {
		carbon->backend.sample = &pickle1_each;
		carbon->backend.flush = &pickle1_flush;
		carbon->pickler.ptr = malloc(PICKLE_BUFFER_SIZE);
		pickle1_init(&carbon->pickler);
	} else {
		carbon->backend.sample = &plaintext_each;
		carbon->backend.flush = NULL;
	}

	carbon->backend.sample_freq = frequency;
	carbon->namespacing = namespacing;
	carbon->legacy_namespace = legacy_namespace;
	carbon->global_prefix = global_prefix;
	carbon->global_count_prefix = global_count_prefix;
	carbon->prefix_counter = prefix_counter;
	carbon->prefix_timer = prefix_timer;
	carbon->prefix_gauge = prefix_gauge;

	carbon->backend.server = server;
	carbon->out_sock = -1;
	url_to_inaddr2(&carbon->out_sockaddr, address, port);

	brubeck_backend_run_threaded((struct brubeck_backend *)carbon);
	log_splunk("backend=carbon event=started");

	return (struct brubeck_backend *)carbon;
}
Exemple #2
0
struct brubeck_backend *
brubeck_carbon_new(struct brubeck_server *server, json_t *settings, int shard_n)
{
	struct brubeck_carbon *carbon = xcalloc(1, sizeof(struct brubeck_carbon));
	char *address;
	int port, frequency, pickle = 0;

	json_unpack_or_die(settings,
		"{s:s, s:i, s?:b, s:i}",
		"address", &address,
		"port", &port,
		"pickle", &pickle,
		"frequency", &frequency);

	carbon->backend.type = BRUBECK_BACKEND_CARBON;
	carbon->backend.shard_n = shard_n;
	carbon->backend.connect = &carbon_connect;

	if (pickle) {
		carbon->backend.sample = &pickle1_each;
		carbon->backend.flush = &pickle1_flush;
		carbon->pickler.ptr = malloc(PICKLE_BUFFER_SIZE);
		pickle1_init(&carbon->pickler);
	} else {
		carbon->backend.sample = &plaintext_each;
		carbon->backend.flush = NULL;
	}

	carbon->backend.sample_freq = frequency;
	carbon->backend.server = server;
	carbon->out_sock = -1;
	url_to_inaddr2(&carbon->out_sockaddr, address, port);

	brubeck_backend_run_threaded((struct brubeck_backend *)carbon);
	log_splunk("backend=carbon event=started");

	return (struct brubeck_backend *)carbon;
}