Skip to content

Commit 82f273d

Browse files
authored
Merge branch 'main' into codegen
2 parents c70d33d + bb6e24b commit 82f273d

File tree

13 files changed

+1245
-278
lines changed

13 files changed

+1245
-278
lines changed

.github/workflows/nodejs.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
name: Test
2727
runs-on: ${{ matrix.os }}
2828
needs: paths-filter
29-
# only run if code relevant to unit tests was changed
30-
if: needs.paths-filter.outputs.src-only == 'true'
29+
env:
30+
CODE_CHANGED: ${{ needs.paths-filter.outputs.src-only }}
3131

3232
strategy:
3333
fail-fast: false
@@ -50,16 +50,19 @@ jobs:
5050
npm install
5151
5252
- name: Lint
53+
shell: bash
5354
run: |
54-
npm run lint
55+
[ "$CODE_CHANGED" = "true" ] && npm run lint || exit 0
5556
5657
- name: Unit test
58+
shell: bash
5759
run: |
58-
npm run test:unit
60+
[ "$CODE_CHANGED" = "true" ] && npm run test:unit || exit 0
5961
6062
- name: ECMAScript module test
63+
shell: bash
6164
run: |
62-
npm run test:esm
65+
[ "$CODE_CHANGED" = "true" ] && npm run test:esm || exit 0
6366
6467
license:
6568
name: License check
@@ -90,8 +93,8 @@ jobs:
9093
name: Test Bun
9194
runs-on: ${{ matrix.os }}
9295
needs: paths-filter
93-
# only run if code relevant to unit tests was changed
94-
if: needs.paths-filter.outputs.src-only == 'true'
96+
env:
97+
CODE_CHANGED: ${{ needs.paths-filter.outputs.src-only }}
9598

9699
strategy:
97100
fail-fast: false
@@ -111,13 +114,16 @@ jobs:
111114
bun install
112115
113116
- name: Lint
117+
shell: bash
114118
run: |
115-
bun run lint
119+
[ "$CODE_CHANGED" = "true" ] && bun run lint || exit 0
116120
117121
- name: Unit test
122+
shell: bash
118123
run: |
119-
bun run test:unit-bun
124+
[ "$CODE_CHANGED" = "true" ] && bun run test:unit-bun || exit 0
120125
121126
- name: ECMAScript module test
127+
shell: bash
122128
run: |
123-
bun run test:esm
129+
[ "$CODE_CHANGED" = "true" ] && bun run test:esm || exit 0

docs/docset.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ exclude:
66
cross_links:
77
- docs-content
88
- elasticsearch
9+
- elastic-otel-node
910
toc:
1011
- toc: reference
1112
- toc: release-notes

docs/reference/api-reference.md

Lines changed: 153 additions & 87 deletions
Large diffs are not rendered by default.

docs/reference/observability.md

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,21 @@ mapped_pages:
55

66
# Observability [observability]
77

8-
To observe and measure {{es}} client usage, several client features are provided.
8+
Several client features help you observe and measure {{es}} client usage. As of version 8.15.0, the JavaScript client provides native support for OpenTelemetry. You can send client usage data to OpenTelemetry endpoints without making changes to your JavaScript codebase.
99

10-
First, as of 8.15.0, the client provides native support for OpenTelemetry, which allows you to send client usage data to any endpoint that supports OpenTelemetry without having to make any changes to your JavaScript codebase.
11-
12-
Also, rather than providing a default logger, the client offers an event emitter interface to hook into internal events, such as `request` and `response`, allowing you to log the events you care about, or otherwise react to client usage however you might need.
13-
14-
Correlating events can be hard, especially if your applications have a large codebase with many events happening at the same time. To help you with this, the client provides a correlation ID system, and other features.
15-
16-
All of these observability features are documented below.
10+
Rather than providing a default logger, the client offers an event emitter interface to hook into internal events like `request` and `response`. This allows you to log significant events or otherwise react to client usage. Because correlating events can be complex, the client provides a correlation ID system and other features.
1711

1812
## OpenTelemetry [_opentelemetry]
1913

