@julr/otel-instrumentation-clickhouse 1.0.0 → 1.0.2
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/build/src/constants.d.ts +25 -0
- package/build/src/constants.d.ts.map +1 -0
- package/build/src/constants.js +28 -0
- package/build/src/constants.js.map +1 -0
- package/build/src/index.d.ts +3 -0
- package/build/src/index.d.ts.map +1 -0
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -0
- package/build/src/instrumentation.d.ts +11 -0
- package/build/src/instrumentation.d.ts.map +1 -0
- package/build/src/instrumentation.js +209 -0
- package/build/src/instrumentation.js.map +1 -0
- package/build/src/internal_types.d.ts +25 -0
- package/build/src/internal_types.d.ts.map +1 -0
- package/build/src/internal_types.js +2 -0
- package/build/src/internal_types.js.map +1 -0
- package/build/src/types.d.ts +26 -0
- package/build/src/types.d.ts.map +1 -0
- package/build/src/types.js +2 -0
- package/build/src/types.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ClickHouseInstrumentationConfig } from './types.js';
|
|
2
|
+
export declare const MODULE_NAME = "@clickhouse/client-common";
|
|
3
|
+
export declare const INSTRUMENTATION_NAME = "@julr/otel-instrumentation-clickhouse";
|
|
4
|
+
export declare const INSTRUMENTATION_VERSION = "1.0.0";
|
|
5
|
+
/**
|
|
6
|
+
* Stable semantic convention attributes for database spans
|
|
7
|
+
* @see https://opentelemetry.io/docs/specs/semconv/database/database-spans/
|
|
8
|
+
*/
|
|
9
|
+
export declare const ATTR_DB_SYSTEM_NAME = "db.system.name";
|
|
10
|
+
export declare const ATTR_DB_QUERY_TEXT = "db.query.text";
|
|
11
|
+
export declare const ATTR_DB_OPERATION_NAME = "db.operation.name";
|
|
12
|
+
export declare const ATTR_DB_NAMESPACE = "db.namespace";
|
|
13
|
+
export declare const ATTR_DB_COLLECTION_NAME = "db.collection.name";
|
|
14
|
+
export declare const ATTR_SERVER_ADDRESS = "server.address";
|
|
15
|
+
export declare const ATTR_SERVER_PORT = "server.port";
|
|
16
|
+
/**
|
|
17
|
+
* Deprecated attributes - kept for backward compatibility
|
|
18
|
+
* Can be removed once consumers migrate to stable attributes
|
|
19
|
+
*/
|
|
20
|
+
export declare const ATTR_DB_SYSTEM = "db.system";
|
|
21
|
+
export declare const ATTR_DB_STATEMENT = "db.statement";
|
|
22
|
+
export declare const ATTR_DB_OPERATION = "db.operation";
|
|
23
|
+
export declare const ATTR_DB_NAME = "db.name";
|
|
24
|
+
export declare const DEFAULT_CONFIG: ClickHouseInstrumentationConfig;
|
|
25
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAEjE,eAAO,MAAM,WAAW,8BAA8B,CAAA;AACtD,eAAO,MAAM,oBAAoB,0CAA0C,CAAA;AAC3E,eAAO,MAAM,uBAAuB,UAAU,CAAA;AAE9C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AACnD,eAAO,MAAM,kBAAkB,kBAAkB,CAAA;AACjD,eAAO,MAAM,sBAAsB,sBAAsB,CAAA;AACzD,eAAO,MAAM,iBAAiB,iBAAiB,CAAA;AAC/C,eAAO,MAAM,uBAAuB,uBAAuB,CAAA;AAC3D,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AACnD,eAAO,MAAM,gBAAgB,gBAAgB,CAAA;AAE7C;;;GAGG;AACH,eAAO,MAAM,cAAc,cAAc,CAAA;AACzC,eAAO,MAAM,iBAAiB,iBAAiB,CAAA;AAC/C,eAAO,MAAM,iBAAiB,iBAAiB,CAAA;AAC/C,eAAO,MAAM,YAAY,YAAY,CAAA;AAErC,eAAO,MAAM,cAAc,EAAE,+BAI5B,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export const MODULE_NAME = '@clickhouse/client-common';
|
|
2
|
+
export const INSTRUMENTATION_NAME = '@julr/otel-instrumentation-clickhouse';
|
|
3
|
+
export const INSTRUMENTATION_VERSION = '1.0.0';
|
|
4
|
+
/**
|
|
5
|
+
* Stable semantic convention attributes for database spans
|
|
6
|
+
* @see https://opentelemetry.io/docs/specs/semconv/database/database-spans/
|
|
7
|
+
*/
|
|
8
|
+
export const ATTR_DB_SYSTEM_NAME = 'db.system.name';
|
|
9
|
+
export const ATTR_DB_QUERY_TEXT = 'db.query.text';
|
|
10
|
+
export const ATTR_DB_OPERATION_NAME = 'db.operation.name';
|
|
11
|
+
export const ATTR_DB_NAMESPACE = 'db.namespace';
|
|
12
|
+
export const ATTR_DB_COLLECTION_NAME = 'db.collection.name';
|
|
13
|
+
export const ATTR_SERVER_ADDRESS = 'server.address';
|
|
14
|
+
export const ATTR_SERVER_PORT = 'server.port';
|
|
15
|
+
/**
|
|
16
|
+
* Deprecated attributes - kept for backward compatibility
|
|
17
|
+
* Can be removed once consumers migrate to stable attributes
|
|
18
|
+
*/
|
|
19
|
+
export const ATTR_DB_SYSTEM = 'db.system';
|
|
20
|
+
export const ATTR_DB_STATEMENT = 'db.statement';
|
|
21
|
+
export const ATTR_DB_OPERATION = 'db.operation';
|
|
22
|
+
export const ATTR_DB_NAME = 'db.name';
|
|
23
|
+
export const DEFAULT_CONFIG = {
|
|
24
|
+
maxQueryLength: 2048,
|
|
25
|
+
requireParentSpan: false,
|
|
26
|
+
suppressInternalInstrumentation: true,
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,WAAW,GAAG,2BAA2B,CAAA;AACtD,MAAM,CAAC,MAAM,oBAAoB,GAAG,uCAAuC,CAAA;AAC3E,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAA;AAE9C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA;AACnD,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAA;AACjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,mBAAmB,CAAA;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC/C,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAA;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,gBAAgB,CAAA;AACnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA;AAE7C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC/C,MAAM,CAAC,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC/C,MAAM,CAAC,MAAM,YAAY,GAAG,SAAS,CAAA;AAErC,MAAM,CAAC,MAAM,cAAc,GAAoC;IAC7D,cAAc,EAAE,IAAI;IACpB,iBAAiB,EAAE,KAAK;IACxB,+BAA+B,EAAE,IAAI;CACtC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAChE,YAAY,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition } from '@opentelemetry/instrumentation';
|
|
2
|
+
import type { ClickHouseInstrumentationConfig } from './types.js';
|
|
3
|
+
export declare class ClickHouseInstrumentation extends InstrumentationBase<ClickHouseInstrumentationConfig> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(config?: ClickHouseInstrumentationConfig);
|
|
6
|
+
/**
|
|
7
|
+
* Initialize the instrumentation by defining module patches.
|
|
8
|
+
*/
|
|
9
|
+
protected init(): InstrumentationNodeModuleDefinition;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=instrumentation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.d.ts","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EAEpC,MAAM,gCAAgC,CAAA;AAIvC,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,YAAY,CAAA;AAqBjE,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,+BAA+B,CAAC;;gBACrF,MAAM,GAAE,+BAAoC;IAwNxD;;OAEG;IACH,SAAS,CAAC,IAAI;CA8Bf"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { InstrumentationBase, InstrumentationNodeModuleDefinition, isWrapped, } from '@opentelemetry/instrumentation';
|
|
2
|
+
import { suppressTracing } from '@opentelemetry/core';
|
|
3
|
+
import { SpanKind, SpanStatusCode, context, trace } from '@opentelemetry/api';
|
|
4
|
+
import { ATTR_DB_COLLECTION_NAME, ATTR_DB_NAME, ATTR_DB_NAMESPACE, ATTR_DB_OPERATION, ATTR_DB_OPERATION_NAME, ATTR_DB_QUERY_TEXT, ATTR_DB_STATEMENT, ATTR_DB_SYSTEM, ATTR_DB_SYSTEM_NAME, ATTR_SERVER_ADDRESS, ATTR_SERVER_PORT, DEFAULT_CONFIG, INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION, MODULE_NAME, } from './constants.js';
|
|
5
|
+
export class ClickHouseInstrumentation extends InstrumentationBase {
|
|
6
|
+
constructor(config = {}) {
|
|
7
|
+
super(INSTRUMENTATION_NAME, INSTRUMENTATION_VERSION, {
|
|
8
|
+
...DEFAULT_CONFIG,
|
|
9
|
+
...config,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wrap a method on the prototype with instrumentation.
|
|
14
|
+
*/
|
|
15
|
+
#wrapMethod(prototype, methodName, operation) {
|
|
16
|
+
if (isWrapped(prototype[methodName]))
|
|
17
|
+
this._unwrap(prototype, methodName);
|
|
18
|
+
this._wrap(prototype, methodName, this.#createWrapper(operation));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a wrapper function that instruments the original method.
|
|
22
|
+
*/
|
|
23
|
+
#createWrapper(operation) {
|
|
24
|
+
// oxlint-disable-next-line no-this-alias
|
|
25
|
+
const instrumentation = this;
|
|
26
|
+
return function wrapper(original) {
|
|
27
|
+
return function (params) {
|
|
28
|
+
const config = instrumentation.getConfig();
|
|
29
|
+
const parentSpan = trace.getSpan(context.active());
|
|
30
|
+
if (config.requireParentSpan && !parentSpan)
|
|
31
|
+
return original.apply(this, arguments);
|
|
32
|
+
const tableName = instrumentation.#extractTableName(params, operation);
|
|
33
|
+
const queryText = instrumentation.#extractQueryText(params, operation);
|
|
34
|
+
const spanName = tableName
|
|
35
|
+
? `clickhouse.${operation} ${tableName}`
|
|
36
|
+
: `clickhouse.${operation}`;
|
|
37
|
+
const attributes = instrumentation.#buildAttributes({
|
|
38
|
+
client: this,
|
|
39
|
+
operation,
|
|
40
|
+
tableName,
|
|
41
|
+
queryText,
|
|
42
|
+
});
|
|
43
|
+
const span = instrumentation.tracer.startSpan(spanName, {
|
|
44
|
+
kind: SpanKind.CLIENT,
|
|
45
|
+
attributes,
|
|
46
|
+
});
|
|
47
|
+
const spanContext = trace.setSpan(context.active(), span);
|
|
48
|
+
return context.with(spanContext, () => {
|
|
49
|
+
const result = instrumentation.#callOriginalFunction(original, this, arguments);
|
|
50
|
+
if (result && typeof result.then === 'function') {
|
|
51
|
+
return result.then((res) => {
|
|
52
|
+
instrumentation.#endSpan(span, null);
|
|
53
|
+
return res;
|
|
54
|
+
}, (err) => {
|
|
55
|
+
instrumentation.#endSpan(span, err);
|
|
56
|
+
throw err;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
instrumentation.#endSpan(span, null);
|
|
60
|
+
return result;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Extract the table/collection name from params.
|
|
67
|
+
*
|
|
68
|
+
* For `insert` operations, we use `params.table` directly (clean approach).
|
|
69
|
+
* For other operations (`query`, `command`, `exec`), the ClickHouse client
|
|
70
|
+
* only provides raw SQL strings, so we fall back to regex parsing.
|
|
71
|
+
*/
|
|
72
|
+
#extractTableName(params, operation) {
|
|
73
|
+
if (!params)
|
|
74
|
+
return null;
|
|
75
|
+
if (operation === 'insert' && 'table' in params && params.table)
|
|
76
|
+
return params.table.trim();
|
|
77
|
+
if ('query' in params && params.query)
|
|
78
|
+
return this.#parseTableFromQuery(params.query);
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Extract a displayable query text from the params.
|
|
83
|
+
*/
|
|
84
|
+
#extractQueryText(params, operation) {
|
|
85
|
+
if (!params)
|
|
86
|
+
return operation;
|
|
87
|
+
if ('query' in params && params.query)
|
|
88
|
+
return this.#normalizeQuery(params.query);
|
|
89
|
+
if ('table' in params && params.table)
|
|
90
|
+
return `INSERT INTO ${params.table}`;
|
|
91
|
+
return operation;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Normalize query text by collapsing excessive whitespace.
|
|
95
|
+
*/
|
|
96
|
+
#normalizeQuery(query) {
|
|
97
|
+
return query.replace(/\s+/g, ' ').trim();
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Parse table name from SQL query string.
|
|
101
|
+
* This is a best-effort extraction for common SQL patterns.
|
|
102
|
+
*/
|
|
103
|
+
#parseTableFromQuery(query) {
|
|
104
|
+
if (!query)
|
|
105
|
+
return null;
|
|
106
|
+
const normalized = query.trim().toUpperCase();
|
|
107
|
+
const fromMatch = query.match(/\bFROM\s+([`"]?[\w.]+[`"]?)/i);
|
|
108
|
+
if (fromMatch)
|
|
109
|
+
return fromMatch[1].replace(/[`"]/g, '');
|
|
110
|
+
const insertMatch = query.match(/\bINSERT\s+INTO\s+([`"]?[\w.]+[`"]?)/i);
|
|
111
|
+
if (insertMatch)
|
|
112
|
+
return insertMatch[1].replace(/[`"]/g, '');
|
|
113
|
+
if (normalized.startsWith('UPDATE')) {
|
|
114
|
+
const updateMatch = query.match(/\bUPDATE\s+([`"]?[\w.]+[`"]?)/i);
|
|
115
|
+
if (updateMatch)
|
|
116
|
+
return updateMatch[1].replace(/[`"]/g, '');
|
|
117
|
+
}
|
|
118
|
+
if (normalized.startsWith('DELETE')) {
|
|
119
|
+
const deleteMatch = query.match(/\bDELETE\s+FROM\s+([`"]?[\w.]+[`"]?)/i);
|
|
120
|
+
if (deleteMatch)
|
|
121
|
+
return deleteMatch[1].replace(/[`"]/g, '');
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Build span attributes from the client and operation context.
|
|
127
|
+
*/
|
|
128
|
+
#buildAttributes(options) {
|
|
129
|
+
const { client, operation, tableName, queryText } = options;
|
|
130
|
+
const config = this.getConfig();
|
|
131
|
+
const maxQueryLength = config.maxQueryLength ?? 2048;
|
|
132
|
+
const attributes = {
|
|
133
|
+
[ATTR_DB_SYSTEM_NAME]: 'clickhouse',
|
|
134
|
+
[ATTR_DB_OPERATION_NAME]: operation,
|
|
135
|
+
[ATTR_DB_SYSTEM]: 'clickhouse',
|
|
136
|
+
[ATTR_DB_OPERATION]: operation,
|
|
137
|
+
};
|
|
138
|
+
if (tableName)
|
|
139
|
+
attributes[ATTR_DB_COLLECTION_NAME] = tableName;
|
|
140
|
+
if (maxQueryLength > 0 && queryText) {
|
|
141
|
+
const truncatedQuery = queryText.length > maxQueryLength
|
|
142
|
+
? queryText.substring(0, maxQueryLength) + '...'
|
|
143
|
+
: queryText;
|
|
144
|
+
attributes[ATTR_DB_QUERY_TEXT] = truncatedQuery;
|
|
145
|
+
attributes[ATTR_DB_STATEMENT] = truncatedQuery;
|
|
146
|
+
}
|
|
147
|
+
if (client.connectionParams) {
|
|
148
|
+
const url = client.connectionParams.url;
|
|
149
|
+
if (url) {
|
|
150
|
+
attributes[ATTR_SERVER_ADDRESS] = url.hostname;
|
|
151
|
+
if (url.port)
|
|
152
|
+
attributes[ATTR_SERVER_PORT] = Number.parseInt(url.port, 10);
|
|
153
|
+
}
|
|
154
|
+
if (client.connectionParams.database) {
|
|
155
|
+
attributes[ATTR_DB_NAMESPACE] = client.connectionParams.database;
|
|
156
|
+
attributes[ATTR_DB_NAME] = client.connectionParams.database;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return attributes;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Call the original function, optionally suppressing HTTP instrumentation.
|
|
163
|
+
*/
|
|
164
|
+
#callOriginalFunction(original, thisArg, args) {
|
|
165
|
+
const config = this.getConfig();
|
|
166
|
+
if (config.suppressInternalInstrumentation) {
|
|
167
|
+
return context.with(suppressTracing(context.active()), () => original.apply(thisArg, args));
|
|
168
|
+
}
|
|
169
|
+
return original.apply(thisArg, args);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* End a span with either success or error status.
|
|
173
|
+
*/
|
|
174
|
+
#endSpan(span, error) {
|
|
175
|
+
if (error) {
|
|
176
|
+
span.recordException(error);
|
|
177
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
181
|
+
}
|
|
182
|
+
span.end();
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Initialize the instrumentation by defining module patches.
|
|
186
|
+
*/
|
|
187
|
+
init() {
|
|
188
|
+
return new InstrumentationNodeModuleDefinition(MODULE_NAME, ['>=1.0.0'], (moduleExports) => {
|
|
189
|
+
const ClickHouseClientClass = moduleExports.ClickHouseClient;
|
|
190
|
+
if (!ClickHouseClientClass?.prototype)
|
|
191
|
+
return moduleExports;
|
|
192
|
+
this.#wrapMethod(ClickHouseClientClass.prototype, 'query', 'query');
|
|
193
|
+
this.#wrapMethod(ClickHouseClientClass.prototype, 'insert', 'insert');
|
|
194
|
+
this.#wrapMethod(ClickHouseClientClass.prototype, 'command', 'command');
|
|
195
|
+
this.#wrapMethod(ClickHouseClientClass.prototype, 'exec', 'exec');
|
|
196
|
+
return moduleExports;
|
|
197
|
+
}, (moduleExports) => {
|
|
198
|
+
const ClickHouseClientClass = moduleExports.ClickHouseClient;
|
|
199
|
+
if (!ClickHouseClientClass?.prototype)
|
|
200
|
+
return moduleExports;
|
|
201
|
+
this._unwrap(ClickHouseClientClass.prototype, 'query');
|
|
202
|
+
this._unwrap(ClickHouseClientClass.prototype, 'insert');
|
|
203
|
+
this._unwrap(ClickHouseClientClass.prototype, 'command');
|
|
204
|
+
this._unwrap(ClickHouseClientClass.prototype, 'exec');
|
|
205
|
+
return moduleExports;
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=instrumentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentation.js","sourceRoot":"","sources":["../../src/instrumentation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,mCAAmC,EACnC,SAAS,GACV,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAK7E,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,i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,CAAC,qBAAqB,EAAE,SAAS;gBAAE,OAAO,aAAa,CAAA;YAE3D,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;YACtD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;YACvD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;YACxD,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAA;YAErD,OAAO,aAAa,CAAA;QACtB,CAAC,CACF,CAAA;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal representation of the ClickHouse client instance.
|
|
3
|
+
* Used for accessing connection parameters during instrumentation.
|
|
4
|
+
*/
|
|
5
|
+
export interface ClickHouseClient {
|
|
6
|
+
connectionParams?: {
|
|
7
|
+
url?: URL;
|
|
8
|
+
database?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parameters for query, command, and exec operations.
|
|
13
|
+
*/
|
|
14
|
+
export interface QueryParams {
|
|
15
|
+
query?: string;
|
|
16
|
+
query_id?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Parameters for insert operations.
|
|
20
|
+
* Extends QueryParams with table name support.
|
|
21
|
+
*/
|
|
22
|
+
export interface InsertParams extends QueryParams {
|
|
23
|
+
table?: string;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=internal_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal_types.d.ts","sourceRoot":"","sources":["../../src/internal_types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE;QACjB,GAAG,CAAC,EAAE,GAAG,CAAA;QACT,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal_types.js","sourceRoot":"","sources":["../../src/internal_types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for ClickHouse instrumentation.
|
|
4
|
+
*/
|
|
5
|
+
export interface ClickHouseInstrumentationConfig extends InstrumentationConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Maximum length of the query to include in the span.
|
|
8
|
+
* Queries longer than this will be truncated.
|
|
9
|
+
* Set to 0 to disable query capture.
|
|
10
|
+
* @default 2048
|
|
11
|
+
*/
|
|
12
|
+
maxQueryLength?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to require a parent span to create child spans.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
requireParentSpan?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether to suppress internal HTTP instrumentation.
|
|
20
|
+
* When true, the HTTP spans for ClickHouse requests will not be created
|
|
21
|
+
* by @opentelemetry/instrumentation-http, avoiding duplicate spans.
|
|
22
|
+
* @default true
|
|
23
|
+
*/
|
|
24
|
+
suppressInternalInstrumentation?: boolean;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAA;AAE3E;;GAEG;AACH,MAAM,WAAW,+BAAgC,SAAQ,qBAAqB;IAC5E;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;;OAKG;IACH,+BAA+B,CAAC,EAAE,OAAO,CAAA;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@julr/otel-instrumentation-clickhouse",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OpenTelemetry automatic instrumentation for ClickHouse client",
|
|
5
|
-
"main": "./
|
|
6
|
-
"module": "./
|
|
7
|
-
"types": "./
|
|
5
|
+
"main": "./build/src/index.js",
|
|
6
|
+
"module": "./build/src/index.js",
|
|
7
|
+
"types": "./build/src/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"import": "./
|
|
12
|
-
"types": "./
|
|
11
|
+
"import": "./build/src/index.js",
|
|
12
|
+
"types": "./build/src/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
-
"
|
|
16
|
+
"build"
|
|
17
17
|
],
|
|
18
18
|
"scripts": {
|
|
19
19
|
"build": "tsc",
|