Skip to content

Commit db8af33

Browse files
committed
[DOCS] Add X-Opaque-Id info to transport README
1 parent eae213d commit db8af33

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

elasticsearch-transport/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ Full documentation is available at <http://rubydoc.info/gems/elasticsearch-trans
6969

7070
## Configuration
7171

72+
* [Setting Hosts](#setting-hosts)
73+
* [Default port](#default-port)
74+
* [Connect using an Elastic Cloud ID](#connect-using-an-elastic-cloud-id)
75+
* [Authentication](#authentication)
76+
* [Logging](#logging)
77+
* [Identifying running tasks with X-Opaque-Id](#identifying-running-tasks-with-x-opaque-id)
78+
* [Setting Timeouts](#setting-timeouts)
79+
* [Randomizing Hosts](#randomizing-hosts)
80+
* [Retrying on Failures](#retrying-on-failures)
81+
* [Reloading Hosts](#reloading-hosts)
82+
* [Connection Selector](#connection-selector)
83+
* [Transport Implementations](#transport-implementations)
84+
* [Serializer implementations](#serializer-implementations)
85+
* [Exception Handling](#exception-handling)
86+
* [Development and Community](#development-and-community)
87+
7288
The client supports many configurations options for setting up and managing connections,
7389
configuring logging, customizing the transport library, etc.
7490

@@ -178,6 +194,33 @@ You can pass the client any conforming logger implementation:
178194

179195
client = Elasticsearch::Client.new logger: log
180196

197+
### Identifying running tasks with X-Opaque-Id
198+
199+
The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them ([more on the Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks)). To use this feature, you need to set an id for `opaque_id` on the client before each request. Example:
200+
201+
```ruby
202+
client = Elasticsearch::Client.new
203+
client.opaque_id = '123456'
204+
client.search(index: 'myindex', q: 'title:test')
205+
```
206+
The search request will include the following HTTP Header:
207+
```
208+
X-Opaque-Id: 123456
209+
```
210+
211+
Please note that `opaque_id` will be set to nil after every request, so you need to set it on the client for every individual request.
212+
213+
You can also set a prefix for X-Opaque-Id when initializing the client. This will be prepended to the id you set before each request if you're using X-Opaque-Id. Example:
214+
```ruby
215+
client = Elasticsearch::Client.new(opaque_id_prefix: 'eu-west1')
216+
client.opaque_id = '123456'
217+
client.search(index: 'myindex', q: 'title:test')
218+
```
219+
The request will include the following HTTP Header:
220+
```
221+
X-Opaque-Id: eu-west1_123456
222+
```
223+
181224
### Setting Timeouts
182225

183226
For many operations in Elasticsearch, the default timeouts of HTTP libraries are too low.

0 commit comments

Comments
 (0)