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 racecar integration #268

Merged
merged 8 commits into from
Dec 22, 2017
Merged

Add racecar integration #268

merged 8 commits into from
Dec 22, 2017

Conversation

p-lambert
Copy link
Member

@p-lambert p-lambert commented Dec 7, 2017

This PR provides instrumentation support for racecar.

Usage

Datadog.configure do |c|
  c.use :racecar
end

@p-lambert p-lambert added do-not-merge/WIP Not ready for merge integrations Involves tracing integrations labels Dec 7, 2017
@p-lambert p-lambert force-pushed the pedro/add-racecar-integration branch from 8f5aa2b to c0ff401 Compare December 7, 2017 19:04
require_relative 'tracer'

::Racecar.singleton_class.class_eval do
alias_method :__instrumenter, :instrumenter
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to make this work now that the start_ notifications are emitted?

@p-lambert p-lambert force-pushed the pedro/add-racecar-integration branch 3 times, most recently from a8ec3fc to b878e26 Compare December 13, 2017 20:17
@p-lambert p-lambert removed the do-not-merge/WIP Not ready for merge label Dec 13, 2017
@palazzem palazzem added this to the 0.11.0 milestone Dec 14, 2017
::ActiveSupport::Notifications.subscribe('start_process_batch.racecar', &method(:start))
::ActiveSupport::Notifications.subscribe('start_process_message.racecar', &method(:start))
::ActiveSupport::Notifications.subscribe('process_batch.racecar', &method(:finish))
::ActiveSupport::Notifications.subscribe('process_message.racecar', &method(:finish))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to separate message processing from batch processing – at least give the spans different names.

Copy link
Member Author

@p-lambert p-lambert Dec 18, 2017

Choose a reason for hiding this comment

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

Hey @dasch! Apologies for the late reply. I'm not sure if I fully understand the problem here. As far as I understand each worker either implements a process or process_batch method, correct? So each span will belong to a resource that univocally represents either a batch or a message message consumer.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's true, but a service can change from one to the other, and often will – batching is a performance optimization. Naming the top-level span either process_message or process_batch would make it clear what the trace represents.

Copy link
Member Author

@p-lambert p-lambert Dec 18, 2017

Choose a reason for hiding this comment

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

I see! I'll make that change then!

span.set_tag('kafka.consumer', payload[:consumer_class])
span.set_tag('kafka.partition', payload[:partition])
span.set_tag('kafka.offset', payload[:offset]) if payload.key?(:offset)
span.set_tag('kafka.first_offset', payload[:first_offset]) if payload.key?(:first_offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

This mixes up batch processing and individual message processing. For the former, you'd be interested in

  1. The start and end offsets
  2. The batch size

For the latter you're just interested in the offset of that specific message.

Copy link
Member Author

@p-lambert p-lambert Dec 18, 2017

Choose a reason for hiding this comment

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

@dasch I'm conditionally setting the fields kafka.offset and kafka.first_offset.

  • For the process_message.racecar event you provide a payload with consumer_class, topic, partition and offset so these are set in the span accordingly.
  • For the process_batch.racecar, event you provide a payload with consumer_class, topic, partition and first_offset which are the fields set in batch consumer spans.
    Let me know if that makes sense!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I was just confused by both message and batch processing was mixed together. For batch processing, the number of messages is obviously important.

Copy link
Member Author

Choose a reason for hiding this comment

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

So do you plan to update the instrumentation payload with that field?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, thought I already had that! I'll add it now.

Copy link
Contributor

Choose a reason for hiding this comment

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

zendesk/racecar#47

You can add the field conditionally, I'll merge this ASAP.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, thank you!

Copy link
Contributor

@dasch dasch 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!

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.

👍

@p-lambert p-lambert merged commit f5061db into master Dec 22, 2017
@delner delner deleted the pedro/add-racecar-integration branch February 9, 2018 18:52
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.

4 participants