Skip to content

Add external tag to opentrace events#2451

Merged
iilyak merged 1 commit intoapache:prototype/fdb-layerfrom
cloudant:tracing-external
Jan 21, 2020
Merged

Add external tag to opentrace events#2451
iilyak merged 1 commit intoapache:prototype/fdb-layerfrom
cloudant:tracing-external

Conversation

@iilyak
Copy link
Contributor

@iilyak iilyak commented Jan 14, 2020

Overview

This PR adds an ability to selectively enable opentracing for HTTP requests
with X-B3-... headers. This is helpful in following cases:

  • tracing all requests with X-B3-... headers
    all = (#{external := E}) when E == true -> true
  • tracing all requests to specific database with X-B3-... headers
    all = (#{external := E, 'db.name' := Db})
      when E == true andalso Db == <<"foo">> -> true
    
  • tracing requests to specific endpoint with X-B3-... headers
    db.design.view.read = (#{external := E, 'design.id' := Name})
      when E == true andalso Name == <<"bar">> -> true
    

I want to remind that we support following X-B3-... headers:

  • X-B3-TraceId
  • X-B3-SpanId
  • X-B3-ParentSpanId
  • B3 which is in the following format
    <TraceId>-<SpanId>-<1 | 0>-<ParentSpanId>

Testing recommendations

  1. Run test suite
$ make eunit apps=ctrace
  1. Write connection string into fdb.cluster file
  2. Start FDB server
  3. Update rel/overlay/etc/default.ini similar to this:
[tracing]
enabled = true
thrift_format = compact ; compact | binary
agent_host = 127.0.0.1
agent_port = 6831
app_name = couchdb

[tracing.filters]
; Log all traces
all = (#{external := External}) when External == true -> true
  1. Start jaeger docker run -d -p 6831:6831/udp -p 16686:16686 jaegertracing/all-in-one:1.14
  2. Start couchdb dev/run --admin=adm:pass
  3. Create database curl -X PUT -u adm:pass http://127.0.0.1:15984/test
  4. Query database curl -X GET -u adm:pass http://127.0.0.1:15984/test -H 'X-B3-TraceId: 12345678901234567890123453782027'
  5. Open http://localhost:16686/ in the browser and search for spans
  6. Query database curl -X GET -u adm:pass http://127.0.0.1:15984/test
  7. Make sure there are no traces for the call from step #9

As an alternative to Step 4, you can run the jaeger-all-in-one binary without arguments in a separate shell. The Jaeger project provides prebuilt binaries for download.

Related Issues or Pull Requests

Checklist

  • Code is written and works correctly
  • Changes are covered by tests
  • Any new configurable parameters are documented in rel/overlay/etc/default.ini
  • A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation

This PR adds an ability to selectively enable opentracing for HTTP requests
with X-B3-... headers. This is helpful in following cases:
- tracing all requests with X-B3-... headers
  `all = (#{external := E}) when E == true -> true`
- tracing all requests to specific database with X-B3-... headers
  ```
  all = (#{external := E, 'db.name' := Db})
    when E == true andalso Db == <<"foo">> -> true
  ```
- tracing requests to specific endpoint with X-B3-... headers
  ```
  db.design.view.read = (#{external := E, 'design.id' := Name})
    when E == true andalso Name == <<"bar">> -> true
  ```

I want to remind that we support following X-B3-... headers:

- X-B3-TraceId
- X-B3-SpanId
- X-B3-ParentSpanId
- B3 which is in the following format
  <TraceId>-<SpanId>-<1 | 0>-<ParentSpanId>
Copy link
Contributor

@nickva nickva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Nicely done

I had a question about a warning in when examining the spans but I think that's because it's an external span?

Screen Shot 2020-01-21 at 11 24 51 AM

@iilyak iilyak merged commit 6b1da76 into apache:prototype/fdb-layer Jan 21, 2020
@iilyak iilyak deleted the tracing-external branch January 21, 2020 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants