@sebspark/opentelemetry-instrumentation-opensearch 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -9
- package/dist/index.d.mts +5 -37
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +112 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -78,13 +78,76 @@ new OpenSearchInstrumentation({ suppressInternalInstrumentation: true })
|
|
|
78
78
|
|
|
79
79
|
## Produced spans
|
|
80
80
|
|
|
81
|
-
| Attribute | Example | Notes |
|
|
82
|
-
|---|---|---|
|
|
83
|
-
| `db.system.name` | `opensearch` | Always set |
|
|
84
|
-
| `db.operation.name` | `search` | Parsed from path (`_search` → `search`) |
|
|
85
|
-
| `db.opensearch.index` | `asset_v0.1.3` | Omitted for cluster-level operations like `bulk` |
|
|
86
|
-
| `db.query.text` | `{"query":{"match_all":{}}}` | Omitted when `dbStatementSerializer: false` |
|
|
87
|
-
| `server.address` | `localhost` | Set from the connection used for the request |
|
|
88
|
-
| `server.port` | `9200` | Omitted when using the default port for the protocol |
|
|
89
|
-
|
|
90
81
|
Span name follows the pattern `<operation> <index>` (e.g. `search asset_v0.1.3`) or just `<operation>` for index-less operations like `bulk`. Falls back to the raw path when the path does not contain an underscore-prefixed operation segment.
|
|
82
|
+
|
|
83
|
+
### Request attributes
|
|
84
|
+
|
|
85
|
+
Set at span creation, before the request is sent.
|
|
86
|
+
|
|
87
|
+
| Attribute | Type | Example | Notes |
|
|
88
|
+
|---|---|---|---|
|
|
89
|
+
| `db.system.name` | string | `opensearch` | Always set |
|
|
90
|
+
| `db.operation.name` | string | `search` | Parsed from path (`_search` → `search`). Omitted when path has no operation segment |
|
|
91
|
+
| `db.opensearch.index` | string | `asset_v0.1.3` | Omitted for cluster-level operations like `_bulk` |
|
|
92
|
+
| `db.query.text` | string | `{"query":{"match_all":{}}}` | The serialized request body. Omitted for bodyless requests or when `dbStatementSerializer: false` |
|
|
93
|
+
|
|
94
|
+
### Response attributes
|
|
95
|
+
|
|
96
|
+
Set on the span after a successful response.
|
|
97
|
+
|
|
98
|
+
#### Always present on search responses
|
|
99
|
+
|
|
100
|
+
| Attribute | Type | Example | Description |
|
|
101
|
+
|---|---|---|---|
|
|
102
|
+
| `server.address` | string | `opensearch.example.com` | Hostname of the node that handled the request |
|
|
103
|
+
| `server.port` | number | `9200` | Omitted when using the default port for the protocol |
|
|
104
|
+
| `http.response.status_code` | number | `200` | HTTP status code of the response |
|
|
105
|
+
| `db.opensearch.took` | number | `5` | Time in milliseconds OpenSearch spent executing the request |
|
|
106
|
+
| `db.opensearch.timed_out` | boolean | `false` | Whether the request hit the `timeout` threshold |
|
|
107
|
+
| `db.opensearch.shards.total` | number | `5` | Total number of shards the request was executed against |
|
|
108
|
+
| `db.opensearch.shards.successful` | number | `5` | Number of shards that responded successfully |
|
|
109
|
+
| `db.opensearch.shards.failed` | number | `0` | Number of shards that failed |
|
|
110
|
+
| `db.opensearch.hits.total` | number | `42` | Total number of matching documents |
|
|
111
|
+
|
|
112
|
+
#### Conditionally present
|
|
113
|
+
|
|
114
|
+
These attributes only appear when specific conditions are met, either because OpenSearch omits them by default or because they require the query to opt in.
|
|
115
|
+
|
|
116
|
+
| Attribute | Type | Condition | When to use |
|
|
117
|
+
|---|---|---|---|
|
|
118
|
+
| `db.opensearch.shards.skipped` | number | Present when OpenSearch skips shards, e.g. when using `_routing` or shard-level filtering | Useful for verifying that routing is working as intended — a high skipped count means fewer shards are doing work |
|
|
119
|
+
| `db.opensearch.terminated_early` | boolean | Present when the query includes `terminate_after: N` in the request body | Use `terminate_after` when you want to cap result collection for performance reasons (e.g. existence checks). The attribute tells you whether the cap was actually hit |
|
|
120
|
+
| `db.opensearch.phase_took.*` | number | Present when the request uses `search_type: 'dfs_query_then_fetch'` | Use DFS search type when accurate relevance scoring across shards matters (e.g. small indices or cross-shard ranking). The phase breakdown lets you identify which phase dominates latency |
|
|
121
|
+
|
|
122
|
+
To enable `phase_took`, set `search_type` on the request:
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
client.search({
|
|
126
|
+
index: 'my_index',
|
|
127
|
+
search_type: 'dfs_query_then_fetch',
|
|
128
|
+
body: { query: { ... } },
|
|
129
|
+
})
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
To enable `terminated_early`, set `terminate_after` in the query body:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
client.search({
|
|
136
|
+
index: 'my_index',
|
|
137
|
+
body: {
|
|
138
|
+
terminate_after: 1000,
|
|
139
|
+
query: { ... },
|
|
140
|
+
},
|
|
141
|
+
})
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
#### `db.opensearch.phase_took.*` fields
|
|
145
|
+
|
|
146
|
+
| Attribute | Description |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `db.opensearch.phase_took.can_match` | Time spent determining which shards can match the query |
|
|
149
|
+
| `db.opensearch.phase_took.dfs_pre_query` | Time spent collecting term statistics across shards before the query phase |
|
|
150
|
+
| `db.opensearch.phase_took.dfs_query` | Time spent executing the query using globally collected term statistics |
|
|
151
|
+
| `db.opensearch.phase_took.expand` | Time spent expanding results (e.g. for collapse/inner hits) |
|
|
152
|
+
| `db.opensearch.phase_took.fetch` | Time spent fetching document source and fields |
|
|
153
|
+
| `db.opensearch.phase_took.query` | Time spent in the standard query phase |
|
package/dist/index.d.mts
CHANGED
|
@@ -1,57 +1,25 @@
|
|
|
1
1
|
import { ApiResponse, TransportRequestParams } from "@opensearch-project/opensearch/lib/Transport.js";
|
|
2
|
-
import { Span } from "@opentelemetry/api";
|
|
3
2
|
import { InstrumentationBase, InstrumentationConfig } from "@opentelemetry/instrumentation";
|
|
3
|
+
import { Span } from "@opentelemetry/api";
|
|
4
4
|
|
|
5
|
-
//#region src/
|
|
6
|
-
/** Configuration for {@link OpenSearchInstrumentation}. */
|
|
5
|
+
//#region src/types.d.ts
|
|
7
6
|
interface OpenSearchInstrumentationConfig extends InstrumentationConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Serialize the request body into `db.query.text`.
|
|
10
|
-
* Set to `false` to disable capture entirely.
|
|
11
|
-
* Defaults to `JSON.stringify`.
|
|
12
|
-
*/
|
|
13
7
|
dbStatementSerializer?: false | ((params: TransportRequestParams) => string);
|
|
14
|
-
/**
|
|
15
|
-
* Hook called after span attributes are set, before the request is made.
|
|
16
|
-
* Use to add custom attributes.
|
|
17
|
-
*/
|
|
18
8
|
requestHook?: (span: Span, params: TransportRequestParams) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Hook called after a successful response is received.
|
|
21
|
-
* Use to add custom attributes derived from the response.
|
|
22
|
-
*/
|
|
23
9
|
responseHook?: (span: Span, response: ApiResponse) => void;
|
|
24
|
-
/**
|
|
25
|
-
* When `true`, child span creation inside the Transport call is suppressed so
|
|
26
|
-
* HTTP instrumentation cannot produce a duplicate span.
|
|
27
|
-
* When `false` (default), the db span is set as the active context so HTTP
|
|
28
|
-
* child spans are properly parented and W3C trace headers are propagated.
|
|
29
|
-
*/
|
|
30
10
|
suppressInternalInstrumentation?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* If set, the value of the `@opensearch-project/opensearch` client version is
|
|
33
|
-
* recorded as a span attribute under this name.
|
|
34
|
-
* e.g. `'db.opensearch.client.version'`
|
|
35
|
-
*/
|
|
36
11
|
moduleVersionAttributeName?: string;
|
|
37
12
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*
|
|
41
|
-
* Patches `Transport.prototype.request` to create a `db` CLIENT span for every
|
|
42
|
-
* request. Tracing is suppressed inside the call so the HTTP instrumentation
|
|
43
|
-
* does not produce a duplicate child span.
|
|
44
|
-
*/
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/index.d.ts
|
|
45
15
|
declare class OpenSearchInstrumentation extends InstrumentationBase {
|
|
46
16
|
private readonly osConfig;
|
|
47
17
|
private _original;
|
|
48
18
|
constructor(config?: OpenSearchInstrumentationConfig);
|
|
49
19
|
protected init(): void;
|
|
50
|
-
/** Patches `Transport.prototype.request` with span instrumentation. */
|
|
51
20
|
enable(): void;
|
|
52
|
-
/** Restores the original `Transport.prototype.request`. */
|
|
53
21
|
disable(): void;
|
|
54
22
|
}
|
|
55
23
|
//#endregion
|
|
56
|
-
export { OpenSearchInstrumentation, OpenSearchInstrumentationConfig };
|
|
24
|
+
export { OpenSearchInstrumentation, type OpenSearchInstrumentationConfig };
|
|
57
25
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/index.ts"],"mappings":";;;;;UAOiB,+BAAA,SAAwC,qBAAA;EACvD,qBAAA,aAAkC,MAAA,EAAQ,sBAAA;EAC1C,WAAA,IAAe,IAAA,EAAM,IAAA,EAAM,MAAA,EAAQ,sBAAA;EACnC,YAAA,IAAgB,IAAA,EAAM,IAAA,EAAM,QAAA,EAAU,WAAA;EACtC,+BAAA;EACA,0BAAA;AAAA;;;cCGW,yBAAA,SAAkC,mBAAA;EAAA,iBAC5B,QAAA;EAAA,QACT,SAAA;cAEI,MAAA,GAAQ,+BAAA;EAAA,UAQV,IAAA,CAAA;EAED,MAAA,CAAA;EAWA,OAAA,CAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,91 +1,136 @@
|
|
|
1
1
|
import Transport from "@opensearch-project/opensearch/lib/Transport.js";
|
|
2
2
|
import opensearchPkg from "@opensearch-project/opensearch/package.json" with { type: "json" };
|
|
3
|
+
import { InstrumentationBase } from "@opentelemetry/instrumentation";
|
|
3
4
|
import { SpanKind, SpanStatusCode, context, trace } from "@opentelemetry/api";
|
|
4
5
|
import { suppressTracing } from "@opentelemetry/core";
|
|
5
|
-
import { InstrumentationBase } from "@opentelemetry/instrumentation";
|
|
6
6
|
import { ATTR_DB_OPERATION_NAME, ATTR_DB_QUERY_TEXT, ATTR_DB_SYSTEM_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT } from "@opentelemetry/semantic-conventions";
|
|
7
|
+
//#region package.json
|
|
8
|
+
var name = "@sebspark/opentelemetry-instrumentation-opensearch";
|
|
9
|
+
var version = "0.2.1";
|
|
7
10
|
//#endregion
|
|
8
|
-
//#region src/
|
|
9
|
-
const
|
|
10
|
-
const OPENSEARCH_CLIENT_VERSION = opensearchPkg.version;
|
|
11
|
-
/**
|
|
12
|
-
* Parses an OpenSearch path into its index and operation components.
|
|
13
|
-
* e.g. `/my_index/_search` → `{ index: 'my_index', operation: 'search' }`
|
|
14
|
-
* e.g. `/_bulk` → `{ operation: 'bulk' }`
|
|
15
|
-
*/
|
|
16
|
-
function parsePath(path) {
|
|
11
|
+
//#region src/parse-path.ts
|
|
12
|
+
const parsePath = (path) => {
|
|
17
13
|
const match = path.match(/^\/(?:([^/_][^/]*)\/)?_([^/]+)/);
|
|
18
14
|
if (!match) return {};
|
|
19
15
|
return {
|
|
20
16
|
index: match[1],
|
|
21
17
|
operation: match[2]
|
|
22
18
|
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/response-attributes.ts
|
|
22
|
+
const ATTR_DB_OPENSEARCH_DURATION_MS = "db.opensearch.duration_ms";
|
|
23
|
+
const extractResponseAttributes = (res) => {
|
|
24
|
+
const attrs = {};
|
|
25
|
+
const { hostname, port } = res.meta.connection.url;
|
|
26
|
+
attrs[ATTR_SERVER_ADDRESS] = hostname;
|
|
27
|
+
if (port) attrs[ATTR_SERVER_PORT] = Number(port);
|
|
28
|
+
if (res.statusCode != null) attrs["http.response.status_code"] = res.statusCode;
|
|
29
|
+
const body = res.body;
|
|
30
|
+
if (body == null) return attrs;
|
|
31
|
+
if (body.took != null) attrs["db.opensearch.took"] = body.took;
|
|
32
|
+
if (body.timed_out != null) attrs["db.opensearch.timed_out"] = body.timed_out;
|
|
33
|
+
if (body.terminated_early != null) attrs["db.opensearch.terminated_early"] = body.terminated_early;
|
|
34
|
+
const shards = body._shards;
|
|
35
|
+
if (shards != null) {
|
|
36
|
+
attrs["db.opensearch.shards.total"] = shards.total;
|
|
37
|
+
attrs["db.opensearch.shards.successful"] = shards.successful;
|
|
38
|
+
attrs["db.opensearch.shards.failed"] = shards.failed;
|
|
39
|
+
if (shards.skipped != null) attrs["db.opensearch.shards.skipped"] = shards.skipped;
|
|
40
|
+
}
|
|
41
|
+
const phaseTook = body.phase_took;
|
|
42
|
+
if (phaseTook != null) {
|
|
43
|
+
attrs["db.opensearch.phase_took.can_match"] = phaseTook.can_match;
|
|
44
|
+
attrs["db.opensearch.phase_took.dfs_pre_query"] = phaseTook.dfs_pre_query;
|
|
45
|
+
attrs["db.opensearch.phase_took.dfs_query"] = phaseTook.dfs_query;
|
|
46
|
+
attrs["db.opensearch.phase_took.expand"] = phaseTook.expand;
|
|
47
|
+
attrs["db.opensearch.phase_took.fetch"] = phaseTook.fetch;
|
|
48
|
+
attrs["db.opensearch.phase_took.query"] = phaseTook.query;
|
|
49
|
+
}
|
|
50
|
+
const total = body.hits?.total;
|
|
51
|
+
if (total != null && typeof total === "object") attrs["db.opensearch.hits.total"] = total.value;
|
|
52
|
+
return attrs;
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region src/serialize-body.ts
|
|
56
|
+
const serializeBody = (params, config) => {
|
|
57
|
+
if (!params.body) return void 0;
|
|
58
|
+
if (config.dbStatementSerializer === false) return void 0;
|
|
59
|
+
if (typeof config.dbStatementSerializer === "function") return config.dbStatementSerializer(params);
|
|
60
|
+
return typeof params.body === "string" ? params.body : JSON.stringify(params.body);
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/patch-request.ts
|
|
64
|
+
const createPatchedRequest = (getTracer, config = {}, original, clientVersion) => {
|
|
65
|
+
function patchedRequest(params, options, callback) {
|
|
66
|
+
const { index, operation } = parsePath(params.path);
|
|
67
|
+
const queryText = serializeBody(params, config);
|
|
68
|
+
const span = getTracer().startSpan([operation, index].filter(Boolean).join(" ") || params.path, {
|
|
69
|
+
kind: SpanKind.CLIENT,
|
|
70
|
+
attributes: {
|
|
71
|
+
[ATTR_DB_SYSTEM_NAME]: "opensearch",
|
|
72
|
+
...operation && { [ATTR_DB_OPERATION_NAME]: operation },
|
|
73
|
+
...index && { "db.opensearch.index": index },
|
|
74
|
+
...queryText && { [ATTR_DB_QUERY_TEXT]: queryText }
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
config.requestHook?.(span, params);
|
|
78
|
+
const startTime = Date.now();
|
|
79
|
+
const onSuccess = (res) => {
|
|
80
|
+
span.setAttribute(ATTR_DB_OPENSEARCH_DURATION_MS, Date.now() - startTime);
|
|
81
|
+
for (const [key, value] of Object.entries(extractResponseAttributes(res))) span.setAttribute(key, value);
|
|
82
|
+
if (config.moduleVersionAttributeName) span.setAttribute(config.moduleVersionAttributeName, clientVersion);
|
|
83
|
+
config.responseHook?.(span, res);
|
|
84
|
+
span.end();
|
|
85
|
+
};
|
|
86
|
+
const onError = (err) => {
|
|
87
|
+
span.setAttribute(ATTR_DB_OPENSEARCH_DURATION_MS, Date.now() - startTime);
|
|
88
|
+
if (err instanceof Error) span.recordException(err);
|
|
89
|
+
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
90
|
+
span.end();
|
|
91
|
+
};
|
|
92
|
+
const callCtx = config.suppressInternalInstrumentation ? suppressTracing(context.active()) : trace.setSpan(context.active(), span);
|
|
93
|
+
if (typeof callback === "function") {
|
|
94
|
+
const originalWithCallback = original.bind(this);
|
|
95
|
+
return context.with(callCtx, () => originalWithCallback(params, options, (err, res) => {
|
|
96
|
+
err ? onError(err) : onSuccess(res);
|
|
97
|
+
callback(err, res);
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const result = context.with(callCtx, () => original.call(this, params, options));
|
|
101
|
+
const settled = result.then((res) => {
|
|
102
|
+
onSuccess(res);
|
|
103
|
+
return res;
|
|
104
|
+
}, (err) => {
|
|
105
|
+
onError(err);
|
|
106
|
+
throw err;
|
|
107
|
+
});
|
|
108
|
+
return Object.assign(settled, { abort: result.abort });
|
|
109
|
+
}
|
|
110
|
+
return patchedRequest;
|
|
111
|
+
};
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/index.ts
|
|
114
|
+
const PACKAGE_NAME = name;
|
|
115
|
+
const PACKAGE_VERSION = version;
|
|
116
|
+
const OPENSEARCH_CLIENT_VERSION = opensearchPkg.version;
|
|
31
117
|
var OpenSearchInstrumentation = class extends InstrumentationBase {
|
|
32
118
|
osConfig;
|
|
119
|
+
_original;
|
|
33
120
|
constructor(config = {}) {
|
|
34
|
-
super(
|
|
121
|
+
super(PACKAGE_NAME, PACKAGE_VERSION, {
|
|
122
|
+
...config,
|
|
123
|
+
enabled: false
|
|
124
|
+
});
|
|
35
125
|
this.osConfig = config;
|
|
126
|
+
if (config.enabled !== false) this.enable();
|
|
36
127
|
}
|
|
37
128
|
init() {}
|
|
38
|
-
/** Patches `Transport.prototype.request` with span instrumentation. */
|
|
39
129
|
enable() {
|
|
40
130
|
if (this._original) return;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this._original = original;
|
|
44
|
-
function patchedRequest(params, options, callback) {
|
|
45
|
-
const { index, operation } = parsePath(params.path);
|
|
46
|
-
const spanName = [operation, index].filter(Boolean).join(" ") || params.path;
|
|
47
|
-
const span = self.tracer.startSpan(spanName, {
|
|
48
|
-
kind: SpanKind.CLIENT,
|
|
49
|
-
attributes: {
|
|
50
|
-
[ATTR_DB_SYSTEM_NAME]: "opensearch",
|
|
51
|
-
...operation && { [ATTR_DB_OPERATION_NAME]: operation },
|
|
52
|
-
...index && { "db.opensearch.index": index },
|
|
53
|
-
...params.body && self.osConfig?.dbStatementSerializer !== false && { [ATTR_DB_QUERY_TEXT]: typeof self.osConfig?.dbStatementSerializer === "function" ? self.osConfig.dbStatementSerializer(params) : typeof params.body === "string" ? params.body : JSON.stringify(params.body) }
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
self.osConfig?.requestHook?.(span, params);
|
|
57
|
-
const endSpanOnSuccess = (res) => {
|
|
58
|
-
const { hostname, port } = res.meta.connection.url;
|
|
59
|
-
span.setAttribute(ATTR_SERVER_ADDRESS, hostname);
|
|
60
|
-
if (port) span.setAttribute(ATTR_SERVER_PORT, Number(port));
|
|
61
|
-
if (self.osConfig?.moduleVersionAttributeName) span.setAttribute(self.osConfig.moduleVersionAttributeName, OPENSEARCH_CLIENT_VERSION);
|
|
62
|
-
self.osConfig?.responseHook?.(span, res);
|
|
63
|
-
span.end();
|
|
64
|
-
};
|
|
65
|
-
const endSpanOnError = (err) => {
|
|
66
|
-
if (err instanceof Error) span.recordException(err);
|
|
67
|
-
span.setStatus({ code: SpanStatusCode.ERROR });
|
|
68
|
-
span.end();
|
|
69
|
-
};
|
|
70
|
-
const callCtx = self.osConfig?.suppressInternalInstrumentation ? suppressTracing(context.active()) : trace.setSpan(context.active(), span);
|
|
71
|
-
if (typeof callback === "function") return context.with(callCtx, () => original.call(this, params, options, (err, res) => {
|
|
72
|
-
if (err) endSpanOnError(err);
|
|
73
|
-
else endSpanOnSuccess(res);
|
|
74
|
-
callback(err, res);
|
|
75
|
-
}));
|
|
76
|
-
const result = context.with(callCtx, () => original.call(this, params, options));
|
|
77
|
-
const settled = result.then((res) => {
|
|
78
|
-
endSpanOnSuccess(res);
|
|
79
|
-
return res;
|
|
80
|
-
}, (err) => {
|
|
81
|
-
endSpanOnError(err);
|
|
82
|
-
throw err;
|
|
83
|
-
});
|
|
84
|
-
return Object.assign(settled, { abort: result.abort });
|
|
85
|
-
}
|
|
86
|
-
Transport.prototype.request = patchedRequest;
|
|
131
|
+
this._original = Transport.prototype.request;
|
|
132
|
+
Transport.prototype.request = createPatchedRequest(() => this.tracer, this.osConfig, this._original, OPENSEARCH_CLIENT_VERSION);
|
|
87
133
|
}
|
|
88
|
-
/** Restores the original `Transport.prototype.request`. */
|
|
89
134
|
disable() {
|
|
90
135
|
if (this._original) {
|
|
91
136
|
Transport.prototype.request = this._original;
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["pkg.version"],"sources":["../package.json","../src/index.ts"],"sourcesContent":["","import Transport, {\n type ApiError,\n type ApiResponse,\n type TransportRequestCallback,\n type TransportRequestOptions,\n type TransportRequestParams,\n type TransportRequestPromise,\n} from '@opensearch-project/opensearch/lib/Transport.js'\nimport opensearchPkg from '@opensearch-project/opensearch/package.json' with {\n type: 'json',\n}\nimport {\n context,\n type Span,\n SpanKind,\n SpanStatusCode,\n trace,\n} from '@opentelemetry/api'\nimport { suppressTracing } from '@opentelemetry/core'\nimport {\n InstrumentationBase,\n type InstrumentationConfig,\n} from '@opentelemetry/instrumentation'\nimport {\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_SYSTEM_NAME,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions'\nimport pkg from '../package.json' with { type: 'json' }\n\nconst PACKAGE_VERSION: string = pkg.version\nconst OPENSEARCH_CLIENT_VERSION: string = opensearchPkg.version\n\n/**\n * Parses an OpenSearch path into its index and operation components.\n * e.g. `/my_index/_search` → `{ index: 'my_index', operation: 'search' }`\n * e.g. `/_bulk` → `{ operation: 'bulk' }`\n */\nfunction parsePath(path: string): { index?: string; operation?: string } {\n const match = path.match(/^\\/(?:([^/_][^/]*)\\/)?_([^/]+)/)\n if (!match) return {}\n return { index: match[1], operation: match[2] }\n}\n\n/** Configuration for {@link OpenSearchInstrumentation}. */\nexport interface OpenSearchInstrumentationConfig extends InstrumentationConfig {\n /**\n * Serialize the request body into `db.query.text`.\n * Set to `false` to disable capture entirely.\n * Defaults to `JSON.stringify`.\n */\n dbStatementSerializer?: false | ((params: TransportRequestParams) => string)\n\n /**\n * Hook called after span attributes are set, before the request is made.\n * Use to add custom attributes.\n */\n requestHook?: (span: Span, params: TransportRequestParams) => void\n\n /**\n * Hook called after a successful response is received.\n * Use to add custom attributes derived from the response.\n */\n responseHook?: (span: Span, response: ApiResponse) => void\n\n /**\n * When `true`, child span creation inside the Transport call is suppressed so\n * HTTP instrumentation cannot produce a duplicate span.\n * When `false` (default), the db span is set as the active context so HTTP\n * child spans are properly parented and W3C trace headers are propagated.\n */\n suppressInternalInstrumentation?: boolean\n\n /**\n * If set, the value of the `@opensearch-project/opensearch` client version is\n * recorded as a span attribute under this name.\n * e.g. `'db.opensearch.client.version'`\n */\n moduleVersionAttributeName?: string\n}\n\n/**\n * OpenTelemetry instrumentation for `@opensearch-project/opensearch`.\n *\n * Patches `Transport.prototype.request` to create a `db` CLIENT span for every\n * request. Tracing is suppressed inside the call so the HTTP instrumentation\n * does not produce a duplicate child span.\n */\nexport class OpenSearchInstrumentation extends InstrumentationBase {\n private readonly osConfig: OpenSearchInstrumentationConfig\n private declare _original: typeof Transport.prototype.request | undefined\n\n constructor(config: OpenSearchInstrumentationConfig = {}) {\n super(\n '@sebspark/opentelemetry-instrumentation-opensearch',\n PACKAGE_VERSION,\n config\n )\n this.osConfig = config\n }\n\n protected init() {}\n\n /** Patches `Transport.prototype.request` with span instrumentation. */\n override enable() {\n if (this._original) return\n const self = this\n const original: (\n this: Transport,\n params: TransportRequestParams,\n options?: TransportRequestOptions\n ) => TransportRequestPromise<ApiResponse> = Transport.prototype.request\n this._original = original\n\n function patchedRequest(\n params: TransportRequestParams,\n options?: TransportRequestOptions\n ): TransportRequestPromise<ApiResponse>\n function patchedRequest(\n params: TransportRequestParams,\n options: TransportRequestOptions | undefined,\n callback: (err: ApiError, result: ApiResponse) => void\n ): TransportRequestCallback\n function patchedRequest(\n this: Transport,\n params: TransportRequestParams,\n options?: TransportRequestOptions,\n callback?: (err: ApiError, result: ApiResponse) => void\n ): TransportRequestPromise<ApiResponse> | TransportRequestCallback {\n const { index, operation } = parsePath(params.path)\n const spanName =\n [operation, index].filter(Boolean).join(' ') || params.path\n const span = self.tracer.startSpan(spanName, {\n kind: SpanKind.CLIENT,\n attributes: {\n [ATTR_DB_SYSTEM_NAME]: 'opensearch',\n ...(operation && { [ATTR_DB_OPERATION_NAME]: operation }),\n ...(index && { 'db.opensearch.index': index }),\n ...(params.body &&\n self.osConfig?.dbStatementSerializer !== false && {\n [ATTR_DB_QUERY_TEXT]:\n typeof self.osConfig?.dbStatementSerializer === 'function'\n ? self.osConfig.dbStatementSerializer(params)\n : typeof params.body === 'string'\n ? params.body\n : JSON.stringify(params.body),\n }),\n },\n })\n self.osConfig?.requestHook?.(span, params)\n\n const endSpanOnSuccess = (res: ApiResponse) => {\n const { hostname, port } = res.meta.connection.url\n span.setAttribute(ATTR_SERVER_ADDRESS, hostname)\n if (port) span.setAttribute(ATTR_SERVER_PORT, Number(port))\n if (self.osConfig?.moduleVersionAttributeName) {\n span.setAttribute(\n self.osConfig.moduleVersionAttributeName,\n OPENSEARCH_CLIENT_VERSION\n )\n }\n self.osConfig?.responseHook?.(span, res)\n span.end()\n }\n const endSpanOnError = (err: unknown) => {\n if (err instanceof Error) span.recordException(err)\n span.setStatus({ code: SpanStatusCode.ERROR })\n span.end()\n }\n\n const callCtx = self.osConfig?.suppressInternalInstrumentation\n ? suppressTracing(context.active())\n : trace.setSpan(context.active(), span)\n\n if (typeof callback === 'function') {\n return context.with(callCtx, () =>\n (\n original as (\n this: Transport,\n params: TransportRequestParams,\n options: TransportRequestOptions | undefined,\n callback: (err: ApiError, result: ApiResponse) => void\n ) => TransportRequestCallback\n ).call(this, params, options, (err, res) => {\n if (err) endSpanOnError(err)\n else endSpanOnSuccess(res)\n callback(err, res)\n })\n )\n }\n\n const result = context.with(callCtx, () =>\n original.call(this, params, options)\n )\n const settled = result.then(\n (res: ApiResponse) => {\n endSpanOnSuccess(res)\n return res\n },\n (err: unknown) => {\n endSpanOnError(err)\n throw err\n }\n )\n return Object.assign(settled, { abort: result.abort })\n }\n\n Transport.prototype.request = patchedRequest\n }\n\n /** Restores the original `Transport.prototype.request`. */\n override disable() {\n if (this._original) {\n Transport.prototype.request = this._original\n this._original = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;ACgCA,MAAM;AACN,MAAM,4BAAoC,cAAc;;;;;;AAOxD,SAAS,UAAU,MAAsD;CACvE,MAAM,QAAQ,KAAK,MAAM,iCAAiC;AAC1D,KAAI,CAAC,MAAO,QAAO,EAAE;AACrB,QAAO;EAAE,OAAO,MAAM;EAAI,WAAW,MAAM;EAAI;;;;;;;;;AA+CjD,IAAa,4BAAb,cAA+C,oBAAoB;CACjE;CAGA,YAAY,SAA0C,EAAE,EAAE;AACxD,QACE,sDACA,iBACA,OACD;AACD,OAAK,WAAW;;CAGlB,OAAiB;;CAGjB,SAAkB;AAChB,MAAI,KAAK,UAAW;EACpB,MAAM,OAAO;EACb,MAAM,WAIsC,UAAU,UAAU;AAChE,OAAK,YAAY;EAWjB,SAAS,eAEP,QACA,SACA,UACiE;GACjE,MAAM,EAAE,OAAO,cAAc,UAAU,OAAO,KAAK;GACnD,MAAM,WACJ,CAAC,WAAW,MAAM,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI,IAAI,OAAO;GACzD,MAAM,OAAO,KAAK,OAAO,UAAU,UAAU;IAC3C,MAAM,SAAS;IACf,YAAY;MACT,sBAAsB;KACvB,GAAI,aAAa,GAAG,yBAAyB,WAAW;KACxD,GAAI,SAAS,EAAE,uBAAuB,OAAO;KAC7C,GAAI,OAAO,QACT,KAAK,UAAU,0BAA0B,SAAS,GAC/C,qBACC,OAAO,KAAK,UAAU,0BAA0B,aAC5C,KAAK,SAAS,sBAAsB,OAAO,GAC3C,OAAO,OAAO,SAAS,WACrB,OAAO,OACP,KAAK,U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pkg.version"],"sources":["../package.json","../src/parse-path.ts","../src/response-attributes.ts","../src/serialize-body.ts","../src/patch-request.ts","../src/index.ts"],"sourcesContent":["","export const parsePath = (\n path: string\n): { index?: string; operation?: string } => {\n const match = path.match(/^\\/(?:([^/_][^/]*)\\/)?_([^/]+)/)\n if (!match) return {}\n return { index: match[1], operation: match[2] }\n}\n","import type { Types } from '@opensearch-project/opensearch'\nimport type { ApiResponse } from '@opensearch-project/opensearch/lib/Transport.js'\nimport {\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n} from '@opentelemetry/semantic-conventions'\n\nexport const ATTR_DB_OPENSEARCH_DURATION_MS = 'db.opensearch.duration_ms'\n\nexport const extractResponseAttributes = (\n res: ApiResponse\n): Record<string, string | number | boolean> => {\n const attrs: Record<string, string | number | boolean> = {}\n\n const { hostname, port } = res.meta.connection.url\n attrs[ATTR_SERVER_ADDRESS] = hostname\n if (port) attrs[ATTR_SERVER_PORT] = Number(port)\n if (res.statusCode != null)\n attrs['http.response.status_code'] = res.statusCode\n\n const body = res.body as Types.Core_Search.ResponseBody | null | undefined\n if (body == null) return attrs\n\n if (body.took != null) attrs['db.opensearch.took'] = body.took\n if (body.timed_out != null) attrs['db.opensearch.timed_out'] = body.timed_out\n if (body.terminated_early != null)\n attrs['db.opensearch.terminated_early'] = body.terminated_early\n\n const shards = body._shards\n if (shards != null) {\n attrs['db.opensearch.shards.total'] = shards.total\n attrs['db.opensearch.shards.successful'] = shards.successful\n attrs['db.opensearch.shards.failed'] = shards.failed\n if (shards.skipped != null)\n attrs['db.opensearch.shards.skipped'] = shards.skipped\n }\n\n const phaseTook = body.phase_took\n if (phaseTook != null) {\n attrs['db.opensearch.phase_took.can_match'] = phaseTook.can_match\n attrs['db.opensearch.phase_took.dfs_pre_query'] = phaseTook.dfs_pre_query\n attrs['db.opensearch.phase_took.dfs_query'] = phaseTook.dfs_query\n attrs['db.opensearch.phase_took.expand'] = phaseTook.expand\n attrs['db.opensearch.phase_took.fetch'] = phaseTook.fetch\n attrs['db.opensearch.phase_took.query'] = phaseTook.query\n }\n\n const total = body.hits?.total\n if (total != null && typeof total === 'object') {\n attrs['db.opensearch.hits.total'] = total.value\n }\n\n return attrs\n}\n","import type { TransportRequestParams } from '@opensearch-project/opensearch/lib/Transport.js'\nimport type { OpenSearchInstrumentationConfig } from './types'\n\nexport const serializeBody = (\n params: TransportRequestParams,\n config: Pick<OpenSearchInstrumentationConfig, 'dbStatementSerializer'>\n): string | undefined => {\n if (!params.body) return undefined\n if (config.dbStatementSerializer === false) return undefined\n if (typeof config.dbStatementSerializer === 'function') {\n return config.dbStatementSerializer(params)\n }\n return typeof params.body === 'string'\n ? params.body\n : JSON.stringify(params.body)\n}\n","import type Transport from '@opensearch-project/opensearch/lib/Transport.js'\nimport type {\n ApiError,\n ApiResponse,\n TransportRequestCallback,\n TransportRequestOptions,\n TransportRequestParams,\n TransportRequestPromise,\n} from '@opensearch-project/opensearch/lib/Transport.js'\nimport {\n context,\n SpanKind,\n SpanStatusCode,\n type Tracer,\n trace,\n} from '@opentelemetry/api'\nimport { suppressTracing } from '@opentelemetry/core'\nimport {\n ATTR_DB_OPERATION_NAME,\n ATTR_DB_QUERY_TEXT,\n ATTR_DB_SYSTEM_NAME,\n} from '@opentelemetry/semantic-conventions'\nimport { parsePath } from './parse-path'\nimport {\n ATTR_DB_OPENSEARCH_DURATION_MS,\n extractResponseAttributes,\n} from './response-attributes'\nimport { serializeBody } from './serialize-body'\nimport type { OpenSearchInstrumentationConfig } from './types'\n\nexport type OriginalRequest = (\n this: Transport,\n params: TransportRequestParams,\n options?: TransportRequestOptions\n) => TransportRequestPromise<ApiResponse>\n\ntype OriginalRequestWithCallback = (\n this: Transport,\n params: TransportRequestParams,\n options: TransportRequestOptions | undefined,\n callback: (err: ApiError, result: ApiResponse) => void\n) => TransportRequestCallback\n\nexport const createPatchedRequest = (\n getTracer: () => Tracer,\n config: OpenSearchInstrumentationConfig = {},\n original: OriginalRequest,\n clientVersion: string\n) => {\n function patchedRequest(\n params: TransportRequestParams,\n options?: TransportRequestOptions\n ): TransportRequestPromise<ApiResponse>\n function patchedRequest(\n params: TransportRequestParams,\n options: TransportRequestOptions | undefined,\n callback: (err: ApiError, result: ApiResponse) => void\n ): TransportRequestCallback\n function patchedRequest(\n this: Transport,\n params: TransportRequestParams,\n options?: TransportRequestOptions,\n callback?: (err: ApiError, result: ApiResponse) => void\n ): TransportRequestPromise<ApiResponse> | TransportRequestCallback {\n const { index, operation } = parsePath(params.path)\n const queryText = serializeBody(params, config)\n\n const span = getTracer().startSpan(\n [operation, index].filter(Boolean).join(' ') || params.path,\n {\n kind: SpanKind.CLIENT,\n attributes: {\n [ATTR_DB_SYSTEM_NAME]: 'opensearch',\n ...(operation && { [ATTR_DB_OPERATION_NAME]: operation }),\n ...(index && { 'db.opensearch.index': index }),\n ...(queryText && { [ATTR_DB_QUERY_TEXT]: queryText }),\n },\n }\n )\n config.requestHook?.(span, params)\n\n const startTime = Date.now()\n\n const onSuccess = (res: ApiResponse) => {\n span.setAttribute(ATTR_DB_OPENSEARCH_DURATION_MS, Date.now() - startTime)\n for (const [key, value] of Object.entries(\n extractResponseAttributes(res)\n )) {\n span.setAttribute(key, value)\n }\n if (config.moduleVersionAttributeName) {\n span.setAttribute(config.moduleVersionAttributeName, clientVersion)\n }\n config.responseHook?.(span, res)\n span.end()\n }\n\n const onError = (err: unknown) => {\n span.setAttribute(ATTR_DB_OPENSEARCH_DURATION_MS, Date.now() - startTime)\n if (err instanceof Error) span.recordException(err)\n span.setStatus({ code: SpanStatusCode.ERROR })\n span.end()\n }\n\n const callCtx = config.suppressInternalInstrumentation\n ? suppressTracing(context.active())\n : trace.setSpan(context.active(), span)\n\n if (typeof callback === 'function') {\n const originalWithCallback = (\n original as OriginalRequestWithCallback\n ).bind(this)\n return context.with(callCtx, () =>\n originalWithCallback(params, options, (err, res) => {\n err ? onError(err) : onSuccess(res)\n callback(err, res)\n })\n )\n }\n\n const result = context.with(callCtx, () =>\n original.call(this, params, options)\n )\n const settled = result.then(\n (res: ApiResponse) => {\n onSuccess(res)\n return res\n },\n (err: unknown) => {\n onError(err)\n throw err\n }\n )\n return Object.assign(settled, { abort: result.abort })\n }\n\n return patchedRequest\n}\n","import Transport from '@opensearch-project/opensearch/lib/Transport.js'\nimport opensearchPkg from '@opensearch-project/opensearch/package.json' with {\n type: 'json',\n}\nimport { InstrumentationBase } from '@opentelemetry/instrumentation'\nimport pkg from '../package.json' with { type: 'json' }\nimport { createPatchedRequest, type OriginalRequest } from './patch-request'\nimport type { OpenSearchInstrumentationConfig } from './types'\n\nexport type { OpenSearchInstrumentationConfig } from './types'\n\nconst PACKAGE_NAME: string = pkg.name\nconst PACKAGE_VERSION: string = pkg.version\nconst OPENSEARCH_CLIENT_VERSION: string = opensearchPkg.version\n\nexport class OpenSearchInstrumentation extends InstrumentationBase {\n private readonly osConfig: OpenSearchInstrumentationConfig\n private _original: OriginalRequest | undefined\n\n constructor(config: OpenSearchInstrumentationConfig = {}) {\n super(PACKAGE_NAME, PACKAGE_VERSION, { ...config, enabled: false })\n this.osConfig = config\n if (config.enabled !== false) {\n this.enable()\n }\n }\n\n protected init() {}\n\n override enable() {\n if (this._original) return\n this._original = Transport.prototype.request as OriginalRequest\n Transport.prototype.request = createPatchedRequest(\n () => this.tracer,\n this.osConfig,\n this._original,\n OPENSEARCH_CLIENT_VERSION\n )\n }\n\n override disable() {\n if (this._original) {\n Transport.prototype.request = this._original\n this._original = undefined\n }\n }\n}\n"],"mappings":";;;;;;;;;;;ACAA,MAAa,aACX,SAC2C;CAC3C,MAAM,QAAQ,KAAK,MAAM,iCAAiC;AAC1D,KAAI,CAAC,MAAO,QAAO,EAAE;AACrB,QAAO;EAAE,OAAO,MAAM;EAAI,WAAW,MAAM;EAAI;;;;ACEjD,MAAa,iCAAiC;AAE9C,MAAa,6BACX,QAC8C;CAC9C,MAAM,QAAmD,EAAE;CAE3D,MAAM,EAAE,UAAU,SAAS,IAAI,KAAK,W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K,MAAM,QAAQ,QAAQ,CACrC;EACD,MAAM,UAAU,OAAO,MACpB,QAAqB;AACpB,aAAU,IAAI;AACd,UAAO;MAER,QAAiB;AAChB,WAAQ,IAAI;AACZ,SAAM;IAET;AACD,SAAO,OAAO,OAAO,SAAS,EAAE,OAAO,OAAO,OAAO,CAAC;;AAGxD,QAAO;;;;AC7HT,MAAM,eAAuBA;AAC7B,MAAM,kBAA0BC;AAChC,MAAM,4BAAoC,cAAc;AAExD,IAAa,4BAAb,cAA+C,oBAAoB;CACjE;CACA;CAEA,YAAY,SAA0C,EAAE,EAAE;AACxD,QAAM,cAAc,iBAAiB;GAAE,GAAG;GAAQ,SAAS;GAAO,CAAC;AACnE,OAAK,WAAW;AAChB,MAAI,OAAO,YAAY,MACrB,MAAK,QAAQ;;CAIjB,OAAiB;CAEjB,SAAkB;AAChB,MAAI,KAAK,UAAW;AACpB,OAAK,YAAY,UAAU,UAAU;AACrC,YAAU,UAAU,UAAU,2BACtB,KAAK,QACX,KAAK,UACL,KAAK,WACL,0BACD;;CAGH,UAAmB;AACjB,MAAI,KAAK,WAAW;AAClB,aAAU,UAAU,UAAU,KAAK;AACnC,QAAK,YAAY,KAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/opentelemetry-instrumentation-opensearch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@opensearch-project/opensearch": "3.5.1",
|
|
36
36
|
"@opentelemetry/api": "1.9.0",
|
|
37
|
+
"@opentelemetry/instrumentation-http": "0.213.0",
|
|
38
|
+
"@opentelemetry/instrumentation-undici": "0.23.0",
|
|
37
39
|
"@opentelemetry/sdk-trace-base": "2.6.0",
|
|
38
40
|
"@opentelemetry/sdk-trace-node": "2.6.0",
|
|
39
41
|
"@testcontainers/opensearch": "11.13.0"
|