Skip to content

Commit

Permalink
Merge pull request #1876 from newrelic/bugfix/transaction_finish_nil_…
Browse files Browse the repository at this point in the history
…parent

Add safe navigation to parent.name in warn message
  • Loading branch information
kaylareopelle authored Mar 16, 2023
2 parents 3dc000d + 794f872 commit 8a0c06c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,30 @@

## dev

Upcoming version identifies the Amazon Timesteam data store, removes Distributed Tracing warnings from agent logs when using Sidekiq, fixes a bug regarding logged request headers, and is tested against the recently released JRuby 9.4.2.0.
Upcoming version identifies the Amazon Timesteam 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.


- **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: Removes Distributed Tracing related warnings from agent logs when headers are not present in Sidekiq**
- **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: Undefined method `controller_path` logged in Action Controller Instrumentation**
- **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)

- **CI: target JRuby 9.4.2.0**
- **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 instrumentatation 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.

Expand Down
1 change: 1 addition & 0 deletions lib/new_relic/agent/tracer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ def thread_block_with_current_transaction(*args, segment_name:, parent: nil, &bl
begin
if current_txn
NewRelic::Agent::Tracer.state.current_transaction = current_txn
current_txn.async = true
segment_name += "/Thread#{::Thread.current.object_id}/Fiber#{::Fiber.current.object_id}" if NewRelic::Agent.config[:'thread_ids_enabled']
segment = NewRelic::Agent::Tracer.start_segment(name: segment_name, parent: parent)
end
Expand Down
4 changes: 2 additions & 2 deletions lib/new_relic/agent/transaction/abstract_segment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ def add_child_timing(segment)

def force_finish
finish
NewRelic::Agent.logger.warn("Segment: #{name} was unfinished at " \
NewRelic::Agent.logger.send(transaction.async? ? :debug : :warn, "Segment: #{name} was unfinished at " \
"the end of transaction. Timing information for this segment's " \
"parent #{parent.name} in #{transaction.best_name} may be inaccurate.")
"parent #{parent&.name} in #{transaction.best_name} may be inaccurate.")
end

def run_complete_callbacks
Expand Down

0 comments on commit 8a0c06c

Please sign in to comment.