Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 9 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 30 additions and 18 deletions.
  1. +7 −7 rebar.config
  2. +16 −8 src/zeta.erl
  3. +7 −3 src/zeta_client.erl
View
14 rebar.config
@@ -1,6 +1,6 @@
%%-*- mode: erlang -*-
-{plugins, [rebar_covertool]}.
+%{plugins, [rebar_covertool]}.
{sub_dirs, ["rel"]}.
{erl_opts, [fail_on_warning, debug_info,
@@ -11,18 +11,18 @@
{cover_print_enable, true}.
{clean_files, ["*.eunit", "ebin/*.beam"]}.
-{covertool_eunit, ".eunit/eunit.coverage.xml"}.
-{covertool_prefix_len, 2}.
+%%{covertool_eunit, ".eunit/eunit.coverage.xml"}.
+%%{covertool_prefix_len, 2}.
{lib_dirs, [".."]}.
{deps_dir, ".."}.
{deps, [{lager, ".*",
{git, "git://github.com/basho/lager.git", "HEAD"}},
{erlando, ".*",
- {git, "git@github.com:reifyhealth/erlando.git", "HEAD"}},
+ {git, "git://github.com/reifyhealth/erlando.git", "HEAD"}},
{proper, ".*",
{git, "https://github.com/manopapad/proper.git", "HEAD"}},
{protobuffs, ".*",
- {git, "https://github.com/dizzyd/protobuffs.git", "HEAD"}},
- {covertool, ".*",
- {git, "https://github.com/idubrov/covertool.git", "HEAD"}}]}.
+ {git, "https://github.com/dizzyd/protobuffs.git", "HEAD"}}]}.
+%% {covertool, ".*",
+%% {git, "https://github.com/idubrov/covertool.git", "HEAD"}}]}.
View
24 src/zeta.erl
@@ -7,6 +7,7 @@
-export([ev/2, ev/3, ev/4, evh/2, evh/3, evh/4]).
-export([sv/2, sv/3, sv/4, svh/2, svh/3, svh/4]).
-export([cv/2, cv/3, cv/4, cvh/2, cvh/3, cvh/4]).
+-export([cv_batch/1, sv_batch/1]).
-export([all_client_configs/0, client_config/1]).
@@ -88,12 +89,16 @@ sv(Loc, Metric) -> sv(Loc, Metric, undefined).
sv(Loc, Metric, State) -> sv(Loc, Metric, State, []).
sv(Loc, Metric, State, Opts) ->
E = ev(Loc, Metric, State, Opts),
- M = #zeta_msg{zevents = [E]},
+ sv_batch([E]).
+
+sv_batch(Es) ->
+ M = #zeta_msg{zevents = Es},
Data = zeta_pb:encode(M),
Length = byte_size(Data),
- do([error_m ||
- Client <- zeta_corral:client(),
- gen_server:call(Client, {events, <<Length:32/integer-big, Data/binary>>})]).
+ do([error_m ||
+ Client <- zeta_corral:client(),
+ gen_server:call(
+ Client, {events, <<Length:32/integer-big, Data/binary>>})]).
svh(Service, Metric) -> svh(Service, Metric, undefined).
svh(Service, Metric, State) -> svh(Service, Metric, State, []).
@@ -103,17 +108,20 @@ cv(Loc, Metric) -> cv(Loc, Metric, undefined).
cv(Loc, Metric, State) -> cv(Loc, Metric, State, []).
cv(Loc, Metric, State, Opts) ->
E = ev(Loc, Metric, State, Opts),
- M = #zeta_msg{zevents = [E]},
+ cv_batch([E]).
+
+cv_batch(Es) ->
+ M = #zeta_msg{zevents = Es},
Data = zeta_pb:encode(M),
do([error_m ||
- Client <- zeta_corral:client(),
- gen_server:cast(Client, {events, Data})]).
+ Client <- zeta_corral:client(),
+ gen_server:cast(Client, {events, Data})]).
+
cvh(Service, Metric) -> cvh(Service, Metric, undefined).
cvh(Service, Metric, State) -> cvh(Service, Metric, State, []).
cvh(Service, Metric, State, Opts) -> cv({node(), Service}, Metric, State, Opts).
-
lookup(K, List) when is_atom(K) ->
case lists:keyfind(K, 1, List) of
{K, V} -> V;
View
10 src/zeta_client.erl
@@ -34,7 +34,7 @@ init([Host, Port]) ->
{ok, UDPSock} = gen_udp:open(0, [binary, {active,false}]),
%% Try to make a TCP connection
case gen_tcp:connect(Host, Port,
- [binary, {active, false}],
+ [binary, {active, false}, {nodelay, true}],
5000) of
{ok, TCPSock} ->
{ok, #st{udp = UDPSock, tcp = TCPSock, host = Host, port = Port}};
@@ -64,11 +64,15 @@ handle_call({events, Msg}, _From, St = #st{tcp = TCP}) ->
{#zeta_msg{error = Error}, _} ->
{error, {riemann, Error}};
{none, _} -> {error, noparse}
- end
+ end;
+ {error, _} = Error ->
+ error_logger:info_msg(
+ "ignoring zeta_client receive error: ~p~n", [Error]),
+ {stop, {shutdown, tcp_recv_error}, ok, St}
end;
{error, closed} ->
error_logger:info_msg("zeta_client disconnected"),
- {stop, {shutdown, connection_closed}, St}
+ {stop, {shutdown, connection_closed}, ok, St}
end;
handle_call(_Message, _From, State) -> {reply, ignored, State}.

No commit comments for this range

Something went wrong with that request. Please try again.