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 8.0 support #1985

Merged
merged 8 commits into from
May 13, 2022
Merged

Elasticsearch 8.0 support #1985

merged 8 commits into from
May 13, 2022

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Apr 22, 2022

Fixes #1950

Elasticsearch (from now on referred to as ES) has a new server and library version v8.0.0, with many changes and some breaking ones: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/release_notes_80.html

Not a lot changes on the ddtrace side: the core logic stays the same. But a few noteworthy changes took place:

  1. Our instrumentation target gem is the transport component of ES. This components lives in its own "transport" gem, not the top-level gem, elasticsearch. This has always been the case.
    For v8, the transport gem has been renamed from elasticsearch-transport to elastic-transport, alongside with a namespace change from Elasticsearch::Transport to Elastic::Transport.
  2. elastic-transport depends on faraday ~> 1 in v8. Before it used to depend on faraday >= 0. Because ES is part of our Appraisal contrib gem set, this dependency conflicts with the presto-client dependency on faraday ~> 0.12.
    As it turns out, the Presto client we support has been renamed in newer version and this presto-client is actually a bit old. Because of this, I've moved presto-client to the contrib-old Appraisal group, alongside 'elasticsearch', '< 8.0.0'. They both live happily there with their good old friend 'faraday', '0.17'.
    contrib now uses faraday >= 1.
    Things are a bit more complicated with super old rubies that don't support ES v8: in their case everything just stays in contrib (their contrib is "naturally" old 🤷).
  3. The ES container image had to be updated, as the v8 gem does not like super old ES servers.

@marcotc marcotc added the do-not-merge/WIP Not ready for merge label Apr 22, 2022
@marcotc marcotc self-assigned this Apr 22, 2022
@marcotc marcotc force-pushed the new-elastic branch 3 times, most recently from 7b00f6c to cdf1379 Compare April 27, 2022 18:08
@codecov-commenter
Copy link

codecov-commenter commented May 6, 2022

Codecov Report

Merging #1985 (8747cec) into master (7367ecf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff            @@
##           master    #1985    +/-   ##
========================================
  Coverage   97.45%   97.45%            
========================================
  Files        1016     1019     +3     
  Lines       51476    51649   +173     
========================================
+ Hits        50164    50336   +172     
- Misses       1312     1313     +1     
Impacted Files Coverage Δ
lib/datadog/core/configuration/settings.rb 100.00% <100.00%> (ø)
lib/datadog/core/environment/variable_helpers.rb 100.00% <100.00%> (ø)
lib/datadog/kit/enable_core_dumps.rb 100.00% <100.00%> (ø)
...tadog/tracing/contrib/elasticsearch/integration.rb 100.00% <100.00%> (ø)
...b/datadog/tracing/contrib/elasticsearch/patcher.rb 98.63% <100.00%> (+0.19%) ⬆️
.../datadog/core/environment/variable_helpers_spec.rb 100.00% <100.00%> (ø)
spec/datadog/kit/enable_core_dumps_spec.rb 100.00% <100.00%> (ø)
.../tracing/contrib/elasticsearch/integration_spec.rb 100.00% <100.00%> (ø)
...adog/tracing/contrib/elasticsearch/patcher_spec.rb 100.00% <100.00%> (ø)
lib/datadog/core/diagnostics/environment_logger.rb 98.41% <0.00%> (-1.59%) ⬇️
... and 6 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@@ -0,0 +1,16 @@
RSpec.shared_context 'Elasticsearch client' do
Copy link
Member Author

@marcotc marcotc May 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper is simply extracting behaviour from spec/datadog/tracing/contrib/elasticsearch/patcher_spec.rb into its own helper file. This is not new code.

@@ -22,7 +22,7 @@ task :install_appraisal_gemfiles do |_task, args|
versions = tracer_version_arg.empty? ? TRACER_VERSIONS : tracer_version_arg

versions.each do |version|
sh "docker-compose run -e APPRAISAL_GROUP --rm tracer-#{version} /bin/bash -c " \
sh "docker-compose run -e APPRAISAL_GROUP --rm tracer-#{version} --no-deps /bin/bash -c " \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures we don't start the whole docker-compose stack just to run bundle.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh I totally did not know there was a shortcut for this. Nice! 👌

@marcotc marcotc removed the do-not-merge/WIP Not ready for merge label May 10, 2022
@marcotc marcotc marked this pull request as ready for review May 10, 2022 22:55
@marcotc marcotc requested a review from a team May 10, 2022 22:55
@marcotc marcotc added the integrations Involves tracing integrations label May 10, 2022
@marcotc marcotc changed the title WIP Elastic search 8.0 support Elasticsearch 8.0 support May 10, 2022
@ivoanjo
Copy link
Member

ivoanjo commented May 12, 2022

(Extra note for reference -- issue #1988 is where we're tracking support for trino-client)

Copy link
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Rakefile Outdated Show resolved Hide resolved
Comment on lines +43 to +46
# DEV-2.0: Remove this access, as `Client#self` in this context is not exposed to the user
# since `elasticsearch` v8.0.0. In contrast, `Client#transport` is always available across
# all `elasticsearch` gem versions and should be used instead.
service = Datadog.configuration_for(self, :service_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest adding a deprecation warning if we find configuration attached to self? That way we can start moving any customers off of it right away, rather than them needing to wait until 2.0 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, added!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor minor: I wonder if we should reference/point to https://github.com/DataDog/dd-trace-rb/blob/master/docs/Deprecation.md in the deprecation message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of having an explicit Datadog.logger.deprecation_warning (or Datadog::Core.deprecation_warning, not sure exactly where), so we have consistent messaging around these messages.
I think linking to the deprecation doc you mentioned is a good idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ I really like the idea of a shared deprecation helper -- we get a more consistent experience rather than every warning being a slightly different variant which may or may not include all the info we need.

spec/datadog/tracing/contrib/elasticsearch/patcher_spec.rb Outdated Show resolved Hide resolved
@marcotc
Copy link
Member Author

marcotc commented May 13, 2022

Fixed all comments, 🔀ing now.

@marcotc marcotc merged commit 08c823e into master May 13, 2022
@marcotc marcotc deleted the new-elastic branch May 13, 2022 23:43
@github-actions github-actions bot added this to the 1.1.0 milestone May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrations Involves tracing integrations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Elasticsearch integration is not compatible with the latest elastic-transport gem
3 participants