Skip to content

Commit

Permalink
Merge branch 'dev' into presto_chango
Browse files Browse the repository at this point in the history
  • Loading branch information
fallwith committed Oct 10, 2024
2 parents e80d166 + c96ac53 commit 22ceb3e
Show file tree
Hide file tree
Showing 23 changed files with 94 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .github/versions.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
# This file is consumed by lib/tasks/gha.rake
ruby/setup-ruby:
:tag: v1.191.0
:sha: 52753b7da854d5c07df37391a986c76ab4615999
:tag: v1.196.0
:sha: f26937343756480a8cb3ae1f623b9c8d89ed6984
actions/checkout:
:tag: v4.1.7
:sha: 692973e3d937129bcbf40652eb9f2f61becf3332
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Configure git
run: 'git config --global init.defaultBranch main'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: '3.3'
- run: bundle
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down Expand Up @@ -231,7 +231,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down Expand Up @@ -324,7 +324,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down Expand Up @@ -364,7 +364,7 @@ jobs:
- name: Configure git
run: 'git config --global init.defaultBranch main'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: '3.3'
- run: bundle
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Configure git
run: 'git config --global init.defaultBranch main'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: '3.3'
- run: bundle
Expand All @@ -36,7 +36,7 @@ jobs:
strategy:
fail-fast: false
matrix:
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-preview1]
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 All @@ -50,7 +50,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
"3.3.5": {
"rails": "norails,rails61,rails70,rails71,rails72,railsedge"
},
"3.4.0-preview1": {
"3.4.0-preview2": {
"rails": "norails,rails61,rails70,rails71,rails72"
}
}
Expand Down Expand Up @@ -230,7 +230,7 @@ jobs:
fail-fast: false
matrix:
multiverse: [agent, ai, background, background_2, database, 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-preview1]
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
run: 'git config --global init.defaultBranch main'
Expand All @@ -243,7 +243,7 @@ jobs:
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down Expand Up @@ -308,14 +308,14 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby-version: [2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview1]
ruby-version: [2.7.8, 3.0.7, 3.1.6, 3.2.5, 3.3.5, 3.4.0-preview2]
steps:
- name: Configure git
run: 'git config --global init.defaultBranch main'
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7

- name: Install Ruby ${{ matrix.ruby-version }}
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: ${{ matrix.ruby-version }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7

- name: Install JRuby
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: jruby-9.4.8.0

Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7

- name: Install JRuby
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: jruby-9.4.8.0

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci_special.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ jobs:
- name: Install OS packages
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev libxslt1-dev

- name: Install Ruby 3.4.0-preview1
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- name: Install Ruby 3.4.0-preview2
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.4.0-preview1
ruby-version: 3.4.0-preview2

- name: Setup bundler
run: ./.github/workflows/scripts/setup_bundler
env:
RUBY_VERSION: 3.4.0-preview1
RUBY_VERSION: 3.4.0-preview2

- name: Run Unit Tests
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # tag v3.0.0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/config_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
pull-requests: write
steps:
- name: Install Ruby 3.3
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/performance_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
with:
ref: 'main'
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: '3.3'
- run: bundle
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prerelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
pull-requests: write
steps:
- name: Install Ruby 3.3
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 0

- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
pull-requests: write
steps:
- name: Install Ruby 3.3
uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/slack_notifications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
gem_notifications:
runs-on: ubuntu-22.04
steps:
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
cve_notifications:
runs-on: ubuntu-22.04
steps:
- uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # tag v1.191.0
- uses: ruby/setup-ruby@f26937343756480a8cb3ae1f623b9c8d89ed6984 # tag v1.196.0
with:
ruby-version: 3.3
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # tag v4.1.7
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# New Relic Ruby Agent Release Notes

## dev

Version <dev> resolves a bug in rdkafka instrumentation when using the karafka-rdkafka gem.

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

Due to version differences between the rdkafka gem and karafka-rdkafka gem, the agent could encounter an error when it tried to install rdkafka instrumentation. This has now been resolved. Thank you to @krisdigital for bringing this issue to our attention. [PR#2880](https://github.com/newrelic/newrelic-ruby-agent/pull/2880)


## 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
1 change: 1 addition & 0 deletions lib/new_relic/agent/configuration/default_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def self.enforce_fallback(allowed_values: nil, fallback: nil)
:public => true,
:type => String,
:allowed_from_server => false,
:exclude_from_reported_settings => true,
:description => 'Your New Relic <InlinePopover type="userKey" />. Required when using the New Relic REST API v2 to record deployments using the `newrelic deployments` command.'
},
:backport_fast_active_record_connection_lookup => {
Expand Down
3 changes: 2 additions & 1 deletion lib/new_relic/agent/instrumentation/rdkafka/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ def each(**kwargs)
alias_method(:producer_without_new_relic, :producer)
alias_method(:consumer_without_new_relic, :consumer)

if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')
if Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0') ||
(Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0'))
def producer(**kwargs)
producer_without_new_relic(**kwargs).tap do |producer|
set_nr_config(producer)
Expand Down
3 changes: 2 additions & 1 deletion lib/new_relic/agent/instrumentation/rdkafka/prepend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ module RdkafkaConfig
module Prepend
include NewRelic::Agent::Instrumentation::RdkafkaConfig

if defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')
if (defined?(::Rdkafka) && Gem::Version.new(::Rdkafka::VERSION) >= Gem::Version.new('0.16.0')) ||
(Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0'))
def producer(**kwargs)
super.tap do |producer|
set_nr_config(producer)
Expand Down
6 changes: 4 additions & 2 deletions lib/new_relic/agent/span_event_primitive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ module SpanEventPrimitive
DATASTORE_CATEGORY = 'datastore'
CLIENT = 'client'

DB_STATEMENT_MAX_BYTES = 4096

# Builds a Hash of error attributes as well as the Span ID when
# an error is present. Otherwise, returns nil when no error present.
def error_attributes(segment)
Expand Down Expand Up @@ -114,9 +116,9 @@ def for_datastore_segment(segment) # rubocop:disable Metrics/AbcSize
agent_attributes[DB_SYSTEM_KEY] = segment.product if allowed?(DB_SYSTEM_KEY)

if segment.sql_statement && allowed?(DB_STATEMENT_KEY)
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.sql_statement.safe_sql, 2000)
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.sql_statement.safe_sql, DB_STATEMENT_MAX_BYTES)
elsif segment.nosql_statement && allowed?(DB_STATEMENT_KEY)
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, 2000)
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, DB_STATEMENT_MAX_BYTES)
end

