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

feature Integrate Shoryuken into ddtracer #626

Merged
merged 1 commit into from
Dec 10, 2018

Conversation

JustSnow
Copy link
Contributor

@JustSnow JustSnow commented Nov 8, 2018

No description provided.

@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch from 6a90844 to 4c8c790 Compare November 13, 2018 14:38
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.

All-in-all this is a great start! I'm really pleased to see this contribution, and that you've already implemented the integration standard we had recently setup.

There are just some minor changes I'd suggest making (nothing serious.) Additionally we should add some RSpec tests and documentation to match the changes here before we merge.

We'll want to merge this to 0.18-dev, our feature branch, so you'll want to rebase it on that (which should also fix the broken tests you were seeing in the build.) If you add any other commits which kick off a build, don't worry if the "prerelease gem" steps fails; as long as all the other steps are green, we can call it ready.

Thanks for submitting this @JustSnow ! Looking forward to getting this in!

@tracer = options[:tracer] || Datadog.configuration[:shoryuken][:tracer]
@shoryuken_service = options[:service_name] || Datadog.configuration[:shoryuken][:service_name]
@tracer.enabled = options[:enabled] || Datadog.configuration[:shoryuken][:enabled]
Datadog::Tracer.debug_logging = options[:debug] || Datadog.configuration[:shoryuken][:debug]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this option is necessary, users should be able to enable/disable tracer debug logging via the tracer itself.

def initialize(options = {})
@tracer = options[:tracer] || Datadog.configuration[:shoryuken][:tracer]
@shoryuken_service = options[:service_name] || Datadog.configuration[:shoryuken][:service_name]
@tracer.enabled = options[:enabled] || Datadog.configuration[:shoryuken][:enabled]
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think is option is necessary either.

set_service_info(@shoryuken_service)

@tracer.trace(Ext::SPAN_JOB, service: @shoryuken_service, span_type: Datadog::Ext::AppTypes::WORKER) do |span|
span.resource = tracer_info[:resource]
Copy link
Contributor

Choose a reason for hiding this comment

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

These values should all be directly accessible within this block, right? If so, I'd suggest removing the tracer_info hash and access the values directly instead. This should save on a bit of memory allocation per call.

e.g.

span.set_tag(Ext::TAG_JOB_ID, sqs_msg.message_id)

tracer_info[:job_attribites] = sqs_msg.attributes
tracer_info[:body] = body

set_service_info(@shoryuken_service)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since setting service info only needs to be done once, I might advise moving this to the constructor instead, which would prevent unnecessary checks and save a little performance.

# Default settings for the Shoryuken integration
class Settings < Contrib::Configuration::Settings
option :service_name, default: Ext::SERVICE_NAME
option :debug, default: false
Copy link
Contributor

Choose a reason for hiding this comment

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

The debug and enabled options could also be removed here (as its related to the suggested change in tracer.rb)

@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch from 4c8c790 to e155dbc Compare November 14, 2018 09:02
@JustSnow JustSnow changed the base branch from master to 0.18-dev November 14, 2018 09:02
@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch from e155dbc to fe8665b Compare November 14, 2018 09:05
@JustSnow
Copy link
Contributor Author

@delner fixed comments. Will think about tests. If you have suggestions, would be good to see them :)

@delner
Copy link
Contributor

delner commented Nov 14, 2018

@JustSnow For tests, I think we just need some basic RSpec tests that verify that it traces a job properly. You'd probably want to find a way to mock an incoming message from SQS (from within the test suite as opposed to setting up an external service), then use that to drive the test and verify it generated traces with the expected attributes. You might want to look at something like Racecar as an example.

Also, could you try this out in an actual application and share a screenshot of how the trace looks in the UI? I'd very much like to see what it looks like in action!

@JustSnow
Copy link
Contributor Author

@delner
shoryuken-datadog-trace

@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch from 742a8b9 to 7044a5a Compare November 19, 2018 14:53
@delner
Copy link
Contributor

delner commented Nov 28, 2018

@JustSnow Overall this is looking very good; I think its all configured pretty much as we'd like to see it. We should add more tests that simulate a Shoryuken job running, which verify that it produces a span with the appropriate name, resource, service, and tags w/ values at minimum.

There should be a number of other integrations you should be able to copy tests from that verify similar behavior, it'd just be a matter then of modifying them to have them trigger a Shoryuken job.

Once we have that in, I think we can do a final review and merge this.

@JustSnow
Copy link
Contributor Author

@delner totally agree. working on it, but don't have enough time to finish tests

@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch 2 times, most recently from 37f7814 to b4a1cf0 Compare December 4, 2018 13:49
end

before do
allow(Shoryuken::Client).to receive(:queues).with(queue).and_return sqs_queue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@delner maybe do you know or some one can suggest right way how to run shoryuken client for test to getting spans from writer

@delner
Copy link
Contributor

delner commented Dec 6, 2018

@JustSnow I created a diff.txt you can apply to this PR which should update it with a test that runs Shoryuken in a test. (Your repo didn't grant push permissions from the upstream, otherwise I would've pushed it myself.)

Unfortunately it appears our tests for this won't work though for this because Shoryuken doesn't run middleware when running workers inline for tests. I opened an issue and we'll see if this gets merged/released for Shoryuken.

We probably can merge and release this integration in the mean time, but we'll need to make sure we update the CI accordingly later.

@JustSnow JustSnow force-pushed the feature/integrate-shoryuken branch from b4a1cf0 to 87eade8 Compare December 10, 2018 13:52
@JustSnow
Copy link
Contributor Author

@delner updated according diff.txt. Hope all are right. This is strange what you can't push commits here, because I allowed to do it all who has edit permission on dd-trace repo (Allow edits from maintainers. is enabled)

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.

Looks good! We'll have to update the tests when the other issue in Shoryuken is resolved, but this should be okay for now. Thanks so much for your contribution! 🎉

@delner delner merged commit d719f4a into DataDog:0.18-dev Dec 10, 2018
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