Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adds Brave 4 ServerTracer integration #334

Merged
merged 1 commit into from
Jan 13, 2017
Merged

Conversation

codefromthecrypt
Copy link
Member

@codefromthecrypt codefromthecrypt commented Jan 13, 2017

An oversight in the initial Brave 4 TracerAdapter was how server spans
wire differently than local and client ones. Particularly, they carry
sampling status to prevent downstream trace commands from creating
children when unsampled.

fixes #332

Brave 3's ServerTracer works slightly differently than Brave 3's client
or local tracers. Internally, it uses a ServerSpan which keeps track
of the original sample status. To interop with ServerTracer, use the
following hooks:

Use TracerAdapter.getServerSpan to get one of..

  • a real span: when a sampled server request preceded this call
  • a noop span: when a server request preceded this call, but was not sampled
  • null: if no server request preceded this call
brave4Span = TracerAdapter.getServerSpan(brave4, brave3.serverSpanThreadBinder());
// Since the current server span might be empty, you must check null
if (brave4Span != null) {
  // use or finish the span
}

If you have a reference to a Brave 4 span, and know it represents a server
request, use TracerAdapter.setServerSpan to attach it to Brave 3's thread
binder.

TracerAdapter.setServerSpan(brave4Span.context(), brave3.serverSpanThreadBinder());
brave3.serverTracer().setServerSend(); // for example

An oversight in the initial Brave 4 TracerAdapter was how server spans
wire differently than local and client ones. Particularly, they carry
sampling status to prevent downstream trace commands to create children
when unsampled.

fixes #332

Brave 3's ServerTracer works slightly differently than Brave 3's client
or local tracers. Internally, it uses a `ServerSpan` which keeps track
of the original sample status. To interop with ServerTracer, use the
following hooks:

Use `TracerAdapter.getServerSpan` to get one of..
* a real span: when a sampled server request preceded this call
* a noop span: when a server request preceded this call, but was not sampled
* null: if no server request preceded this call

```java
brave4Span = TracerAdapter.getServerSpan(brave4, brave3.serverSpanThreadBinder());
// Since the current server span might be empty, you must check null
if (brave4Span != null) {
  // use or finish the span
}
```

If you have a reference to a Brave 4 span, and know it represents a server
request, use `TracerAdapter.setServerSpan` to attach it to Brave 3's thread
binder.
```java
TracerAdapter.setServerSpan(brave4Span.context(), brave3.serverSpanThreadBinder());
brave3.serverTracer().setServerSend(); // for example
```
@codefromthecrypt codefromthecrypt merged commit 98f7876 into master Jan 13, 2017
@codefromthecrypt codefromthecrypt deleted the server-span branch January 13, 2017 08:07
@codefromthecrypt codefromthecrypt added this to the 4.0.1 milestone Jan 14, 2017
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

the ServerSpan create method, I can't call
1 participant