diff options
author | iilyak <iilyak@users.noreply.github.com> | 2020-01-21 08:40:41 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-21 08:40:41 -0800 |
commit | 6b1da76bcded6de117bf814f2a984ffb29aed3c6 (patch) | |
tree | 7eb09f50046057f2c024819f3d3dc55b326811db | |
parent | ab4eafab0d555881f118b2ab19678872814b5059 (diff) | |
parent | 963f84bad08d0a0e5587ae2f1869c3563d4182d6 (diff) | |
download | couchdb-6b1da76bcded6de117bf814f2a984ffb29aed3c6.tar.gz |
Merge pull request #2451 from cloudant/tracing-external
Add `external` tag to opentrace events
-rw-r--r-- | src/chttpd/src/chttpd.erl | 12 | ||||
-rw-r--r-- | src/ctrace/README.md | 3 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/chttpd/src/chttpd.erl b/src/chttpd/src/chttpd.erl index c4bfa602f..d5e731423 100644 --- a/src/chttpd/src/chttpd.erl +++ b/src/chttpd/src/chttpd.erl @@ -1250,6 +1250,7 @@ start_span(Req) -> [] -> <<"">>; [_ | _] -> filename:join(PathParts) end, + {IsExternalSpan, RootOptions} = root_span_options(MochiReq), Tags = maps:merge(#{ peer => Peer, 'http.method' => Method, @@ -1257,21 +1258,22 @@ start_span(Req) -> 'http.url' => MochiReq:get(raw_path), path_parts => Path, 'span.kind' => <<"server">>, - component => <<"couchdb.chttpd">> + component => <<"couchdb.chttpd">>, + external => IsExternalSpan }, ExtraTags), ctrace:start_span(OperationName, [ {tags, Tags}, {time, Begin} - ] ++ maybe_root_span(MochiReq)). + ] ++ RootOptions). -maybe_root_span(MochiReq) -> +root_span_options(MochiReq) -> case get_trace_headers(MochiReq) of [undefined, _, _] -> - []; + {false, []}; [TraceId, SpanId, ParentSpanId] -> Span = ctrace:external_span(TraceId, SpanId, ParentSpanId), - [{root, Span}] + {true, [{root, Span}]} end. parse_trace_id(undefined) -> diff --git a/src/ctrace/README.md b/src/ctrace/README.md index 6e40b434c..3172f268b 100644 --- a/src/ctrace/README.md +++ b/src/ctrace/README.md @@ -146,7 +146,10 @@ and logged. ```ini [tracing.filters] +; trace all events ; all = (#{}) -> true +; trace all events with X-B3-... headers +; all = (#{external := External}) when External == true -> true ; database-info.read = (#{'http.method' := Method}) when Method == 'GET' -> true ; view.build = (#{'view.name' := Name}) when Name == "foo" -> 0.25 ``` |