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

Respect child_of: option in Tracer#trace #1082

Merged
merged 5 commits into from
Jul 13, 2020

Conversation

DocX
Copy link
Contributor

@DocX DocX commented Jun 15, 2020

It is documented behaviour in Getting Started guide, however the implementation did not respect it and always used the current context instead - even if the option was passed.

This change makes passing child_of: option to Tracer.trace effective.

@DocX DocX requested a review from a team June 15, 2020 10:48
@DocX DocX changed the title Allow passing child_of: to Tracer.trace Allow passing child_of: to Tracer#trace Jun 15, 2020
@DocX DocX changed the title Allow passing child_of: to Tracer#trace Respect child_of: option in Tracer#trace Jun 15, 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.

This change makes a lot of sense. Nice work with the tests, too.

We'll need to rebase and rerun tests after Excon is fixed, to make sure this doesn't cause any problems elsewhere in CI. Otherwise though, I'm happy with this, and it should be good to merge.

@delner delner added bug Involves a bug community Was opened by a community member core Involves Datadog core libraries labels Jun 15, 2020
@marcotc
Copy link
Member

marcotc commented Jun 18, 2020

@DocX could you please rebase with master? The excon CI failure should be fixed now.

It is documented behaviour in Getting Started guide, however the implementation did not respect it and always used the current context instead, even if the option was passed. This change makes passing `child_of:` option to `Tracer.trace` effective.
@DocX DocX force-pushed the ld/tracer-trace-child-of branch from 71bd093 to af40d0f Compare June 19, 2020 07:44
@DocX DocX requested a review from delner June 19, 2020 07:44
@DocX
Copy link
Contributor Author

DocX commented Jun 23, 2020

@marcotc merged :)

@DocX
Copy link
Contributor Author

DocX commented Jul 1, 2020

@marcotc Hi, can you please help me with the failing tests? I can't figure out why is it failing :(

@delner
Copy link
Contributor

delner commented Jul 1, 2020

From a glance, it looks like in Rails the traces are not being constructed as expected... I see some differences in an array of Span, so your change may somehow affect Rails instrumentation. I think you'd have to dig into the Rails test in question, compare the generated trace to the expected output, and reason whether the test is wrong, or Rails instrumentation is doing something it shouldn't.

@marcotc should be able to follow up with you soon on this, if you still need more help.

@DocX
Copy link
Contributor Author

DocX commented Jul 9, 2020

@delner thanks for update

@marcotc I would appreciate help on this, if you have context about the rails integration. thanks

@DocX
Copy link
Contributor Author

DocX commented Jul 9, 2020

I tried to test the failed examples, but when run alone they don't fail. So it seems there is some inter-example dependency or leak of some state:

bundle exec appraisal rails5-mysql2 ruby -I test test/contrib/rails/controller_test.rb 'template partial rendering is properly traced'

...

..............

Finished in 0.494967s, 30.3051 runs/s, 236.3794 assertions/s.

15 runs, 117 assertions, 0 failures, 0 errors, 0 skips

@marcotc
Copy link
Member

marcotc commented Jul 9, 2020

Hey @DocX, I figured out what the issue is.
You changes have revealed that we were reusing the options Hash provided to Tracer#trace here:

tracer.trace(@span_name, @options).tap do |span|

Because we modify the provided options Hash, e.g. options[:child_of] = call_context, we were passing in polluted data to the #trace.

This wasn't an issue before because we were always overriding :child_of, which your PR fixes :)

I wrote a fix for the affected call site (it's only one affected in our code base thankfully). I thought about pushing a separate PR for it, but I believe it makes the most sense to be shipped with your PR.

Could you please include this commit in this PR? 8f33959
All current tests failures will succeed with this change.

@DocX
Copy link
Contributor Author

DocX commented Jul 13, 2020

@marcotc thanks for the help! i've added your commit to this PR :)

Copy link
Member

@marcotc marcotc left a comment

Choose a reason for hiding this comment

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

Thank you so much for this work @DocX! 🚀

@marcotc marcotc merged commit e13e429 into DataDog:master Jul 13, 2020
@ericmustin ericmustin modified the milestone: 0.42.0 Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Involves a bug community Was opened by a community member core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants