Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Introduces TraceSampler which replaces TraceFilter #118

Merged
merged 1 commit into from
Jan 7, 2016
Merged

Conversation

codefromthecrypt
Copy link
Member

TraceFilter worked off a span id, which isn't always the trace id. This
is confusing and could lead to sparse traces. This eliminates use of
TraceFilter, replaced with TraceSampler, which works off the trace id
and is implemented by a benchmarked implementation in zipkin-java.

The use of zipkin-java's TraceIdSampler is shaded, so as to neither
introduce a dependency, nor the perils of copy/paste.

Impact on users is that they should stop using TraceFilter immediately
as Brave will ignore them. Most often, they will want to only provide a
threshold, ex TraceSampler.create(0.3f) means retain 30%.

We also no longer publish brave-tracefilters and instead an equivalent
brave-tracesamplers, which has the same implementation, except based
on trace id as opposed to span id.

Finally, those using zookeeper should set the rate as a percentage, not
a ratio. For example, /brave/samplerate would be 0.2 to retain 20%.

@codefromthecrypt
Copy link
Member Author

Validated the resulting pom has no zipkin-java dependency, and the classes added are <10K

$ jar -tvf /Users/acole/.m2/repository/com/github/kristofa/brave-core/3.3.1-SNAPSHOT/brave-core-3.3.1-SNAPSHOT.jar |grep com/github/kristofa/brave/internal/io/zipkin/
     0 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/
     0 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/internal/
  3124 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/internal/Util.class
   371 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/internal/Nullable.class
   671 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/TraceIdSampler$1.class
   670 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/TraceIdSampler$2.class
  1426 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/TraceIdSampler$ThresholdSampler.class
  1041 Thu Jan 07 16:12:08 SGT 2016 com/github/kristofa/brave/internal/io/zipkin/TraceIdSampler.class

@codefromthecrypt codefromthecrypt force-pushed the tracesampler branch 2 times, most recently from e2408d0 to 85ec72f Compare January 7, 2016 08:28
@@ -37,7 +36,7 @@ public static Builder builder() {
abstract ClientSpanAndEndpoint spanAndEndpoint();
abstract Random randomGenerator();
abstract SpanCollector spanCollector();
abstract List<TraceFilter> traceFilters();
Copy link
Member Author

Choose a reason for hiding this comment

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

no more list.. if people have cause to create multiple tiers of filtering, they can make a composite one.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, agree. I don't think anyone actually used multiple filters.

<packaging>jar</packaging>
<name>brave-tracefilters</name>
<name>brave-tracesamplers</name>
Copy link
Member Author

Choose a reason for hiding this comment

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

ps kindof inclined to call this brave-zookeeper or brave-sampler-zookeeper

Copy link
Member Author

Choose a reason for hiding this comment

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

because if we add something inside that doesn't have a ZK dep, then we'd end up with a similar problem as if we put it in core (the problem of unnecessary deps).

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's a good point. Let's do it!

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

TraceFilter worked off a span id, which isn't always the trace id. This
is confusing and could lead to sparse traces. This eliminates use of
TraceFilter, replaced with TraceSampler, which works off the trace id
and is implemented by a benchmarked implementation in zipkin-java.

The use of zipkin-java's TraceIdSampler is shaded, so as to neither
introduce a dependency, nor the perils of copy/paste.

Impact on users is that they should stop using TraceFilter immediately
as Brave will ignore them. Most often, they will want to only provide a
threshold, ex `TraceSampler.create(0.3f)` means retain 30%.

We also no longer publish `brave-tracefilters` and instead an equivalent
`brave-tracesamplers`, which has the same implementation, except based
on trace id as opposed to span id.

Finally, those using zookeeper should set the rate as a percentage, not
a ratio. For example, `/brave/samplerate` would be 0.2 to retain 20%.
@kristofa
Copy link
Member

kristofa commented Jan 7, 2016

I think this is good to go. 👍

This is a breaking change so if we are strict about semantic versioning it should be 4.x. However I don't feel like it should be a major bump. Major bump would be rip out thrift and replace with Java implementation or replace propagation of state with new implementation. wdyt?

@codefromthecrypt
Copy link
Member Author

codefromthecrypt commented Jan 7, 2016 via email

@kristofa
Copy link
Member

kristofa commented Jan 7, 2016

Yes, agree :) Previous breaking changes were renames as far as I can remember (like scribe span collector). But still breaking changes. This one has a larger impact. Let's make it 4.x

@codefromthecrypt
Copy link
Member Author

codefromthecrypt commented Jan 7, 2016 via email

@kristofa
Copy link
Member

kristofa commented Jan 7, 2016

Oh, ok, let's stick to my initial, and your view and leave it at to 3.x. We should just make the release notes clear about what needs to change.

@codefromthecrypt
Copy link
Member Author

yeah. essentially...

  • If not using TraceFilter, do nothing
  • If using TraceFilter, your code won't break, but your sample ratio will
    be ignored. Switch to TraceSampler with a percentage.
  • If using ZK, you'll need to change your maven dependencies, change to the
    ZookeeperTraceSampler, and re-assign your rate in ZK to
    a percentage instead of a ratio.

@kristofa
Copy link
Member

kristofa commented Jan 7, 2016

👍

kristofa added a commit that referenced this pull request Jan 7, 2016
Introduces TraceSampler which replaces TraceFilter
@kristofa kristofa merged commit 165ce16 into master Jan 7, 2016
@kristofa kristofa deleted the tracesampler branch January 7, 2016 13:41
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