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

Add elasticsearch.capture_cluster_name config #3038

Merged
merged 7 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from 6 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# New Relic Ruby Agent Release Notes

## dev

- **Feature: Add elasticsearch.capture_cluster_name configuration option**

A new configuration option, `elasticsearch.capture_cluster_name`, has been added to control capturing Elasticsearch cluster names. Cluster names are captured by default, but can now be disabled as needed. [PR#3038](https://github.com/newrelic/newrelic-ruby-agent/pull/3038)

## v9.17.0

- **Feature: Support Ruby 3.4.0**
Expand Down
9 changes: 8 additions & 1 deletion lib/new_relic/agent/configuration/default_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1466,6 +1466,13 @@ def self.notify
:description => 'Distributed tracing lets you see the path that a request takes through your distributed system. Enabling distributed tracing changes the behavior of some New Relic features, so carefully consult the [transition guide](/docs/transition-guide-distributed-tracing) before you enable this feature.'
},
# Elasticsearch
:'elasticsearch.capture_cluster_name' => {
:default => true,
:public => true,
:type => Boolean,
:allowed_from_server => true,
:description => 'If `true`, the agent captures the Elasticsearch cluster name in transaction traces.'
},
:'elasticsearch.capture_queries' => {
:default => true,
:public => true,
Expand Down Expand Up @@ -2730,7 +2737,7 @@ def self.notify
:public => true,
:type => Boolean,
:allowed_from_server => false,
:description => "If `true`, the security agent loads (the agent performs a Ruby 'require')"
:description => "If `true`, the security agent is loaded (a Ruby 'require' is performed)"
},
:'security.enabled' => {
:default => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def nr_reported_query(query)
end

def nr_cluster_name
return unless NewRelic::Agent.config[:'elasticsearch.capture_cluster_name']
return @nr_cluster_name if defined?(@nr_cluster_name)
return if nr_hosts.empty?

Expand Down
1 change: 0 additions & 1 deletion newrelic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,6 @@ common: &default_settings
# NOTE: All "security.*" configuration parameters are related only to the
# security agent, and all other configuration parameters that may
# have "security" in the name somewhere are related to the APM agent.

# If true, the security agent loads (the agent performs a Ruby 'require')
# security.agent.enabled: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ def test_cluster_name_doesnt_try_again_if_defined_but_nil
assert_nil @segment.database_name
end

def test_capture_cluster_name_config_is_false
with_config(:'elasticsearch.capture_cluster_name' => false) do
search

assert_nil @segment.database_name
end
end

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