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

DD templating: conditionally invoke requires #2917

Merged
merged 2 commits into from
Oct 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require_relative '<%= @snake_name.downcase %>/instrumentation'
require_relative '<%= @snake_name.downcase %>/chain'
require_relative '<%= @snake_name.downcase %>/prepend'

DependencyDetection.defer do
named :<%= @name.match?(/\-|\_/) ? "'#{@snake_name}'" : @name.downcase %>

Expand All @@ -18,14 +14,18 @@ DependencyDetection.defer do
end

executes do
require_relative '<%= @snake_name.downcase %>/instrumentation'

# prepend_instrument and chain_instrument call extract_supportability_name
# to get the library name for supportability metrics and info-level logging.
# to get the library name for supportability metrics and info-level logging.
# This is done by spliting on the 2nd to last spot of the instrumented
# module. If this isn't how we want the name to appear, pass in the desired
# name as a third argument.
if use_prepend?
require_relative '<%= @snake_name.downcase %>/prepend'
prepend_instrument <%= @class_name %>, NewRelic::Agent::Instrumentation::<%= @class_name %>::Prepend
else
require_relative '<%= @snake_name.downcase %>/chain'
chain_instrument NewRelic::Agent::Instrumentation::<%= @class_name %>::Chain
end
end
Expand Down
Loading