-
Notifications
You must be signed in to change notification settings - Fork 610
[OTel instrumentation] Add path params and endpoint in opts to perform_request #2179
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
Merged
Merged
Changes from all commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
d119abd
Add request opts to perform_request method args
estolfo 8b0c185
Update method template to handle create endpoint forwarding to index
estolfo d11af8b
Add unit test for perform request args
estolfo 11f02e5
Update elasticsearch unit tests for additional perform_request arg
estolfo a63af83
Update cat specs
estolfo d7f1d5b
Update cluster specs
estolfo b25a90c
Update dangling_indices specs
estolfo 7776328
Update data_frame specs
estolfo 670e566
Update features specs
estolfo 782dfb9
Update fleet specs
estolfo 8a01b4d
Update index_lifecycle_management specs
estolfo 25c7f86
Update indices specs
estolfo 09e40f5
Update ingest specs
estolfo 1599f1b
Update machine_learning specs
estolfo 4d2e368
Update migration specs
estolfo 94da052
Update info specs
estolfo aea3f4e
Update query_ruleset specs
estolfo b411561
Update search_application specs
estolfo 69ee0e1
Update searchable_snapshots specs
estolfo f54f98e
Update security specs
estolfo ef5c561
Update shutdown specs
estolfo bb04fc6
Update snapshot specs
estolfo 03fb742
Update sql specs
estolfo cf13de2
Update tasks specs
estolfo 6c4d8d1
Delete synonyms specs
estolfo 2eccb7c
Update transform specs
estolfo a9d16de
Update watcher specs
estolfo eb2afa5
Update top-level specs
estolfo 56f642e
Update remaining node specs
estolfo d6bb5f7
Generate code using new template with additional perform_request arg
estolfo 1133858
Add docs for native open telemetry instrumentation
estolfo 20207a9
Change image extension
estolfo 33ea7d7
Add valid options to capture search query option
estolfo bb7b612
Minor docs updates
estolfo 938b196
Remove special handling for create and just use index endpoint
estolfo e7b0edd
Remove opts from args when calling perform_request directly
estolfo 2633e80
Transport object is the http adapter so expected args don't change
estolfo 06f85d2
Only remove the last arg if it has an endpoint key
estolfo b05036a
Temporarily disable unit tests
estolfo d994178
download artifacts for unit tests
estolfo 28cbc84
endpoint for creating a doc is index
estolfo 19676df
download_artifacts rake task is in root
estolfo 527a74c
Further updates to create document spec
estolfo e6e9e59
Document client option opentelemetry_tracer_provider
estolfo 10aafe6
Put OpenTelemetry::TracerProvider in quotes
estolfo 77e2dd2
Inline documentation
estolfo 66707fa
Require >= 8.3 of elastic-transport
estolfo 55c8651
Add example of providing tracer provider to Client#new in the docs
estolfo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[[opentelemetry]] | ||
=== Using OpenTelemetry | ||
|
||
You can use https://opentelemetry.io/[OpenTelemetry] to monitor the performance and behavior of your {es} requests through the Ruby Client. | ||
The Ruby Client comes with built-in OpenTelemetry instrumentation that emits https://www.elastic.co/guide/en/apm/guide/current/apm-distributed-tracing.html[distributed tracing spans] by default. | ||
With that, applications https://opentelemetry.io/docs/instrumentation/ruby/manual/[instrumented with OpenTelemetry] or using the https://opentelemetry.io/docs/instrumentation/ruby/automatic/[OpenTelemetry Ruby SDK] are inherently enriched with additional spans that contain insightful information about the execution of the {es} requests. | ||
|
||
The native instrumentation in the Ruby Client follows the https://opentelemetry.io/docs/specs/semconv/database/elasticsearch/[OpenTelemetry Semantic Conventions for {es}]. In particular, the instrumentation in the client covers the logical layer of {es} requests. A single span per request is created that is processed by the service through the Ruby Client. The following image shows a trace that records the handling of two different {es} requests: a `ping` request and a `search` request. | ||
|
||
[role="screenshot"] | ||
image::images/otel-waterfall-without-http.png[alt="Distributed trace with Elasticsearch spans",align="center"] | ||
|
||
Usually, OpenTelemetry auto-instrumentation modules come with instrumentation support for HTTP-level communication. In this case, in addition to the logical {es} client requests, spans will be captured for the physical HTTP requests emitted by the client. The following image shows a trace with both, {es} spans (in blue) and the corresponding HTTP-level spans (in red): | ||
|
||
[role="screenshot"] | ||
image::images/otel-waterfall-with-http.png[alt="Distributed trace with Elasticsearch spans",align="center"] | ||
|
||
Advanced Ruby Client behavior such as nodes round-robin and request retries are revealed through the combination of logical {es} spans and the physical HTTP spans. The following example shows a `search` request in a scenario with two nodes: | ||
|
||
[role="screenshot"] | ||
image::images/otel-waterfall-retry.png[alt="Distributed trace with Elasticsearch spans",align="center"] | ||
|
||
The first node is unavailable and results in an HTTP error, while the retry to the second node succeeds. Both HTTP requests are subsumed by the logical {es} request span (in blue). | ||
|
||
[discrete] | ||
==== Setup the OpenTelemetry instrumentation | ||
estolfo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
When using the https://opentelemetry.io/docs/instrumentation/ruby/manual[OpenTelemetry Ruby SDK manually] or using the https://opentelemetry.io/docs/instrumentation/ruby/automatic/[OpenTelemetry Ruby Auto-Instrumentations], the Ruby Client's OpenTelemetry instrumentation is enabled by default and uses the global OpenTelemetry SDK with the global tracer provider. You can provide a tracer provider via the Ruby Client configuration option `opentelemetry_tracer_provider` when instantiating the client. This is sometimes useful for testing or other specific use cases. | ||
|
||
[source,ruby] | ||
------------------------------------ | ||
client = Elasticsearch::Client.new( | ||
cloud_id: '<CloudID>', | ||
api_key: '<ApiKey>', | ||
opentelemetry_tracer_provider: tracer_provider | ||
) | ||
------------------------------------ | ||
|
||
[discrete] | ||
==== Configuring the OpenTelemetry instrumentation | ||
|
||
You can configure the OpenTelemetry instrumentation through Environment Variables. | ||
The following configuration options are available. | ||
|
||
[discrete] | ||
[[opentelemetry-config-enable]] | ||
===== Enable / Disable the OpenTelemetry instrumentation | ||
|
||
With this configuration option you can enable (default) or disable the built-in OpenTelemetry instrumentation. | ||
|
||
**Default:** `true` | ||
|
||
|============ | ||
| Environment Variable | `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_ENABLED` | ||
|============ | ||
|
||
[discrete] | ||
===== Capture search request bodies | ||
|
||
Per default, the built-in OpenTelemetry instrumentation does not capture request bodies due to data privacy considerations. You can use this option to enable capturing of search queries from the request bodies of {es} search requests in case you wish to gather this information regardless. The options are to capture the raw search query, sanitize the query with a default list of sensitive keys, or not capture it at all. | ||
|
||
**Default:** `omit` | ||
|
||
**Valid Options:** `omit`, `sanitize`, `raw` | ||
|
||
|============ | ||
| Environment Variable | `OTEL_INSTRUMENTATION_ELASTICSEARCH_CAPTURE_SEARCH_QUERY` | ||
|============ | ||
|
||
[discrete] | ||
===== Sanitize the {es} search request body | ||
|
||
You can configure the list of keys whose values are redacted when the search query is captured. Values must be comma-separated. | ||
|
||
**Default:** `nil` | ||
|
||
|============ | ||
| Environment Variable | `OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_SEARCH_QUERY_SANITIZE_KEYS` | ||
|============ | ||
|
||
Example: | ||
|
||
```bash | ||
OTEL_RUBY_INSTRUMENTATION_ELASTICSEARCH_SEARCH_QUERY_SANITIZE_KEYS='sensitive-key,other-sensitive-key' | ||
``` | ||
|
||
[discrete] | ||
==== Overhead | ||
estolfo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The OpenTelemetry instrumentation (as any other monitoring approach) may come with a slight overhead on CPU, memory, and/or latency. The overhead may only occur when the instrumentation is enabled (default) and an OpenTelemetry SDK is active in the target application. When the instrumentation is disabled or no OpenTelemetry SDK is active within the target application, monitoring overhead is not expected when using the client. | ||
|
||
Even in cases where the instrumentation is enabled and is actively used (by an OpenTelemetry SDK), the overhead is minimal and negligible in the vast majority of cases. In edge cases where there is a noticeable overhead, the <<opentelemetry-config-enable,instrumentation can be explicitly disabled>> to eliminate any potential impact on performance. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.