2014
The client supports OpenTelemetry’s [zero-code instrumentation](https://opentelemetry.io/docs/zero-code/js/) to enable tracking each client request as an [OpenTelemetry span](https://opentelemetry.io/docs/concepts/signals/traces/#spans). These spans follow all of the [semantic OpenTelemetry conventions for {{es}}](https://opentelemetry.io/docs/specs/semconv/database/elasticsearch/) except for `db.query.text`.
2115

22-
To start sending {{es}} trace data to your OpenTelemetry endpoint, follow [OpenTelemetry’s zero-code instrumentation guide](https://opentelemetry.io/docs/zero-code/js/), or the following steps:
23-
24-
1. Install `@opentelemetry/api` and `@opentelemetry/auto-instrumentations-node` as Node.js dependencies
25-
2. Export the following environment variables with the appropriate values:
26-
27-
* `OTEL_EXPORTER_OTLP_ENDPOINT`
28-
* `OTEL_EXPORTER_OTLP_HEADERS`
29-
* `OTEL_RESOURCE_ATTRIBUTES`
30-
* `OTEL_SERVICE_NAME`
31-
32-
3. `require` the Node.js auto-instrumentation library at startup:
33-
34-
```
35-
node --require '@opentelemetry/auto-instrumentations-node/register' index.js
36-
```
16+
To start sending {{es}} trace data to your OpenTelemetry endpoint, instrument the client using the [Elastic Distribution of OpenTelemetry (EDOT) JavaScript](elastic-otel-node://reference/edot-node/index.md), or follow [OpenTelemetry’s zero-code instrumentation guide](https://opentelemetry.io/docs/zero-code/js/).
3717

38-
### Disabling OpenTelemetry collection [disable-otel]
18+
### Turn off OpenTelemetry collection [disable-otel]
3919

40-
As of `@elastic/transport` version 9.1.0—or 8.10.0 when using `@elastic/elasticsearch` 8.x—OpenTelemetry tracing can be disabled in multiple ways.
20+
As of `@elastic/transport` version 9.1.0—or 8.10.0 when using `@elastic/elasticsearch` 8.x—you can turn off OpenTelemetry tracing in several ways.
4121

42-
To entirely disable OpenTelemetry collection, you can provide a custom `Transport` at client instantiation time that sets `openTelemetry.enabled` to `false`:
22+
To entirely turn off OpenTelemetry collection, you can provide a custom `Transport` at client instantiation time that sets `openTelemetry.enabled` to `false`:
4323

4424
```typescript
4525
import { Transport } from '@elastic/transport'
@@ -58,11 +38,11 @@ const client = new Client({
5838
})
5939
```
6040

61-
Alternatively, you can also export an environment variable `OTEL_ELASTICSEARCH_ENABLED=false` to achieve the same effect.
41+
Alternatively, you can export the environment variable `OTEL_ELASTICSEARCH_ENABLED=false`.
6242

63-
If you would not like OpenTelemetry to be disabled entirely, but would like the client to suppress tracing, you can use the option `openTelemetry.suppressInternalInstrumentation = true` instead.
43+
To suppress tracing without turning off all OpenTelemetry collection, use the option `openTelemetry.suppressInternalInstrumentation = true` instead.
6444

65-
If you would like to keep either option enabled by default, but want to disable them for a single API call, you can pass `Transport` options as a second argument to any API function call:
45+
If you would like to keep either option enabled by default, but want to turn them off for a single API call, pass `Transport` options as a second argument to any API function call:
6646

6747
```typescript
6848
const response = await client.search({ ... }, {

docs/release-notes/index.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ To check for security updates, go to [Security announcements for the Elastic sta
2020
% ### Fixes [elasticsearch-javascript-client-next-fixes]
2121
% \*
2222

23-
## 9.1.1
23+
## 9.2.0 [elasticsearch-javascript-client-9.2.0-release-notes]
24+
25+
### Features and enhancements [elasticsearch-javascript-client-9.2.0-features-enhancements]
26+
27+
- **Compatibility with Elasticsearch 9.2:** All changes and additions to Elasticsearch APIs for its 9.2 release are reflected in this release.
28+
29+
- **Accepted parameter names added to transport request metadata:** All requests sent through `@elastic/transport` already included some metadata about the request (API name, path parameters). An `acceptedParams` array has been added that includes the names of all parameters that an API supports. This helps support more flexible pre-flight request modifications made by custom transports.
30+
31+
## 9.1.1 [elasticsearch-javascript-client-9.1.1-release-notes]
2432

2533
### Fixes [elasticsearch-javascript-client-9.1.1-fixes]
2634

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@elastic/elasticsearch",
3-
"version": "9.1.0",
4-
"versionCanary": "9.1.0-canary.0",
3+
"version": "9.2.0",
4+
"versionCanary": "9.2.0-canary.0",
55
"description": "The official Elasticsearch client for Node.js",
66
"main": "./index.js",
77
"types": "index.d.ts",
@@ -80,10 +80,10 @@
8080
"ora": "5.4.1",
8181
"proxy": "2.2.0",
8282
"rimraf": "6.0.1",
83-
"semver": "7.7.2",
83+
"semver": "7.7.3",
8484
"split2": "4.2.0",
8585
"stoppable": "1.1.0",
86-
"tap": "21.1.0",
86+
"tap": "21.1.3",
8787
"ts-node": "10.9.2",
8888
"ts-standard": "12.0.2",
8989
"typescript": "5.9.2",

src/api/api/cat.ts

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ export default class Cat {
5858
'master_timeout'
5959
]
6060
},
61+
'cat.circuit_breaker': {
62+
path: [
63+
'circuit_breaker_patterns'
64+
],
65+
body: [],
66+
query: []
67+
},
6168
'cat.component_templates': {
6269
path: [
6370
'name'
@@ -251,7 +258,12 @@ export default class Cat {
251258
'h',
252259
's',
253260
'local',
254-
'master_timeout'
261+
'master_timeout',
262+
'expand_wildcards',
263+
'allow_no_indices',
264+
'ignore_throttled',
265+
'ignore_unavailable',
266+
'allow_closed'
255267
]
256268
},
257269
'cat.shards': {
@@ -451,6 +463,61 @@ export default class Cat {
451463
return await this.transport.request({ path, method, querystring, body, meta }, options)
452464
}
453465

466+
/**
467+
* Get circuit breakers statistics
468+
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch#TODO | Elasticsearch API documentation}
469+
*/
470+
async circuitBreaker (this: That, params?: T.TODO, options?: TransportRequestOptionsWithOutMeta): Promise<T.TODO>
471+
async circuitBreaker (this: That, params?: T.TODO, options?: TransportRequestOptionsWithMeta): Promise<TransportResult<T.TODO, unknown>>
472+
async circuitBreaker (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<T.TODO>
473+
async circuitBreaker (this: That, params?: T.TODO, options?: TransportRequestOptions): Promise<any> {
474+
const {
475+
path: acceptedPath
476+
} = this[kAcceptedParams]['cat.circuit_breaker']
477+
478+
const userQuery = params?.querystring
479+
const querystring: Record<string, any> = userQuery != null ? { ...userQuery } : {}
480+
481+
let body: Record<string, any> | string | undefined
482+
const userBody = params?.body
483+
if (userBody != null) {
484+
if (typeof userBody === 'string') {
485+
body = userBody
486+
} else {
487+
body = { ...userBody }
488+
}
489+
}
490+
491+
params = params ?? {}
492+
for (const key in params) {
493+
if (acceptedPath.includes(key)) {
494+
continue
495+
} else if (key !== 'body' && key !== 'querystring') {
496+
querystring[key] = params[key]
497+
}
498+
}
499+
500+
let method = ''
501+
let path = ''
502+
if (params.circuit_breaker_patterns != null) {
503+
method = 'GET'
504+
path = `/_cat/circuit_breaker/${encodeURIComponent(params.circuit_breaker_patterns.toString())}`
505+
} else {
506+
method = 'GET'
507+
path = '/_cat/circuit_breaker'
508+
}
509+
const meta: TransportRequestMetadata = {
510+
name: 'cat.circuit_breaker',
511+
pathParts: {
512+
circuit_breaker_patterns: params.circuit_breaker_patterns
513+
},
514+
acceptedParams: [
515+
'circuit_breaker_patterns'
516+
]
517+
}
518+
return await this.transport.request({ path, method, querystring, body, meta }, options)
519+
}
520+
454521
/**
455522
* Get component templates. Get information about component templates in a cluster. Component templates are building blocks for constructing index templates that specify index mappings, settings, and aliases. IMPORTANT: CAT APIs are only intended for human consumption using the command line or Kibana console. They are not intended for use by applications. For application consumption, use the get component template API.
456523
* @see {@link https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cat-component-templates | Elasticsearch API documentation}
@@ -1434,7 +1501,12 @@ export default class Cat {
14341501
'h',
14351502
's',
14361503
'local',
1437-
'master_timeout'
1504+
'master_timeout',
1505+
'expand_wildcards',
1506+
'allow_no_indices',
1507+
'ignore_throttled',
1508+
'ignore_unavailable',
1509+
'allow_closed'
14381510
]
14391511
}
14401512
return await this.transport.request({ path, method, querystring, body, meta }, options)

0 commit comments

Comments
 (0)