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

add sidekiq integration #79

Merged
merged 1 commit into from
Mar 2, 2017
Merged

add sidekiq integration #79

merged 1 commit into from
Mar 2, 2017

Conversation

galdor
Copy link
Contributor

@galdor galdor commented Feb 24, 2017

No description provided.

@palazzem palazzem added the integrations Involves tracing integrations label Feb 24, 2017
@LotharSee
Copy link

One thing: we should ensure we have the same app_type and span_type as Celery.
And at the same time, certainly define what they should be.

https://github.com/DataDog/dd-trace-py/blob/master/ddtrace/ext/__init__.py#L6

Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

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

On the overall it's ok! Just a couple of things to check.

@@ -4,6 +4,7 @@ module AppTypes
WEB = 'web'.freeze
DB = 'db'.freeze
CACHE = 'cache'.freeze
JOB_PROCESSOR = 'job_processor'.freeze
Copy link
Contributor

Choose a reason for hiding this comment

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

actually we're using worker as suggested in another comment: https://github.com/DataDog/dd-trace-py/blob/master/ddtrace/ext/__init__.py#L6

@tracer.trace('sidekiq.job',
service: @default_service, span_type: 'job') do |span|
span.resource = job['class']
span.set_tag('sidekiq.job.queue', job['queue'])
Copy link
Contributor

Choose a reason for hiding this comment

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

is this the only tag that we have? can't we retrieve more details about the job like: https://github.com/DataDog/dd-trace-py/blob/master/ddtrace/contrib/celery/task.py#L108-L109

We should only add useful tags so if this is what sidekiq provides, we're good.

To modify the default configuration, simply pass arguments to the middleware.
For example, to change the default service name and activate the debug mode:

Sidekiq.configure_server do |config|
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually I'm wondering what happen when we use Sidekiq with Rails. The current status is that if we install both Sidekiq and Rails, when Sidekiq is executed via bundle exec ... the Rails instrumentation is activated and Sidekiq Redis calls are traced (even the x seconds polling). Is it the expected behavior? I think that this middleware must be the only way to instrument the library so we may investigate and remove the side-effect of Rails instrumentation.

Also I was thinking about providing a good pattern (I think docs are enough) to instrument Sidekiq inside the Rails initializer so that our tracing configurations are all together. In this way Sidekiq is still separated from Rails instrumentation but users can easily follow our docs to share the Rails configuration with Sidekiq.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sidekiq uses the redis library, so its calls will be traced by the redis contrib. The sidekiq contrib traces job executions, so I think we're good.


Sidekiq.configure_server do |config|
config.server_middleware do |chain|
chain.add(Datadog::Contrib::Sidekiq::Tracer, debug: true)
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that the add method appends the middleware at the bottom of the chain right? don't we have a way to keep it as the first one? in this way we can trace other middlewares execution time. If we can't, a suggestion in the docs is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently the last added middlewares are executed first, and add() append at the end.

Copy link
Contributor

@palazzem palazzem left a comment

Choose a reason for hiding this comment

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

Thanks! good to go!

@galdor galdor merged commit 10e4534 into master Mar 2, 2017
@palazzem palazzem deleted the nicolas/sidekiq branch March 6, 2017 10:10
@palazzem palazzem modified the milestone: 0.5.0 Mar 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants