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

Updated implementation of partial trace flushing #845

Merged
merged 12 commits into from
Jan 7, 2020

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Oct 25, 2019

This PR updates partial trace flushing to conform with current requirements of the Datadog agent and processing back-end.

Most restrictions have been lifted regarding flushing partial traces, allowing for a much simpler implementation.

Finished spans from a trace can now be flushed immediately, regardless of their place on the trace tree hierarchy.

@marcotc marcotc added core Involves Datadog core libraries feature Involves a product feature labels Oct 25, 2019
@marcotc marcotc requested a review from a team October 25, 2019 20:33
@marcotc marcotc self-assigned this Oct 25, 2019
lib/ddtrace/context.rb Outdated Show resolved Hide resolved
lib/ddtrace/context/flush/partial.rb Outdated Show resolved Hide resolved
lib/ddtrace/context.rb Outdated Show resolved Hide resolved
lib/ddtrace/tracer.rb Outdated Show resolved Hide resolved
@delner delner added this to In review in Active work Nov 21, 2019
@marcotc marcotc changed the title Updated implementation of partial tracing flushing Updated implementation of partial trace flushing Dec 3, 2019
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

Just some comments from our review so far!

lib/ddtrace/context.rb Outdated Show resolved Hide resolved
lib/ddtrace/context/thread_local.rb Outdated Show resolved Hide resolved
lib/ddtrace/context.rb Outdated Show resolved Hide resolved
lib/ddtrace/context.rb Outdated Show resolved Hide resolved
lib/ddtrace/context/flush/partial.rb Outdated Show resolved Hide resolved
lib/ddtrace/context/flush/partial.rb Outdated Show resolved Hide resolved
@@ -199,15 +250,15 @@ def check_finished_spans
@finished_spans > 0 && @trace.length == @finished_spans
end

def attach_sampling_priority
@current_root_span.set_metric(
def attach_sampling_priority(span)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we could extract these functions + configure_root_span to some kind of Flush base for Finished and Partial; these functions are used only for flushing, and don't describe something generally useful for Contexts.

Copy link
Member Author

@marcotc marcotc Dec 5, 2019

Choose a reason for hiding this comment

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

Because Context#get calls reset when returning a complete trace, we can't call this method after the fact. There's no good way really to move this logic away from Context given today's state.

I think a good solution is to make the Context "less smart", as methods like #get have a lot of logic in it that could be extracted to be ContextFlush responsibilities, like you suggested. That has to be done in a thread-safe way, respecting the possibility that Context is reused on the same thread after reset is called.

This to me looks like a separate, larger refactor in its own merit. I don't think the changes in PR go against that goal, on the contrary, but do I agree that this PR doesn't fully address the abstraction issue that currently existing with the Context.

I'd like to go ahead with the scope of this PR and schedule this much needed refactor for the near future.

@marcotc marcotc requested a review from delner December 5, 2019 21:37
@marcotc
Copy link
Member Author

marcotc commented Dec 20, 2019

All comments should have been addressed, ready for review.

Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

This looks really good, and I think we're pretty much done. Just one minor clarifying question about naming then I think its ready to merge.

Given our reflection during this refactor, as we go forward, I think we might want to consider extracting more complexity from the Context and the Tracer as we discussed before. I think this PR makes a good first step, but it would be prudent to ensure the coupling between these components and other processes (such as flushing) is reduced to keep these components more maintainable.

lib/ddtrace/context.rb Show resolved Hide resolved
lib/ddtrace/context_flush.rb Outdated Show resolved Hide resolved
lib/ddtrace/tracer.rb Show resolved Hide resolved
@marcotc marcotc requested a review from delner January 6, 2020 20:02
delner
delner previously approved these changes Jan 6, 2020
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

One minor suggestion, but non-blocking. Otherwise merge at your discretion.

Thanks @marco! 🎉

lib/ddtrace/context_flush.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@delner delner left a comment

Choose a reason for hiding this comment

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

👍

@marcotc marcotc merged commit 8a9fb55 into master Jan 7, 2020
Active work automation moved this from In review to Merged & awaiting release Jan 7, 2020
@marcotc marcotc deleted the feat/partial-flushing branch January 7, 2020 18:38
@marcotc marcotc added this to the 0.31.0 milestone Jan 7, 2020
@delner delner moved this from Merged & awaiting release to Released in Active work Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries feature Involves a product feature
Projects
Active work
  
Released
Development

Successfully merging this pull request may close these issues.

None yet

3 participants