Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @drewbailey for the PR! Actually the
set_service_infoonly sends metadata to change some UI behavior (i.e. is it a Web, Database or a Cache service?). Our current signature is: https://github.com/drewbailey/dd-trace-rb/blob/6c3ed6302d11432d2985b5a2f65a6e4e04b20cdd/lib/ddtrace/tracer.rb#L128-L139where:
serviceis your service name, so what you choose with thePininstance; it's not related to what will be your service name (maybe we should document that better)appis the application name used to distinguish the framework/library. Examples arerails,resque,faradayand so on. Not strictly related to the service itselfapp_typeused to define if it's a worker, cache, web service etc. It's mostly used in the UI to filter servicesSaid that, if we miss the
set_service_infocall, nothing really changes in how we collect data. Anyway, can you check if having that in your Rails initializer works or not:Thank you again for the PR and any feedback you'll provide!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the reply @palazzem! That seems to work although it unfortunately needs to be guarded in the event that pin is nil when the app initializes. Would the following be acceptable?
require 'ddtrace/ext/app_types' require 'resque' module Datadog module Contrib module Resque # Uses Resque job hooks to create traces module ResqueJob def around_perform(*args) pin = Pin.get_from(::Resque) pin.tracer.trace('resque.job', service: pin.service) do |span| span.resource = name span.span_type = pin.app_type yield span.service = pin.service end end def after_perform(*args) pin = Pin.get_from(::Resque) pin.tracer.shutdown! end end end end end Resque.before_first_fork do + service = ::Rails.configuration.datadog_trace.fetch(:resque_service) || 'resque' pin = Datadog::Pin.get_from(Resque) + pin.service = service pin.tracer.set_service_info(pin.service, service, Datadog::Ext::AppTypes::WORKER) endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably yes, but would be preferable not having any Rails specific configuration in the integration. Mostly we prefer to keep each single integration Rails agnostic, though the current configuration system couples a lot of things (so your PR makes sense and is correct with our current implementation).
Anyway, we're rewriting the configuration system in #203 that allows exactly what you need without changing the
resque_servicefrom the Rails config. It would simply:That PR should be ready very soon. Do you mind if we wait a bit more so we can update your contribution with the new configuration and see how does it look?
Also feel free to give your feedback to the PR above!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, makes sense! Looking forward to #203