Skip to content

Commit ed9db61

Browse files
committed
Improve observability (#834)
* API generation * Added correlation id support * Updated docs * Updated test * Updated code generation * API generation * Updated code generation * Added support for client name and custom context object * Updated docs * Updated test * Fix docs * Updated docs * Added id support also for sniffing * Updated test * Update docs/observability.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Update docs/observability.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Apply suggestions * Update docs/configuration.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Update docs/configuration.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Update docs/observability.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Update docs/observability.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Update docs/observability.asciidoc Co-Authored-By: delvedor <delvedor@users.noreply.github.com> * Apply suggestions * Updated README.md * Fixed test * Addressed suggestions
1 parent c47725d commit ed9db61

File tree

279 files changed

+18696
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+18696
-142
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ The client is designed to be easily configured as you see fit for your needs, fo
119119
nodeFilter: nodeFilterFn;
120120
// custom selection strategy, defaults `round-robin`
121121
nodeSelector: nodeSelectorFn | string;
122+
// function to generate the request id for every request
123+
generateRequestId: generateRequestIdFn;
124+
// name to identify the client instance in the events
125+
name: string;
122126
}
123127
```
124128

@@ -143,7 +147,9 @@ The supported *request specific options* are:
143147
asStream: boolean, // default `false`
144148
compression: string, // default `false`
145149
headers: object, // default `null`
146-
querystring: object // default `null`
150+
querystring: object // default `null`,
151+
context: object // default `null`,
152+
id: any // default incr. integer
147153
}
148154
```
149155

api/api/bulk.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ function buildBulk (opts) {
138138
headers: options.headers || null,
139139
querystring: options.querystring || null,
140140
compression: options.compression || false,
141+
id: options.id || null,
142+
context: options.context || null,
141143
warnings
142144
}
143145

api/api/cat.aliases.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function buildCatAliases (opts) {
120120
headers: options.headers || null,
121121
querystring: options.querystring || null,
122122
compression: options.compression || false,
123+
id: options.id || null,
124+
context: options.context || null,
123125
warnings
124126
}
125127

api/api/cat.allocation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function buildCatAllocation (opts) {
122122
headers: options.headers || null,
123123
querystring: options.querystring || null,
124124
compression: options.compression || false,
125+
id: options.id || null,
126+
context: options.context || null,
125127
warnings
126128
}
127129

api/api/cat.count.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function buildCatCount (opts) {
120120
headers: options.headers || null,
121121
querystring: options.querystring || null,
122122
compression: options.compression || false,
123+
id: options.id || null,
124+
context: options.context || null,
123125
warnings
124126
}
125127

api/api/cat.fielddata.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ function buildCatFielddata (opts) {
124124
headers: options.headers || null,
125125
querystring: options.querystring || null,
126126
compression: options.compression || false,
127+
id: options.id || null,
128+
context: options.context || null,
127129
warnings
128130
}
129131

api/api/cat.health.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ function buildCatHealth (opts) {
117117
headers: options.headers || null,
118118
querystring: options.querystring || null,
119119
compression: options.compression || false,
120+
id: options.id || null,
121+
context: options.context || null,
120122
warnings
121123
}
122124

api/api/cat.help.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ function buildCatHelp (opts) {
104104
headers: options.headers || null,
105105
querystring: options.querystring || null,
106106
compression: options.compression || false,
107+
id: options.id || null,
108+
context: options.context || null,
107109
warnings
108110
}
109111

api/api/cat.indices.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ function buildCatIndices (opts) {
126126
headers: options.headers || null,
127127
querystring: options.querystring || null,
128128
compression: options.compression || false,
129+
id: options.id || null,
130+
context: options.context || null,
129131
warnings
130132
}
131133

api/api/cat.master.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function buildCatMaster (opts) {
115115
headers: options.headers || null,
116116
querystring: options.querystring || null,
117117
compression: options.compression || false,
118+
id: options.id || null,
119+
context: options.context || null,
118120
warnings
119121
}
120122

api/api/cat.nodeattrs.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function buildCatNodeattrs (opts) {
115115
headers: options.headers || null,
116116
querystring: options.querystring || null,
117117
compression: options.compression || false,
118+
id: options.id || null,
119+
context: options.context || null,
118120
warnings
119121
}
120122

api/api/cat.nodes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ function buildCatNodes (opts) {
118118
headers: options.headers || null,
119119
querystring: options.querystring || null,
120120
compression: options.compression || false,
121+
id: options.id || null,
122+
context: options.context || null,
121123
warnings
122124
}
123125

api/api/cat.pending_tasks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function buildCatPendingTasks (opts) {
115115
headers: options.headers || null,
116116
querystring: options.querystring || null,
117117
compression: options.compression || false,
118+
id: options.id || null,
119+
context: options.context || null,
118120
warnings
119121
}
120122

api/api/cat.plugins.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function buildCatPlugins (opts) {
115115
headers: options.headers || null,
116116
querystring: options.querystring || null,
117117
compression: options.compression || false,
118+
id: options.id || null,
119+
context: options.context || null,
118120
warnings
119121
}
120122

api/api/cat.recovery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function buildCatRecovery (opts) {
120120
headers: options.headers || null,
121121
querystring: options.querystring || null,
122122
compression: options.compression || false,
123+
id: options.id || null,
124+
context: options.context || null,
123125
warnings
124126
}
125127

