Skip to content

Commit

Permalink
Merge branch 'acinarius' of github.com:newrelic/newrelic-ruby-agent i…
Browse files Browse the repository at this point in the history
…nto acinarius
  • Loading branch information
kaylareopelle committed Oct 14, 2024
2 parents 2b78cfc + 9c373cd commit 0dee361
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ jobs:
strategy:
fail-fast: false
matrix:
multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest]
multiverse: [agent, ai, background, background_2, kafka, database, frameworks, httpclients, httpclients_2, rails, rest]
ruby-version: [2.4.10, 3.3.5]

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
strategy:
fail-fast: false
matrix:
multiverse: [agent, ai, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest]
multiverse: [agent, ai, background, background_2, database, kafka, frameworks, httpclients, httpclients_2, rails, rest]
ruby-version: [2.4.10, 2.5.9, 2.6.10, 2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2]
steps:
- name: Configure git
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## dev

Version <dev> resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem and fixes a bug with Grape instrumentation.
Version <dev> updates View Componment instrumentation to use a default metric name when one is unavaliable, resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem and fixes a bug with Grape instrumentation.

- **Feature: Use default `View/component` metric name for unidentified View Components**

Previously, when a View Component metric name could not be identified, the agent would set the name as `nil`. Now, the agent defaults to using `View/component` as the metric name when one can not be identified. [PR#2907](https://github.com/newrelic/newrelic-ruby-agent/pull/2907)

- **Bugfix: Instrumentation errors when using the karafka-rdkafka gem**

Expand All @@ -12,7 +16,6 @@ Version <dev> resolves a bug in rdkafka instrumentation when using the karafka-r

In 9.14.0, we released a fix for calls to the deprecated `Bundler.rubygems.all_specs`, but the fix fell short for the agent's Grape instrumentation and deprecation warnings could still be raised. The condition has been simplified and deprecation warnings should no longer be raised. Thank you, [@excelsior](https://github.com/excelsior) for bringing this to our attention. [Issue#](https://github.com/newrelic/newrelic-ruby-agent/issues/2885) [PR#2906](https://github.com/newrelic/newrelic-ruby-agent/pull/2906)


## v9.14.0

Version 9.14.0 adds Apache Kafka instrumentation for the rdkafka and ruby-kafka gems, introduces a configuration-based, automatic way to add custom instrumentation method tracers, correctly captures MIME type for ActionDispatch 7.0+ requests, properly handles Boolean coercion for `newrelic.yml` configuration, fixes a JRuby bug in the configuration manager, fixes a bug related to `Bundler.rubygems.installed_specs`, and fixes a bug to make the agent compatible with ViewComponent v3.15.0+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@ def render_in_with_tracing(*args)
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)

begin
segment = NewRelic::Agent::Tracer.start_segment(
name: metric_name(
self.class.respond_to?(:identifier) ? self.class.identifier : nil,
self.class.name
)
)
segment = NewRelic::Agent::Tracer.start_segment(name: metric_name)
yield
rescue => e
NewRelic::Agent.notice_error(e)
Expand All @@ -25,8 +20,12 @@ def render_in_with_tracing(*args)
end
end

def metric_name(identifier, component)
"View/#{metric_path(identifier)}/#{component}"
def metric_name
"View/#{metric_path(self.class.source_location)}/#{self.class.name}"
rescue => e
NewRelic::Agent.logger.error('Error identifying View Component metric name', e)

'View/component'
end

def metric_path(identifier)
Expand Down
1 change: 1 addition & 0 deletions test/multiverse/lib/multiverse/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def execute_suites(filter, opts)
'ai' => %w[ruby_openai],
'background' => %w[delayed_job sidekiq resque],
'background_2' => %w[rake],
'kafka' => %w[rdkafka],
'database' => %w[elasticsearch mongo redis sequel],
'rails' => %w[active_record active_record_pg active_support_broadcast_logger active_support_logger rails rails_prepend activemerchant],
'frameworks' => %w[grape padrino roda sinatra],
Expand Down
2 changes: 1 addition & 1 deletion test/multiverse/lib/multiverse/suite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ def child_command_line(env, instrumentation_method)

def check_for_failure(env)
if $? != 0
OutputCollector.write(suite, env, red("#{suite.inspect} for Envfile entry #{env} failed!"))
OutputCollector.write(suite, env, red("#{suite.inspect} for Envfile entry #{env} failed! (exit: #{$?})"))
OutputCollector.failed(suite, env)
end
Multiverse::Runner.notice_exit_status($?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@ def test_error_raised
end
end

# Test metric name being built when the controller class doesn't respond to :identifier
# https://github.com/newrelic/newrelic-ruby-agent/pull/2870
def test_the_metric_name_omits_the_identifier_when_absent
def test_the_metric_name_records_default_name_on_error
in_transaction do |txn|
FAKE_CLASS.render_in_with_tracing { 11 * 38 }
actual_name = txn.segments.last.name

assert_equal 'View/component/DummyViewComponentInstrumentationClass', actual_name
assert_equal 'View/component', actual_name
end
end
end
22 changes: 12 additions & 10 deletions test/new_relic/agent/configuration/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,20 +492,22 @@ def test_apply_transformations_reraises_errors
end

def test_auto_determined_values_stay_cached
name = :knockbreck_manse
with_config(:'security.agent.enabled' => true) do
name = :knockbreck_manse

DependencyDetection.defer do
named(name)
executes { use_prepend? }
end
DependencyDetection.defer do
named(name)
executes { use_prepend? }
end

key = :"instrumentation.#{name}"
with_config(key => 'auto') do
DependencyDetection.detect!
key = :"instrumentation.#{name}"
with_config(key => 'auto') do
DependencyDetection.detect!

@manager.replace_or_add_config(ServerSource.new({}))
@manager.replace_or_add_config(ServerSource.new({}))

assert_equal :prepend, @manager.instance_variable_get(:@cache)[key]
assert_equal :prepend, @manager.instance_variable_get(:@cache)[key]
end
end
end

Expand Down

0 comments on commit 0dee361

Please sign in to comment.