[intrinsics, custom_attributes(segment), agent_attributes.merge(agent_attributes(segment))]
Expand Down
2 changes: 1 addition & 1 deletion test/agent_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def assert_log_contains(log, message)
lines = log.array

assert (lines.any? { |line| line.match(message) }),
"Could not find message. Log contained: #{lines.join("\n")}"
"Could not find message: '#{message.inspect}'. Log contained: #{lines.join("\n")}"
end

def assert_audit_log_contains(audit_log_contents, needle)
Expand Down
22 changes: 18 additions & 4 deletions test/multiverse/suites/config_file_loading/Envfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,34 @@

omit_collector!

# TODO: RUBY 3.4
# The CI has a prism-related error when it tries to run this suite
# The problem may be a bug fixed in future preview releases
# Disable ths suite for now, and try again when the next version
# is out.
PSYCH_VERSIONS = [
[nil],
['4.0.0', 2.4],
['3.3.0', 2.4]
[nil, 2.4, 3.3],
['4.0.0', 2.4, 3.3],
['3.3.0', 2.4, 3.3]
]

def stringio_version
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4')
"gem 'stringio', '3.1.2.dev'"
else
"gem 'stringio'"
end
end

def gem_list(psych_version = nil)
<<~RB
#{stringio_version}
# stub file system so we can test that newrelic.yml can be loaded from
# various places.
gem 'fakefs', :require => false

gem 'psych'#{psych_version}
gem 'jar-dependencies', '0.4.1' if RUBY_PLATFORM == 'java'
gem 'jar-dependencies', '0.4.1' if RUBY_PLATFORM == 'java'

# don't start the agent
gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,20 @@ def test_warning_logged_when_config_file_yaml_parsing_error
assert_log_contains(log, /ERROR.*Failed to read or parse configuration file at config\/newrelic\.yml/)
end

def test_warning_logged_when_config_file_erb_error
path = File.join(@cwd, 'config', 'newrelic.yml')
setup_config(path, {}, "\n\n\n<%= this is not ruby %>") # the error is on line 4
setup_agent

log = with_array_logger { NewRelic::Agent.manual_start }

assert_log_contains(log, /ERROR.*Failed ERB processing/)
assert_log_contains(log, /\(erb\):4/)
# TODO: RUBY 3.4 SUPPORT
# Both error class and output have changes in Ruby 3.4
# See Issue: https://github.com/newrelic/newrelic-ruby-agent/issues/2902
unless Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.4.0')
def test_warning_logged_when_config_file_erb_error
path = File.join(@cwd, 'config', 'newrelic.yml')
setup_config(path, {}, "\n\n\n<%= this is not ruby %>") # the error is on line 4
setup_agent

log = with_array_logger { NewRelic::Agent.manual_start }

assert_log_contains(log, /ERROR.*Failed ERB processing/)
assert_log_contains(log, /\(erb\):4/)
end
end

def test_exclude_commented_out_erb_lines
Expand Down
4 changes: 2 additions & 2 deletions test/new_relic/agent/configuration/manager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ def test_unsatisfied_values_stay_cached
def test_logger_does_not_receive_excluded_settings
log = with_array_logger(:debug) { @manager.log_config('direction', 'source') }.array.join('')

assert_includes(log, ':app_name')
refute_includes(log, ':license_key')
assert_includes(log, 'app_name')
refute_includes(log, 'license_key')
end

def test_reset_cache_return_early_for_jruby
Expand Down
Loading

0 comments on commit 22ceb3e

Please sign in to comment.