Skip to content

Commit

Permalink
refactor dig
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahramadan committed Dec 20, 2024
1 parent 15896b9 commit e077f46
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def instrument_method_with_new_relic(method_name, *args)
end

def get_segment_name(method_name, params)
return "#{FIREHOSE}/#{method_name}/#{params[:delivery_stream_name]}" if params&.dig(:delivery_stream_name)
stream_name = params&.dig(:delivery_stream_name)
return "#{FIREHOSE}/#{method_name}/#{stream_name}" if stream_name

"#{FIREHOSE}/#{method_name}"
rescue => e
Expand All @@ -55,9 +56,10 @@ def nr_account_id
end

def get_arn(params)
return params[:delivery_stream_arn] if params&.dig(:delivery_stream_arn)
return params.dig(:delivery_stream_arn) if params&.dig(:delivery_stream_arn)

NewRelic::Agent::Aws.create_arn(FIREHOSE.downcase, "deliverystream/#{params[:delivery_stream_name]}", config&.region, nr_account_id) if params[:delivery_stream_name]
stream_name = params&.dig(:delivery_stream_name)
NewRelic::Agent::Aws.create_arn(FIREHOSE.downcase, "deliverystream/#{stream_name}", config&.region, nr_account_id) if stream_name
end
end
end

0 comments on commit e077f46

Please sign in to comment.