Skip to content

Commit

Permalink
Merge pull request #1914 from newrelic/dev
Browse files Browse the repository at this point in the history
v9.1.0
  • Loading branch information
fallwith authored Mar 29, 2023
2 parents 0f83970 + a5d5bad commit 96e7aca
Show file tree
Hide file tree
Showing 682 changed files with 7,218 additions and 6,678 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ jobs:
name: Prepare mysql directory
run: sudo chown -R $USER /usr/local

- if: matrix.ruby-version == '2.4.10'
- if: matrix.ruby-version == '2.4.10'
name: Cache mysql55
id: mysql55-cache
uses: actions/[email protected]
Expand Down Expand Up @@ -265,6 +265,16 @@ jobs:
path: lib/coverage_*/.resultset.json
retention-days: 2

- name: Generate gem manifest
run: rake test:multiverse:gem_manifest

- name: Save gem manifest
uses: actions/upload-artifact@v3
with:
name: gem_manifest_${{ matrix.ruby-version }}.json
path: gem_manifest_${{ matrix.ruby-version }}.json
retention-days: 2


infinite_tracing:
needs: run_rubocop
Expand Down Expand Up @@ -336,4 +346,4 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
resultPath: lib/coverage_results/.last_run.json
failedThreshold: 93
failedThresholdBranch: 84
failedThresholdBranch: 85
9 changes: 4 additions & 5 deletions .github/workflows/ci_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
with:
ruby-version: ${{ matrix.ruby-version }}

# ,railsedge goes in 2.7+
- name: Set up mini-envs for ruby version
uses: kanga333/variable-mapper@master
with:
Expand All @@ -71,16 +70,16 @@ jobs:
"rails": "norails,rails61,rails60,rails52,rails51,rails42"
},
"2.7.7": {
"rails": "norails,rails61,rails60,rails70"
"rails": "norails,rails61,rails60,rails70,railsedge"
},
"3.0.5": {
"rails": "norails,rails61,rails60,rails70"
"rails": "norails,rails61,rails60,rails70,railsedge"
},
"3.1.3": {
"rails": "norails,rails61,rails70"
"rails": "norails,rails61,rails70,railsedge"
},
"3.2.1": {
"rails": "norails,rails61,rails70"
"rails": "norails,rails61,rails70,railsedge"
}
}
Expand Down
23 changes: 3 additions & 20 deletions .github/workflows/ci_jruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ jobs:
run: 'git config --global init.defaultBranch main'
- uses: actions/checkout@v3

# - curl is needed for Curb
# - xslt is needed for older Nokogiris, RUBY_VERSION < 2.5
# - sasl is needed for memcached
- name: Install OS packages
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev

- name: Install Ruby jruby-9.3.9.0
- name: Install Ruby jruby-9.4.2.0
uses: ruby/setup-ruby@v1
with:
ruby-version: jruby-9.3.9.0
ruby-version: jruby-9.4.2.0

- name: Bundle
run: bundle install
Expand Down Expand Up @@ -122,12 +116,6 @@ jobs:
matrix:
multiverse: [agent, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest]
steps:
- name: Set the default Java version
run: sudo update-alternatives --set java ${JAVA_HOME_8_X64}/bin/java &&
sudo update-alternatives --set javac ${JAVA_HOME_8_X64}/bin/javac &&
java -version &&
javac -version

- name: Configure git
run: 'git config --global init.defaultBranch main'

Expand All @@ -137,14 +125,10 @@ jobs:
- name: Install JRuby
uses: ruby/setup-ruby@v1
with:
ruby-version: jruby-9.3.9.0
env:
JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64
ruby-version: jruby-9.4.2.0

- name: Bundle
run: bundle install
env:
JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64

- name: Run Multiverse Tests
run: ./.github/workflows/scripts/retry_command
Expand All @@ -155,7 +139,6 @@ jobs:
SERIALIZE: 1
DB_PORT: ${{ job.services.mysql.ports[3306] }}
JRUBY_OPTS: --dev --debug
JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64

- name: Annotate errors
if: ${{ failure() }}
Expand Down
67 changes: 67 additions & 0 deletions .github/workflows/scripts/generate_release_notes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/ruby
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
# frozen_string_literal: true

