Skip to content

SamplingPriority refactor and support for UserKeep and UserDrop#59

Merged
willgittoes-dd merged 12 commits intomasterfrom
willgittoes-dd/user-sampling
Oct 16, 2018
Merged

SamplingPriority refactor and support for UserKeep and UserDrop#59
willgittoes-dd merged 12 commits intomasterfrom
willgittoes-dd/user-sampling

Conversation

@willgittoes-dd
Copy link
Copy Markdown
Contributor

The feature added is UserKeep and UserDrop (although they cannot yet easily be set by a user without compiling against our headers). The primary delta/change for this PR however, is a refactoring of how SamplingPriority is handled (set, assigned, and propagated).

Previously, SamplingPriority was a property of the SpanContext - which is not logical since it applies to a trace as a whole not a single span. However, it was there because it propagates via SpanContext. Now, SamplingPriority is handled at the Trace level, which means it is handled by the SpanBuffer, which contains the PendingTrace. When a PendingTrace completes, then the SamplingPriority is assigned (if relevant).

This should allow better behaviour of when users may apply UserKeep and UserDrop: at any time before a trace propagates or the root span finishes.

Also:

  • Renamed a random method from snake_case to camelCase.
  • Added more verbosity to tsan output.

@willgittoes-dd willgittoes-dd force-pushed the willgittoes-dd/user-sampling branch from 0b32a70 to 71558f4 Compare October 8, 2018 21:05
Copy link
Copy Markdown
Contributor

@cgilmour cgilmour left a comment

Choose a reason for hiding this comment

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

Approving.

A couple of questions:
Should anything be done for the tag sampling.priority?
Is important information to look up the priority lost when the traces are flushed?

@willgittoes-dd
Copy link
Copy Markdown
Contributor Author

Re: sampling.priority, YES! Since that's what rnburn asked for.

Re: the second question, not sure what you mean.

@cgilmour
Copy link
Copy Markdown
Contributor

Re: the second question, not sure what you mean.
Never mind, I'd misunderstood the lifecycle of things in the pending traces map.

@willgittoes-dd
Copy link
Copy Markdown
Contributor Author

Sampling priority tag added, please review the latest commit!

Comment thread src/span.cpp Outdated
const std::string datadog_service_name_tag = "service.name";
const std::string http_url_tag = "http.url";
const std::string operation_name_tag = "operation";
const std::string priority_sampling_tag = "sampling.priority";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The tag is defined by opentracing in opentracing/ext/tags.h.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tru dat.

Comment thread test/propagation_test.cpp

// There's two ways we can set the sampling priority. Either directly using the method, or
// through a tag. Test both.
auto setSamplingPriority = GENERATE(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fancy!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah innit?!

Comment thread test/propagation_test.cpp
if (p != nullptr) {
span->SetTag("sampling.priority", static_cast<int>(*p));
} else {
span->SetTag("sampling.priority", "");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should it just be unset?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's what this does. So in addition to the spec of "0 = discard, anything else = keep" I'm adding a way to unset the sampling priority, by passing in an empty string.

@cgilmour
Copy link
Copy Markdown
Contributor

A few review comments.

@willgittoes-dd willgittoes-dd force-pushed the willgittoes-dd/user-sampling branch from c6ab704 to 8591887 Compare October 16, 2018 01:10
@cgilmour
Copy link
Copy Markdown
Contributor

Still approved 👍

@willgittoes-dd willgittoes-dd merged commit e9b24c2 into master Oct 16, 2018
@willgittoes-dd willgittoes-dd deleted the willgittoes-dd/user-sampling branch October 16, 2018 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants