Skip to content

Commit

Permalink
Add a single top level span for Racecar consumers
Browse files Browse the repository at this point in the history
Right now, Racecar consumer processes use one of two top level span
names based on the mode of operation: `racecar.message` or
`racecar.batch`. Because of this, the Datadog interface cannot show
single message consumers and batch consumers in the same list.

This change subscribes to the `main_loop` event which wraps both of
these more specific events. The new span is called `racecar.consume`
since that is the logical operation.
  • Loading branch information
dasch committed Aug 19, 2020
1 parent 7f608a8 commit 05ba58c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/ddtrace/contrib/racecar/events.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
require 'ddtrace/contrib/racecar/events/batch'
require 'ddtrace/contrib/racecar/events/message'
require 'ddtrace/contrib/racecar/events/consume'

module Datadog
module Contrib
module Racecar
# Defines collection of instrumented Racecar events
module Events
ALL = [
Events::Consume,
Events::Batch,
Events::Message
].freeze
Expand Down
27 changes: 27 additions & 0 deletions lib/ddtrace/contrib/racecar/events/consume.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require 'ddtrace/contrib/racecar/ext'
require 'ddtrace/contrib/racecar/event'

module Datadog
module Contrib
module Racecar
module Events
# Defines instrumentation for main_loop.racecar event
module Consume
include Racecar::Event

EVENT_NAME = 'main_loop.racecar'.freeze

module_function

def event_name
self::EVENT_NAME
end

def span_name
Ext::SPAN_CONSUME
end
end
end
end
end
end
1 change: 1 addition & 0 deletions lib/ddtrace/contrib/racecar/ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module Ext
ENV_ANALYTICS_SAMPLE_RATE = 'DD_TRACE_RACECAR_ANALYTICS_SAMPLE_RATE'.freeze
ENV_ANALYTICS_SAMPLE_RATE_OLD = 'DD_RACECAR_ANALYTICS_SAMPLE_RATE'.freeze
SERVICE_NAME = 'racecar'.freeze
SPAN_CONSUME = 'racecar.consume'.freeze
SPAN_BATCH = 'racecar.batch'.freeze
SPAN_MESSAGE = 'racecar.message'.freeze
TAG_CONSUMER = 'kafka.consumer'.freeze
Expand Down

0 comments on commit 05ba58c

Please sign in to comment.