# This file is distributed under New Relic’s license terms. # See github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. # frozen_string_literal: true

DependencyDetection.defer do

named :<%= @snake_name %>

depends_on do
  # The class that needs to be defined to prepend/chain onto. This can be used
  # to determine whether the library is installed.
  defined?(<%= @class_name %>)
  # Add any additional requirements to verify whether this instrumentation
  # should be installed
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.
  # 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

end