Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch: Only try once per client instance to get cluster name #2743

Merged
merged 6 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# New Relic Ruby Agent Release Notes

## <dev>
Version <dev> introduces instrumentation for the LogStasher gem and improves instrumentation for the `redis-clustering` gem.
Version <dev> introduces instrumentation for the LogStasher gem, improves instrumentation for the `redis-clustering` gem, and updates the Elasticsearch instrumentation to only attempt to get the cluster name once per client, even if it fails.

- **Feature: Add instrumentation for LogStasher**

Expand All @@ -11,6 +11,11 @@ Version <dev> introduces instrumentation for the LogStasher gem and improves ins

Version 5.x of the `redis` gem moved cluster behavior into a different gem, `redis-clustering`. This gem can access instrumentation registered through `RedisClient::Middleware`. Previously, the agent only instrumented the `call_pipelined` method through this approach, but now users of the `redis-clustering` gem will also have instrumentation registered for `connect` and `call` methods. In addition, the way the `database_name` attribute is set for Redis datastore spans is now compatible with all versions of Redis supported by the New Relic Ruby agent. Thank you, [@praveen-ks](https://github.com/praveen-ks) for bringing this to our attention. [Issue#2444](https://github.com/newrelic/newrelic-ruby-agent/issues/2444) [PR#2720](https://github.com/newrelic/newrelic-ruby-agent/pull/2720)

- **Bugfix: Update Elasticsearch instrumentation to only attempt to get the cluster name once per client**

Previously, the agent would attempt to get the cluster name every time a call was made if it was not already captured. This could lead to a large number of failures if the cluster name could not be retrieved. Now, the agent will only attempt to get the cluster name once per client, even if it fails. Thank you, [@ascoppa](https://github.com/ascoppa) for bringing this to our attention. [Issue#2730](https://github.com/newrelic/newrelic-ruby-agent/issues/2730) [PR#2743](https://github.com/newrelic/newrelic-ruby-agent/pull/2743)


## v9.11.0

Version 9.11.0 introduces instrumentation for the aws-sdk-sqs gem, fixes a bug related to expected errors not bearing a "true" value for the "expected" attribute if expected as a result of an HTTP status code match and changes the way Stripe instrumentation metrics are named to prevent high-cardinality issues.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def nr_reported_query(query)
end

def nr_cluster_name
return @nr_cluster_name if @nr_cluster_name
return @nr_cluster_name if defined?(@nr_cluster_name)
return if nr_hosts.empty?

NewRelic::Agent.disable_all_tracing do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ def test_segment_database_name
assert_equal 'docker-cluster', @segment.database_name
end

def test_cluster_name_doesnt_try_again_if_defined_but_nil
original = @client.instance_variable_get(:@transport).instance_variable_get(:@nr_cluster_name)
@client.instance_variable_get(:@transport).instance_variable_set(:@nr_cluster_name, nil)
search
@client.instance_variable_get(:@transport).instance_variable_set(:@nr_cluster_name, original)

assert_nil @segment.database_name
end

def test_nosql_statement_recorded_params_obfuscated
with_config(:'elasticsearch.obfuscate_queries' => true) do
txn = in_transaction do
Expand Down
Loading