You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2019/12/05 19:35:44 UTC

[couchdb] 11/11: Load commit errors into jaeger

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch opentracing-davisp
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 891b555974e34405c8505ccee7067111e954599b
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Fri Nov 8 11:12:07 2019 -0600

    Load commit errors into jaeger
---
 support/load-fdb-traces.escript | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/support/load-fdb-traces.escript b/support/load-fdb-traces.escript
index ab0def1..a81f5b6 100755
--- a/support/load-fdb-traces.escript
+++ b/support/load-fdb-traces.escript
@@ -8,6 +8,7 @@
 -define(ANCESTORS_KEY, passage_span_ancestors).
 -define(SPAN_TYPES, [
     <<"TransactionTrace_Commit">>,
+    <<"TransactionTrace_CommitError">>,
     <<"TransactionTrace_Get">>,
     <<"TransactionTrace_GetRange">>,
     <<"TransactionTrace_GetVersion">>
@@ -19,7 +20,8 @@
     {<<"ValueSizeBytes">>, 'value-size-bytes'},
     {<<"RangeSizeBytes">>, 'range-size-bytes'},
     {<<"NumMutations">>, 'num-mutations'},
-    {<<"CommitSizeBytes">>, 'commit-size-bytes'}
+    {<<"CommitSizeBytes">>, 'commit-size-bytes'},
+    {<<"ErrCode">>, 'error-code'}
 ]).
 
 
@@ -75,7 +77,10 @@ create_span(Type, Props) ->
 
 get_time(Props) ->
     {_, EndTimeBin} = lists:keyfind(<<"Time">>, 1, Props),
-    {_, LatencyBin} = lists:keyfind(<<"Latency">>, 1, Props),
+    LatencyBin = case lists:keyfind(<<"Latency">>, 1, Props) of
+        {_, LB} -> LB;
+        false -> <<"0.0">>
+    end,
     EndTimeFloat = binary_to_float(EndTimeBin),
     Latency = binary_to_float(LatencyBin),
     {float_to_time(EndTimeFloat - Latency), float_to_time(EndTimeFloat)}.
@@ -99,7 +104,15 @@ get_tags(Props) ->
     lists:foldl(fun({BinKey, AtomKey}, Tags) ->
         case lists:keyfind(BinKey, 1, Props) of
             {_, Value} ->
-                Tags#{AtomKey => Value};
+                Tags1 = Tags#{AtomKey => Value},
+                if BinKey /= <<"ErrCode">> -> Tags1; true ->
+                    IntCode = binary_to_integer(Value),
+                    Reason = erlfdb_nif:get_error(IntCode),
+                    Tags1#{
+                        error => true,
+                        reason => Reason
+                    }
+                end;
             false ->
                 Tags
         end