require 'date'
require_relative '../../../lib/new_relic/version'

class GenerateReleaseNotes
DIVIDER = '---'
SUPPORT_STATEMENT = <<~SUPPORT_STATEMENT
<Callout variant="important">
We recommend updating to the latest agent version as soon as it's available. If you can't upgrade to the latest version, update your agents to a version at most 90 days old. Read more about [keeping agents up to date](/docs/new-relic-solutions/new-relic-one/install-configure/update-new-relic-agent/).
See the New Relic Ruby agent [EOL policy](https://docs.newrelic.com/docs/apm/agents/ruby-agent/getting-started/ruby-agent-eol-policy/) for information about agent releases and support dates.
</Callout>
SUPPORT_STATEMENT

def build_metadata
changelog = File.read('CHANGELOG.md')
latest_entry = changelog.split('##')[1].prepend('##')
titles = latest_entry.scan(/^- \*{2}(.*?)\*{2}$/).flatten # Match strings between sets of '**'
metadata = Hash.new { |h, k| h[k] = [] }

titles.each do |t|
category = t.split(':').first
case category
when 'Feature'
metadata[:features] << t.delete_prefix('Feature: ')
when 'Bugfix'
metadata[:bugs] << t.delete_prefix('Bugfix: ')
when 'Security'
metadata[:security] << t.delete_prefix('Security: ')
end
end

return metadata, latest_entry
end

def build_release_content
metadata, latest_entry = build_metadata
<<~FRONTMATTER
#{DIVIDER}
subject: Ruby agent
date: #{Date.today}
version: #{NewRelic::VERSION::STRING}
downloadLink: https://rubygems.org/downloads/newrelic_rpm-#{NewRelic::VERSION::STRING}.gem
features: #{metadata[:features]}
bugs: #{metadata[:bugs]}
security: #{metadata[:security]}
#{DIVIDER}
#{SUPPORT_STATEMENT}
#{latest_entry}
FRONTMATTER
end

def write_filename
"ruby-agent-#{NewRelic::VERSION::STRING.tr('.', '-')}.mdx"
end

def write_output_file
File.write(write_filename, build_release_content)
end
end

GenerateReleaseNotes.new.write_output_file
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ vendor/
Brewfile.lock.json
.github/actions/simplecov-report/lib/
test/minitest/minitest_time_report
gem_manifest_*.json
22 changes: 6 additions & 16 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Style/RedundantEach: # new in 1.38
Enabled: true
Style/RedundantInitialize: # new in 1.27
Enabled: true
Style/RedundantStringEscape: # new in 1.37
Style/RedundantStringEscape: # new in 1.37, 'pending' by default so enabled to make sure it's applied
Enabled: true
Style/YodaExpression: # new in 1.42
Enabled: true
Expand Down Expand Up @@ -140,7 +140,8 @@ Performance/StringIdentifierArgument: # new in 1.13
Enabled: true
Performance/StringInclude: # new in 1.7
Enabled: true

Performance/Sum: # new in 1.8, pending so left enabled explicitly until 2.0
Enabled: true

# Old cops

Expand Down Expand Up @@ -1255,9 +1256,6 @@ Style/DocumentationMethod:
Style/DoubleCopDisableDirective:
Enabled: false

Style/DoubleNegation:
Enabled: false

Style/EachForSimpleLoop:
Enabled: true

Expand Down Expand Up @@ -1318,6 +1316,9 @@ Style/ExplicitBlockArgument:
Style/ExponentialNotation:
Enabled: false

Style/FetchEnvVar:
Enabled: false

Style/FloatDivision:
Enabled: false

Expand Down Expand Up @@ -1781,17 +1782,6 @@ Style/StringConcatenation:
Style/StringHashKeys:
Enabled: false

# Disabling for now
Style/StringLiterals:
Enabled: false
# EnforcedStyle: double_quotes
# ConsistentQuotesInMultiline: false

# Disabling for now
Style/StringLiteralsInInterpolation:
Enabled: false
# EnforcedStyle: double_quotes

Style/StringMethods:
Enabled: false

Expand Down
47 changes: 4 additions & 43 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
# Offense count: 422
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 54
Max: 40
Exclude:
- test/**/*
- infinite_tracing/test/**/*
- lib/new_relic/cli/commands/deployments.rb
- test/**/*

# This cop supports safe autocorrection (--autocorrect).
Minitest/AssertInDelta:
Expand All @@ -36,6 +37,7 @@ Minitest/DuplicateTestRun:
Minitest/EmptyLineBeforeAssertionMethods:
Exclude:
- 'test/new_relic/agent_test.rb'
- 'test/new_relic/cli/commands/deployments_test.rb'

# Offense count: 269
Minitest/MultipleAssertions:
Expand All @@ -57,44 +59,3 @@ Style/ConcatArrayLiterals:
Minitest/RefuteRespondTo:
Exclude:
- 'test/new_relic/cli/commands/deployments_test.rb'

Minitest/EmptyLineBeforeAssertionMethods:
Exclude:
- 'test/new_relic/agent_test.rb'
- 'test/new_relic/cli/commands/deployments_test.rb'

# Offense count: 23
# This cop supports safe autocorrection (--autocorrect).
Performance/RegexpMatch:
Enabled: false

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: OnlySumOrWithInitialValue.
Performance/Sum:
Exclude:
- 'lib/new_relic/agent/system_info.rb'

# Offense count: 72
# This cop supports unsafe autocorrection (--autocorrect-all).
Performance/UnfreezeString:
Enabled: false

# Offense count: 21
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowedVars.
Style/FetchEnvVar:
Enabled: false

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantStringEscape:
Exclude:
- 'test/new_relic/agent/logging_test.rb'

# Offense count: 115
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Enabled: false
2 changes: 1 addition & 1 deletion .simplecov
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ end
SimpleCov.start do
enable_coverage(:branch)
SimpleCov.root(File.join(File.dirname(__FILE__), '/lib'))
track_files("**/*.rb")
track_files('**/*.rb')
formatter(SimpleCov::Formatter::SimpleFormatter) if ENV['CI']
end
62 changes: 60 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,63 @@
# New Relic Ruby Agent Release Notes

## v9.1.0

Version 9.1.0 of the agent delivers support for two new [errors inbox](https://docs.newrelic.com/docs/errors-inbox/errors-inbox/) features: error fingerprinting and user tracking, identifies the Amazon Timestream data store, removes Distributed Tracing warnings from agent logs when using Sidekiq, fixes bugs, and is tested against the recently released JRuby 9.4.2.0.

- **Feature: Error fingerprinting - supply your own errors inbox group names**

Are your error occurrences grouped poorly? Set your own error fingerprint via a callback function. A new `set_error_group_callback` public API method has been added that will accept a user defined proc. The proc will be invoked for each noticed error and whenever it returns a string, that string will be used as the error group name for the error and will take precedence over any server-side grouping that takes place with the New Relic errors inbox. This gives users much greater control over the grouping of their errors.

The customer defined proc will be expected to receive exactly one input argument, a hash. The hash contains the following:

| Key | Value |
| ---------------------| ---------------------------------------------------------------------------- |
| `:error` | The Ruby error class instance. Offers `#class`, `#message`, and `#backtrace` |
| `:customAttributes` | Any customer defined custom attributes for the current transaction |
| `:'request.uri'` | The current request URI if available |
| `:'http.statusCode'` | The HTTP status code (200, 404, etc.) if available |
| `:'http.method'` | The HTTP method (GET, PUT, etc.) if available |
| `:'error.expected'` | Whether (true) or not (false) the error was expected |
| `:'options'` | The options hash passed to `NewRelic::Agent.notice_error` |

The callback only needs to be set once per initialization of the New Relic agent.

Example usage:

```
proc = proc { |hash| "Access" if hash[:'http.statusCode'] == 401 }
NewRelic::Agent.set_error_group_callback(proc)
```

- **Feature: User tracking - associate errors with a user id**

You can now see the number of users impacted by an error group. Identify the end user with a new `set_user_id` public API method that will accept a string representation of a user id and associate that user id with the current transaction. Transactions and errors will then have a new `enduser.id` agent attribute associated with them. This will allow agent users to tag transactions and errors as belonging to given user ids in support of greater filtering and alerting capabilities.

- **Identify Amazon Timestream when the amazon_timestream AR adapter is used**

When the agent sees the [activerecord-amazon-timestream-adapter](https://rubygems.org/gems/activerecord-amazon-timestream-adapter) gem being used, it will now identify the data store as "Timestream". Thanks very much to [@wagner](https://github.com/wagner) for contributing this enhancement! [PR#1872](https://github.com/newrelic/newrelic-ruby-agent/pull/1872)

- **Bugfix: Remove Distributed Tracing related warnings from agent logs when headers are not present in Sidekiq**

Previously, the agent would log a warning to `newrelic_agent.log` every time it attempted to accept empty Distributed Tracing headers from Sidekiq jobs which could result in an excessive number of warnings. Now the agent will no longer create these warnings when using Sidekiq. [PR#1834](https://github.com/newrelic/newrelic-ruby-agent/pull/1834)

- **Bugfix: Log request headers in debug-level logs instead of human-readable Objects**

Previously, the agent sometimes received children of the `NewRelic::Agent::HTTPClients::AbstractRequest` class as an argument when `NewRelic::Agent::Transaction::DistributedTracers#log_request_headers` was called. This caused debug-level log messages that print the request headers to show human-readable Objects (ex. `#<NewRelic::Agent::HTTPClients::HTTPClientRequest:0x00007fd0dda983e0>`) instead of the request headers. Now, the hash of the request headers should always be logged. [PR#1839](https://github.com/newrelic/newrelic-ruby-agent/pull/1839)

- **Bugfix: Fix undefined method `controller_path` logged in Action Controller Instrumentation**

Previously, the agent could log an error when trying to determine the metric name in the Action Controller instrumentation if the controller class did not respond to `controller_path`. This has been resolved and the agent will no longer call this method unless the class responds to it. Thank you to [@gsar](https://github.com/gsar) for letting us know about this issue. [PR#1844](https://github.com/newrelic/newrelic-ruby-agent/pull/1844)

- **Bugfix: Fix Transaction#finish exception and decrease log level for related warning during async transactions**

Previously, the agent would raise a non-fatal error when a segment without a parent was unfinished when the transaction completed. This error was raised while constructing a `warn`-level log message. Now that Thread instrumentation is on by default, this log message emits more frequently and is less concerning. In cases where we see a Thread, Fiber, or concurrent-ruby segment in a transaction, the message will be degraded to a `debug`-level. Thanks to [@NielsKSchjoedt](https://github.com/NielsKSchjoedt) for creating the issue and [@boomer196](https://github.com/boomer196) for testing solutions. [PR#1876](https://github.com/newrelic/newrelic-ruby-agent/pull/1876)

- **CI: Target JRuby 9.4.2.0**

The agent is now actively being tested against JRuby 9.4.2.0. NOTE that this release does not contain any non-CI related changes for JRuby. Old agent versions are still expected to work with newer JRubies and the newest agent version is still expected to work with older JRubies.


## v9.0.0

Version 9.0.0 of the agent removes several deprecated configuration options and API methods, enables Thread tracing by default, adds Fiber instrumentation, removes support for Ruby versions 2.2 and 2.3, removes instrumentation for several deprecated gems, changes how the API method `set_transaction_name` works, and updates `rails_defer_initialization` to be an environment variable only configuration option.
Expand Down Expand Up @@ -92,8 +150,8 @@
- HttpClient: 2.2.0 - 2.8.0
- HttpRb: 0.9.9 - 2.2.1
- Typhoeus: 0.5.3 - 1.2.x
- Bunny: 2.0.x - 2.6.x
- ActiveMerchant: 1.25.0 - 1.64.x
- Bunny: 2.0.x - 2.6.x
- ActiveMerchant: 1.25.0 - 1.64.x


- **Updated API method `set_transaction_name`**
Expand Down
Loading

0 comments on commit 96e7aca

Please sign in to comment.