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 2020/02/10 18:41:05 UTC

[couchdb] 07/16: Support jaeger http reporter

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

davisp pushed a commit to branch prototype/fdb-layer-get-dbs-info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 3565e524cb50c8596dc9739907e3a75dc3151d80
Author: ILYA Khlopotov <ii...@apache.org>
AuthorDate: Fri Jan 17 09:37:54 2020 -0800

    Support jaeger http reporter
---
 rebar.config.script              |  4 ++--
 rel/overlay/etc/default.ini      | 12 +++++++++---
 src/ctrace/README.md             | 18 ++++++++++++++++--
 src/ctrace/src/ctrace_config.erl | 38 +++++++++++++++++++++++++++++---------
 4 files changed, 56 insertions(+), 16 deletions(-)

diff --git a/rebar.config.script b/rebar.config.script
index 2fde9c5..f7ebcb5 100644
--- a/rebar.config.script
+++ b/rebar.config.script
@@ -121,13 +121,13 @@ DepDescs = [
 {folsom,           "folsom",           {tag, "CouchDB-0.8.3"}},
 {hyper,            "hyper",            {tag, "CouchDB-2.2.0-4"}},
 {ibrowse,          "ibrowse",          {tag, "CouchDB-4.0.1-1"}},
-{jaeger_passage,   "jaeger-passage",   {tag, "CouchDB-0.1.13-1"}},
+{jaeger_passage,   "jaeger-passage",   {tag, "CouchDB-0.1.14-1"}},
 {jiffy,            "jiffy",            {tag, "CouchDB-0.14.11-2"}},
 {local,            "local",            {tag, "0.2.1"}},
 {mochiweb,         "mochiweb",         {tag, "v2.19.0"}},
 {meck,             "meck",             {tag, "0.8.8"}},
 {passage,          "passage",          {tag, "0.2.6"}},
-{thrift_protocol,  "thrift-protocol",  {tag, "0.1.3"}},
+{thrift_protocol,  "thrift-protocol",  {tag, "0.1.5"}},
 
 %% TMP - Until this is moved to a proper Apache repo
 {erlfdb,           "erlfdb",           {branch, "master"}}
diff --git a/rel/overlay/etc/default.ini b/rel/overlay/etc/default.ini
index 63cb443..592445c 100644
--- a/rel/overlay/etc/default.ini
+++ b/rel/overlay/etc/default.ini
@@ -568,13 +568,19 @@ min_priority = 2.0
 [tracing]
 ;
 ; Configuration settings for the `ctrace` OpenTracing
-; API.
-;
+; API. There are two reporter which we support.
+;   - jaeger.thrift over udp
+;   - jaeger.thrift over http
+; ## Common settings
 ; enabled = false ; true | false
+; app_name = couchdb ; value to use for the `location.application` tag
+; protocol = udp ; udp | http - which reporter to use
+; ## jaeger.thrift over udp reporter
 ; thrift_format = compact ; compact | binary
 ; agent_host = 127.0.0.1
 ; agent_port = 6831
-; app_name = couchdb ; value to use for the `location.application` tag
+; ## jaeger.thrift over udp reporter
+; endpoint = http://127.0.0.1:14268
 
 [tracing.filters]
 ;
diff --git a/src/ctrace/README.md b/src/ctrace/README.md
index 3172f26..4b0238b 100644
--- a/src/ctrace/README.md
+++ b/src/ctrace/README.md
@@ -120,9 +120,23 @@ Configuration
 Traces are configured using standard CouchDB ini file based configuration.
 There is a global toggle `[tracing] enabled = true | false` that switches
 tracing on or off completely. The `[tracing]` section also includes
-configuration for where to send trace data.
+configuration for where to send trace data. There are two reporters which we
+support.
 
-An example `[tracing]` section
+The thrift over udp reporter (this is the default) has following configuration
+options:
+
+- protocol = udp
+- thrift_format = compact | binary
+- agent_host = 127.0.0.1
+- agent_port = 6831
+
+The thrift over http has following options
+
+- protocol = http
+- endpoint = http://127.0.0.1:14268
+
+An example of `[tracing]` section
 
 ```ini
 [tracing]
diff --git a/src/ctrace/src/ctrace_config.erl b/src/ctrace/src/ctrace_config.erl
index bc2a3df..c63c77f 100644
--- a/src/ctrace/src/ctrace_config.erl
+++ b/src/ctrace/src/ctrace_config.erl
@@ -98,17 +98,37 @@ maybe_start_main_tracer(TracerId) ->
 
 
 start_main_tracer(TracerId) ->
-    Sampler = passage_sampler_all:new(),
-    Options = [
-        {thrift_format,
-            list_to_atom(config:get("tracing", "thrift_format", "compact"))},
-        {agent_host, config:get("tracing", "agent_host", "127.0.0.1")},
-        {agent_port, config:get_integer("tracing", "agent_port", 6831)},
-        {default_service_name,
-            list_to_atom(config:get("tracing", "app_name", "couchdb"))}
-    ],
+    MaxQueueLen = config:get_integer("tracing", "max_queue_len", 1024),
+    Sampler = jaeger_passage_sampler_queue_limit:new(
+        passage_sampler_all:new(), TracerId, MaxQueueLen),
+    ServiceName = list_to_atom(config:get("tracing", "app_name", "couchdb")),
+
+    ProtocolOptions = case config:get("tracing", "protocol", "udp") of
+        "udp" ->
+            [
+                {thrift_format, list_to_atom(
+                    config:get("tracing", "thrift_format", "compact"))},
+                {agent_host,
+                    config:get("tracing", "agent_host", "127.0.0.1")},
+                {agent_port,
+                    config:get_integer("tracing", "agent_port", 6831)},
+                {protocol, udp},
+                {default_service_name, ServiceName}
+           ];
+        "http" ++ _ ->
+            [
+                {endpoint,
+                    config:get("tracing", "endpoint", "http://127.0.0.1:14268")},
+                {protocol, http},
+                {http_client, fun http_client/5},
+                {default_service_name, ServiceName}
+           ]
+    end,
+    Options = [{default_service_name, ServiceName}|ProtocolOptions],
     ok = jaeger_passage:start_tracer(TracerId, Sampler, Options).
 
+http_client(Endpoint, Method, Headers, Body, _ReporterOptions) ->
+    ibrowse:send_req(Endpoint, Headers, Method, Body, []).
 
 compile_filter(OperationId, FilterDef) ->
     try