api/api/cat.repositories.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ function buildCatRepositories (opts) {
115115
headers: options.headers || null,
116116
querystring: options.querystring || null,
117117
compression: options.compression || false,
118+
id: options.id || null,
119+
context: options.context || null,
118120
warnings
119121
}
120122

api/api/cat.segments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ function buildCatSegments (opts) {
117117
headers: options.headers || null,
118118
querystring: options.querystring || null,
119119
compression: options.compression || false,
120+
id: options.id || null,
121+
context: options.context || null,
120122
warnings
121123
}
122124

api/api/cat.shards.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function buildCatShards (opts) {
122122
headers: options.headers || null,
123123
querystring: options.querystring || null,
124124
compression: options.compression || false,
125+
id: options.id || null,
126+
context: options.context || null,
125127
warnings
126128
}
127129

api/api/cat.snapshots.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ function buildCatSnapshots (opts) {
125125
headers: options.headers || null,
126126
querystring: options.querystring || null,
127127
compression: options.compression || false,
128+
id: options.id || null,
129+
context: options.context || null,
128130
warnings
129131
}
130132

api/api/cat.tasks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ function buildCatTasks (opts) {
123123
headers: options.headers || null,
124124
querystring: options.querystring || null,
125125
compression: options.compression || false,
126+
id: options.id || null,
127+
context: options.context || null,
126128
warnings
127129
}
128130

api/api/cat.templates.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ function buildCatTemplates (opts) {
120120
headers: options.headers || null,
121121
querystring: options.querystring || null,
122122
compression: options.compression || false,
123+
id: options.id || null,
124+
context: options.context || null,
123125
warnings
124126
}
125127

api/api/cat.thread_pool.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ function buildCatThreadPool (opts) {
122122
headers: options.headers || null,
123123
querystring: options.querystring || null,
124124
compression: options.compression || false,
125+
id: options.id || null,
126+
context: options.context || null,
125127
warnings
126128
}
127129

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
'use strict'
21+
22+
/* eslint camelcase: 0 */
23+
/* eslint no-unused-vars: 0 */
24+
25+
function buildCcrDeleteAutoFollowPattern (opts) {
26+
// eslint-disable-next-line no-unused-vars
27+
const { makeRequest, ConfigurationError, handleError } = opts
28+
/**
29+
* Perform a [ccr.delete_auto_follow_pattern](https://www.elastic.co/guide/en/elasticsearch/reference/current/ccr-delete-auto-follow-pattern.html) request
30+
*
31+
* @param {string} name - The name of the auto follow pattern.
32+
*/
33+
34+
const acceptedQuerystring = [
35+
36+
]
37+
38+
const snakeCase = {
39+
40+
}
41+
42+
return function ccrDeleteAutoFollowPattern (params, options, callback) {
43+
options = options || {}
44+
if (typeof options === 'function') {
45+
callback = options
46+
options = {}
47+
}
48+
if (typeof params === 'function' || params == null) {
49+
callback = params
50+
params = {}
51+
options = {}
52+
}
53+
54+
// check required parameters
55+
if (params['name'] == null) {
56+
const err = new ConfigurationError('Missing required parameter: name')
57+
return handleError(err, callback)
58+
}
59+
60+
// validate headers object
61+
if (options.headers != null && typeof options.headers !== 'object') {
62+
const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`)
63+
return handleError(err, callback)
64+
}
65+
66+
var warnings = null
67+
var { method, body, name } = params
68+
var querystring = semicopy(params, ['method', 'body', 'name'])
69+
70+
if (method == null) {
71+
method = 'DELETE'
72+
}
73+
74+
var ignore = options.ignore || null
75+
if (typeof ignore === 'number') {
76+
ignore = [ignore]
77+
}
78+
79+
var path = ''
80+
81+
path = '/' + '_ccr' + '/' + 'auto_follow' + '/' + encodeURIComponent(name)
82+
83+
// build request object
84+
const request = {
85+
method,
86+
path,
87+
body: body || '',
88+
querystring
89+
}
90+
91+
const requestOptions = {
92+
ignore,
93+
requestTimeout: options.requestTimeout || null,
94+
maxRetries: options.maxRetries || null,
95+
asStream: options.asStream || false,
96+
headers: options.headers || null,
97+
querystring: options.querystring || null,
98+
compression: options.compression || false,
99+
id: options.id || null,
100+
context: options.context || null,
101+
warnings
102+
}
103+
104+
return makeRequest(request, requestOptions, callback)
105+
106+
function semicopy (obj, exclude) {
107+
var target = {}
108+
var keys = Object.keys(obj)
109+
for (var i = 0, len = keys.length; i < len; i++) {
110+
var key = keys[i]
111+
if (exclude.indexOf(key) === -1) {
112+
target[snakeCase[key] || key] = obj[key]
113+
if (acceptedQuerystring.indexOf(snakeCase[key] || key) === -1) {
114+
warnings = warnings || []
115+
warnings.push('Client - Unknown parameter: "' + key + '", sending it as query parameter')
116+
}
117+
}
118+
}
119+
return target
120+
}
121+
}
122+
}
123+
124+
module.exports = buildCcrDeleteAutoFollowPattern

0 commit comments

Comments
 (0)