Skip to content

Commit

Permalink
Group together APM service tags with subdomains
Browse files Browse the repository at this point in the history
Currently we create one "service" per domain we call (see the
split_by_domain setting just above). This works fine except for cases
like Shopify or Ngrok, which use subdomains for users. In those cases,
it's more representative to group all the subdomains together under one
service.
  • Loading branch information
sulami committed Jan 24, 2024
1 parent 685381e commit ceb0d3b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/degica_datadog/tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ def init(rake_tasks: []) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
c.tracing.instrument :httpclient, split_by_domain: true
c.tracing.instrument :httprb, split_by_domain: true
end

# This block is called before traces are sent to the agent, and allows
# us to modify or filter them.
Datadog::Tracing.before_flush do |trace|
Datadog::Tracing::Pipeline::SpanProcessor.new do |span|
# Group subdomains in service tags together.
span.service = "myshopify.com" if span.service.end_with?("myshopify.com")
span.service = "ngrok.io" if span.service.end_with?("ngrok.io")
span.service = "ngrok-free.app" if span.service.end_with?("ngrok-free.app")
end

trace
end
end

# Start a new span.
Expand Down

0 comments on commit ceb0d3b

Please sign in to comment.