@ogcio/o11y-sdk-node 0.1.0-beta.2 → 0.1.0-beta.3
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/CHANGELOG.md +7 -0
- package/README.md +96 -10
- package/index.ts +2 -0
- package/lib/console.ts +15 -0
- package/lib/grpc.ts +4 -4
- package/lib/http.ts +4 -4
- package/lib/index.ts +2 -2
- package/lib/instrumentation.node.ts +9 -1
- package/lib/metrics.ts +70 -0
- package/lib/options.ts +2 -3
- package/package.json +22 -22
- package/test/metrics.test.ts +142 -0
- package/test/node-config.test.ts +35 -9
- package/test/validation.test.ts +31 -0
- package/tsconfig.json +2 -1
- package/coverage/cobertura-coverage.xml +0 -199
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -131
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sdk-node/index.html +0 -116
- package/coverage/lcov-report/sdk-node/index.ts.html +0 -106
- package/coverage/lcov-report/sdk-node/lib/grpc.ts.html +0 -178
- package/coverage/lcov-report/sdk-node/lib/http.ts.html +0 -190
- package/coverage/lcov-report/sdk-node/lib/index.html +0 -191
- package/coverage/lcov-report/sdk-node/lib/index.ts.html +0 -265
- package/coverage/lcov-report/sdk-node/lib/instrumentation.node.ts.html +0 -310
- package/coverage/lcov-report/sdk-node/lib/options.ts.html +0 -109
- package/coverage/lcov-report/sdk-node/lib/utils.ts.html +0 -115
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov.info +0 -206
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -2
- package/dist/lib/grpc.d.ts +0 -3
- package/dist/lib/grpc.js +0 -26
- package/dist/lib/http.d.ts +0 -3
- package/dist/lib/http.js +0 -29
- package/dist/lib/index.d.ts +0 -46
- package/dist/lib/index.js +0 -1
- package/dist/lib/instrumentation.node.d.ts +0 -3
- package/dist/lib/instrumentation.node.js +0 -53
- package/dist/lib/options.d.ts +0 -7
- package/dist/lib/options.js +0 -1
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.js +0 -5
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -25
- package/test-report.xml +0 -39
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
var addSorting = (function() {
|
|
3
|
-
'use strict';
|
|
4
|
-
var cols,
|
|
5
|
-
currentSort = {
|
|
6
|
-
index: 0,
|
|
7
|
-
desc: false
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
// returns the summary table element
|
|
11
|
-
function getTable() {
|
|
12
|
-
return document.querySelector('.coverage-summary');
|
|
13
|
-
}
|
|
14
|
-
// returns the thead element of the summary table
|
|
15
|
-
function getTableHeader() {
|
|
16
|
-
return getTable().querySelector('thead tr');
|
|
17
|
-
}
|
|
18
|
-
// returns the tbody element of the summary table
|
|
19
|
-
function getTableBody() {
|
|
20
|
-
return getTable().querySelector('tbody');
|
|
21
|
-
}
|
|
22
|
-
// returns the th element for nth column
|
|
23
|
-
function getNthColumn(n) {
|
|
24
|
-
return getTableHeader().querySelectorAll('th')[n];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function onFilterInput() {
|
|
28
|
-
const searchValue = document.getElementById('fileSearch').value;
|
|
29
|
-
const rows = document.getElementsByTagName('tbody')[0].children;
|
|
30
|
-
for (let i = 0; i < rows.length; i++) {
|
|
31
|
-
const row = rows[i];
|
|
32
|
-
if (
|
|
33
|
-
row.textContent
|
|
34
|
-
.toLowerCase()
|
|
35
|
-
.includes(searchValue.toLowerCase())
|
|
36
|
-
) {
|
|
37
|
-
row.style.display = '';
|
|
38
|
-
} else {
|
|
39
|
-
row.style.display = 'none';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// loads the search box
|
|
45
|
-
function addSearchBox() {
|
|
46
|
-
var template = document.getElementById('filterTemplate');
|
|
47
|
-
var templateClone = template.content.cloneNode(true);
|
|
48
|
-
templateClone.getElementById('fileSearch').oninput = onFilterInput;
|
|
49
|
-
template.parentElement.appendChild(templateClone);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// loads all columns
|
|
53
|
-
function loadColumns() {
|
|
54
|
-
var colNodes = getTableHeader().querySelectorAll('th'),
|
|
55
|
-
colNode,
|
|
56
|
-
cols = [],
|
|
57
|
-
col,
|
|
58
|
-
i;
|
|
59
|
-
|
|
60
|
-
for (i = 0; i < colNodes.length; i += 1) {
|
|
61
|
-
colNode = colNodes[i];
|
|
62
|
-
col = {
|
|
63
|
-
key: colNode.getAttribute('data-col'),
|
|
64
|
-
sortable: !colNode.getAttribute('data-nosort'),
|
|
65
|
-
type: colNode.getAttribute('data-type') || 'string'
|
|
66
|
-
};
|
|
67
|
-
cols.push(col);
|
|
68
|
-
if (col.sortable) {
|
|
69
|
-
col.defaultDescSort = col.type === 'number';
|
|
70
|
-
colNode.innerHTML =
|
|
71
|
-
colNode.innerHTML + '<span class="sorter"></span>';
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return cols;
|
|
75
|
-
}
|
|
76
|
-
// attaches a data attribute to every tr element with an object
|
|
77
|
-
// of data values keyed by column name
|
|
78
|
-
function loadRowData(tableRow) {
|
|
79
|
-
var tableCols = tableRow.querySelectorAll('td'),
|
|
80
|
-
colNode,
|
|
81
|
-
col,
|
|
82
|
-
data = {},
|
|
83
|
-
i,
|
|
84
|
-
val;
|
|
85
|
-
for (i = 0; i < tableCols.length; i += 1) {
|
|
86
|
-
colNode = tableCols[i];
|
|
87
|
-
col = cols[i];
|
|
88
|
-
val = colNode.getAttribute('data-value');
|
|
89
|
-
if (col.type === 'number') {
|
|
90
|
-
val = Number(val);
|
|
91
|
-
}
|
|
92
|
-
data[col.key] = val;
|
|
93
|
-
}
|
|
94
|
-
return data;
|
|
95
|
-
}
|
|
96
|
-
// loads all row data
|
|
97
|
-
function loadData() {
|
|
98
|
-
var rows = getTableBody().querySelectorAll('tr'),
|
|
99
|
-
i;
|
|
100
|
-
|
|
101
|
-
for (i = 0; i < rows.length; i += 1) {
|
|
102
|
-
rows[i].data = loadRowData(rows[i]);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
// sorts the table using the data for the ith column
|
|
106
|
-
function sortByIndex(index, desc) {
|
|
107
|
-
var key = cols[index].key,
|
|
108
|
-
sorter = function(a, b) {
|
|
109
|
-
a = a.data[key];
|
|
110
|
-
b = b.data[key];
|
|
111
|
-
return a < b ? -1 : a > b ? 1 : 0;
|
|
112
|
-
},
|
|
113
|
-
finalSorter = sorter,
|
|
114
|
-
tableBody = document.querySelector('.coverage-summary tbody'),
|
|
115
|
-
rowNodes = tableBody.querySelectorAll('tr'),
|
|
116
|
-
rows = [],
|
|
117
|
-
i;
|
|
118
|
-
|
|
119
|
-
if (desc) {
|
|
120
|
-
finalSorter = function(a, b) {
|
|
121
|
-
return -1 * sorter(a, b);
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
for (i = 0; i < rowNodes.length; i += 1) {
|
|
126
|
-
rows.push(rowNodes[i]);
|
|
127
|
-
tableBody.removeChild(rowNodes[i]);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
rows.sort(finalSorter);
|
|
131
|
-
|
|
132
|
-
for (i = 0; i < rows.length; i += 1) {
|
|
133
|
-
tableBody.appendChild(rows[i]);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
// removes sort indicators for current column being sorted
|
|
137
|
-
function removeSortIndicators() {
|
|
138
|
-
var col = getNthColumn(currentSort.index),
|
|
139
|
-
cls = col.className;
|
|
140
|
-
|
|
141
|
-
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
|
142
|
-
col.className = cls;
|
|
143
|
-
}
|
|
144
|
-
// adds sort indicators for current column being sorted
|
|
145
|
-
function addSortIndicators() {
|
|
146
|
-
getNthColumn(currentSort.index).className += currentSort.desc
|
|
147
|
-
? ' sorted-desc'
|
|
148
|
-
: ' sorted';
|
|
149
|
-
}
|
|
150
|
-
// adds event listeners for all sorter widgets
|
|
151
|
-
function enableUI() {
|
|
152
|
-
var i,
|
|
153
|
-
el,
|
|
154
|
-
ithSorter = function ithSorter(i) {
|
|
155
|
-
var col = cols[i];
|
|
156
|
-
|
|
157
|
-
return function() {
|
|
158
|
-
var desc = col.defaultDescSort;
|
|
159
|
-
|
|
160
|
-
if (currentSort.index === i) {
|
|
161
|
-
desc = !currentSort.desc;
|
|
162
|
-
}
|
|
163
|
-
sortByIndex(i, desc);
|
|
164
|
-
removeSortIndicators();
|
|
165
|
-
currentSort.index = i;
|
|
166
|
-
currentSort.desc = desc;
|
|
167
|
-
addSortIndicators();
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
for (i = 0; i < cols.length; i += 1) {
|
|
171
|
-
if (cols[i].sortable) {
|
|
172
|
-
// add the click event handler on the th so users
|
|
173
|
-
// dont have to click on those tiny arrows
|
|
174
|
-
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
|
175
|
-
if (el.addEventListener) {
|
|
176
|
-
el.addEventListener('click', ithSorter(i));
|
|
177
|
-
} else {
|
|
178
|
-
el.attachEvent('onclick', ithSorter(i));
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// adds sorting functionality to the UI
|
|
184
|
-
return function() {
|
|
185
|
-
if (!getTable()) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
cols = loadColumns();
|
|
189
|
-
loadData();
|
|
190
|
-
addSearchBox();
|
|
191
|
-
addSortIndicators();
|
|
192
|
-
enableUI();
|
|
193
|
-
};
|
|
194
|
-
})();
|
|
195
|
-
|
|
196
|
-
window.addEventListener('load', addSorting);
|
package/coverage/lcov.info
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
TN:
|
|
2
|
-
SF:index.ts
|
|
3
|
-
FNF:0
|
|
4
|
-
FNH:0
|
|
5
|
-
DA:1,1
|
|
6
|
-
LF:1
|
|
7
|
-
LH:1
|
|
8
|
-
BRF:0
|
|
9
|
-
BRH:0
|
|
10
|
-
end_of_record
|
|
11
|
-
TN:
|
|
12
|
-
SF:lib/grpc.ts
|
|
13
|
-
FN:10,buildGrpcExporters
|
|
14
|
-
FNF:1
|
|
15
|
-
FNH:1
|
|
16
|
-
FNDA:2,buildGrpcExporters
|
|
17
|
-
DA:1,1
|
|
18
|
-
DA:10,2
|
|
19
|
-
DA:11,2
|
|
20
|
-
DA:12,2
|
|
21
|
-
DA:13,2
|
|
22
|
-
DA:14,2
|
|
23
|
-
DA:15,2
|
|
24
|
-
DA:16,2
|
|
25
|
-
DA:17,2
|
|
26
|
-
DA:18,2
|
|
27
|
-
DA:19,2
|
|
28
|
-
DA:20,2
|
|
29
|
-
DA:21,2
|
|
30
|
-
DA:22,2
|
|
31
|
-
DA:23,2
|
|
32
|
-
DA:24,2
|
|
33
|
-
DA:25,2
|
|
34
|
-
DA:26,2
|
|
35
|
-
DA:27,2
|
|
36
|
-
DA:28,2
|
|
37
|
-
DA:29,2
|
|
38
|
-
DA:30,2
|
|
39
|
-
DA:31,2
|
|
40
|
-
LF:23
|
|
41
|
-
LH:23
|
|
42
|
-
BRDA:10,0,0,2
|
|
43
|
-
BRDA:23,1,0,1
|
|
44
|
-
BRF:2
|
|
45
|
-
BRH:2
|
|
46
|
-
end_of_record
|
|
47
|
-
TN:
|
|
48
|
-
SF:lib/http.ts
|
|
49
|
-
FN:10,buildHttpExporters
|
|
50
|
-
FNF:1
|
|
51
|
-
FNH:1
|
|
52
|
-
FNDA:2,buildHttpExporters
|
|
53
|
-
DA:1,1
|
|
54
|
-
DA:10,2
|
|
55
|
-
DA:11,2
|
|
56
|
-
DA:12,1
|
|
57
|
-
DA:13,1
|
|
58
|
-
DA:15,2
|
|
59
|
-
DA:16,2
|
|
60
|
-
DA:17,2
|
|
61
|
-
DA:18,2
|
|
62
|
-
DA:19,2
|
|
63
|
-
DA:20,2
|
|
64
|
-
DA:21,2
|
|
65
|
-
DA:22,2
|
|
66
|
-
DA:23,2
|
|
67
|
-
DA:24,2
|
|
68
|
-
DA:25,2
|
|
69
|
-
DA:26,2
|
|
70
|
-
DA:27,2
|
|
71
|
-
DA:28,2
|
|
72
|
-
DA:29,2
|
|
73
|
-
DA:30,2
|
|
74
|
-
DA:31,2
|
|
75
|
-
DA:32,2
|
|
76
|
-
DA:33,2
|
|
77
|
-
DA:34,2
|
|
78
|
-
DA:35,2
|
|
79
|
-
LF:26
|
|
80
|
-
LH:26
|
|
81
|
-
BRDA:10,0,0,2
|
|
82
|
-
BRDA:11,1,0,1
|
|
83
|
-
BRF:2
|
|
84
|
-
BRH:2
|
|
85
|
-
end_of_record
|
|
86
|
-
TN:
|
|
87
|
-
SF:lib/index.ts
|
|
88
|
-
FN:1,(empty-report)
|
|
89
|
-
FNF:1
|
|
90
|
-
FNH:1
|
|
91
|
-
FNDA:1,(empty-report)
|
|
92
|
-
LF:0
|
|
93
|
-
LH:0
|
|
94
|
-
BRDA:1,0,0,1
|
|
95
|
-
BRF:1
|
|
96
|
-
BRH:1
|
|
97
|
-
end_of_record
|
|
98
|
-
TN:
|
|
99
|
-
SF:lib/instrumentation.node.ts
|
|
100
|
-
FN:11,buildNodeInstrumentation
|
|
101
|
-
FNF:1
|
|
102
|
-
FNH:1
|
|
103
|
-
FNDA:6,buildNodeInstrumentation
|
|
104
|
-
DA:1,1
|
|
105
|
-
DA:11,6
|
|
106
|
-
DA:12,6
|
|
107
|
-
DA:13,6
|
|
108
|
-
DA:14,6
|
|
109
|
-
DA:15,1
|
|
110
|
-
DA:16,1
|
|
111
|
-
DA:17,1
|
|
112
|
-
DA:18,1
|
|
113
|
-
DA:19,1
|
|
114
|
-
DA:21,6
|
|
115
|
-
DA:22,1
|
|
116
|
-
DA:23,1
|
|
117
|
-
DA:24,1
|
|
118
|
-
DA:25,1
|
|
119
|
-
DA:26,1
|
|
120
|
-
DA:28,4
|
|
121
|
-
DA:29,1
|
|
122
|
-
DA:30,1
|
|
123
|
-
DA:31,1
|
|
124
|
-
DA:32,1
|
|
125
|
-
DA:33,1
|
|
126
|
-
DA:35,3
|
|
127
|
-
DA:37,3
|
|
128
|
-
DA:38,1
|
|
129
|
-
DA:39,3
|
|
130
|
-
DA:40,2
|
|
131
|
-
DA:41,2
|
|
132
|
-
DA:43,3
|
|
133
|
-
DA:44,3
|
|
134
|
-
DA:45,3
|
|
135
|
-
DA:46,3
|
|
136
|
-
DA:47,3
|
|
137
|
-
DA:48,0
|
|
138
|
-
DA:49,6
|
|
139
|
-
DA:51,6
|
|
140
|
-
DA:52,6
|
|
141
|
-
DA:53,6
|
|
142
|
-
DA:54,6
|
|
143
|
-
DA:55,6
|
|
144
|
-
DA:56,6
|
|
145
|
-
DA:57,6
|
|
146
|
-
DA:58,6
|
|
147
|
-
DA:59,6
|
|
148
|
-
DA:60,6
|
|
149
|
-
DA:61,6
|
|
150
|
-
DA:62,6
|
|
151
|
-
DA:63,6
|
|
152
|
-
DA:64,6
|
|
153
|
-
DA:66,6
|
|
154
|
-
DA:67,6
|
|
155
|
-
DA:68,6
|
|
156
|
-
DA:69,6
|
|
157
|
-
DA:70,0
|
|
158
|
-
DA:71,0
|
|
159
|
-
DA:72,0
|
|
160
|
-
DA:73,0
|
|
161
|
-
DA:74,0
|
|
162
|
-
DA:75,6
|
|
163
|
-
LF:59
|
|
164
|
-
LH:53
|
|
165
|
-
BRDA:11,0,0,6
|
|
166
|
-
BRDA:14,1,0,1
|
|
167
|
-
BRDA:19,2,0,5
|
|
168
|
-
BRDA:21,3,0,4
|
|
169
|
-
BRDA:21,4,0,1
|
|
170
|
-
BRDA:28,5,0,1
|
|
171
|
-
BRDA:33,6,0,3
|
|
172
|
-
BRDA:37,7,0,1
|
|
173
|
-
BRDA:39,8,0,2
|
|
174
|
-
BRDA:47,9,0,0
|
|
175
|
-
BRDA:60,10,0,3
|
|
176
|
-
BRDA:69,11,0,0
|
|
177
|
-
BRF:12
|
|
178
|
-
BRH:10
|
|
179
|
-
end_of_record
|
|
180
|
-
TN:
|
|
181
|
-
SF:lib/options.ts
|
|
182
|
-
FN:1,(empty-report)
|
|
183
|
-
FNF:1
|
|
184
|
-
FNH:1
|
|
185
|
-
FNDA:1,(empty-report)
|
|
186
|
-
LF:0
|
|
187
|
-
LH:0
|
|
188
|
-
BRDA:1,0,0,1
|
|
189
|
-
BRF:1
|
|
190
|
-
BRH:1
|
|
191
|
-
end_of_record
|
|
192
|
-
TN:
|
|
193
|
-
SF:lib/utils.ts
|
|
194
|
-
FNF:0
|
|
195
|
-
FNH:0
|
|
196
|
-
DA:1,1
|
|
197
|
-
DA:4,1
|
|
198
|
-
DA:7,1
|
|
199
|
-
DA:8,1
|
|
200
|
-
DA:9,1
|
|
201
|
-
DA:10,1
|
|
202
|
-
LF:6
|
|
203
|
-
LH:6
|
|
204
|
-
BRF:0
|
|
205
|
-
BRH:0
|
|
206
|
-
end_of_record
|
package/dist/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
-
import type { NodeSDKConfig } from "./lib/index.js";
|
|
3
|
-
import buildNodeInstrumentation from "./lib/instrumentation.node.js";
|
|
4
|
-
export type * from "./lib/index.js";
|
|
5
|
-
export type { NodeSDKConfig, NodeSDK };
|
|
6
|
-
export { buildNodeInstrumentation as instrumentNode };
|
package/dist/index.js
DELETED
package/dist/lib/grpc.d.ts
DELETED
package/dist/lib/grpc.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { LogRecordProcessorMap } from "./utils.js";
|
|
2
|
-
import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
|
|
3
|
-
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
4
|
-
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
|
|
5
|
-
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
|
|
6
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
|
|
7
|
-
export default function buildGrpcExporters(config) {
|
|
8
|
-
return {
|
|
9
|
-
traces: new OTLPTraceExporter({
|
|
10
|
-
url: `${config.collectorUrl}`,
|
|
11
|
-
compression: CompressionAlgorithm.GZIP,
|
|
12
|
-
}),
|
|
13
|
-
metrics: new PeriodicExportingMetricReader({
|
|
14
|
-
exporter: new OTLPMetricExporter({
|
|
15
|
-
url: `${config.collectorUrl}`,
|
|
16
|
-
compression: CompressionAlgorithm.GZIP,
|
|
17
|
-
}),
|
|
18
|
-
}),
|
|
19
|
-
logs: [
|
|
20
|
-
new LogRecordProcessorMap[config.collectorMode ?? "batch"](new OTLPLogExporter({
|
|
21
|
-
url: `${config.collectorUrl}`,
|
|
22
|
-
compression: CompressionAlgorithm.GZIP,
|
|
23
|
-
})),
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
}
|
package/dist/lib/http.d.ts
DELETED
package/dist/lib/http.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
2
|
-
import { LogRecordProcessorMap } from "./utils.js";
|
|
3
|
-
import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
|
|
4
|
-
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
5
|
-
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
6
|
-
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
7
|
-
export default function buildHttpExporters(config) {
|
|
8
|
-
if (config.collectorUrl.endsWith("/")) {
|
|
9
|
-
config.collectorUrl = config.collectorUrl.slice(0, -1);
|
|
10
|
-
}
|
|
11
|
-
return {
|
|
12
|
-
traces: new OTLPTraceExporter({
|
|
13
|
-
url: `${config.collectorUrl}/v1/traces`,
|
|
14
|
-
compression: CompressionAlgorithm.GZIP,
|
|
15
|
-
}),
|
|
16
|
-
metrics: new PeriodicExportingMetricReader({
|
|
17
|
-
exporter: new OTLPMetricExporter({
|
|
18
|
-
url: `${config.collectorUrl}/v1/metrics`,
|
|
19
|
-
compression: CompressionAlgorithm.GZIP,
|
|
20
|
-
}),
|
|
21
|
-
}),
|
|
22
|
-
logs: [
|
|
23
|
-
new LogRecordProcessorMap[config.collectorMode ?? "batch"](new OTLPLogExporter({
|
|
24
|
-
url: `${config.collectorUrl}/v1/logs`,
|
|
25
|
-
compression: CompressionAlgorithm.GZIP,
|
|
26
|
-
})),
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
|
-
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
interface SDKConfig {
|
|
2
|
-
/**
|
|
3
|
-
* The opentelemetry collector entrypoint GRPC url.
|
|
4
|
-
* If the collectoUrl is null or undefined, the instrumentation will not be activated.
|
|
5
|
-
* @example http://alloy:4317
|
|
6
|
-
*/
|
|
7
|
-
collectorUrl: string;
|
|
8
|
-
/**
|
|
9
|
-
* Name of your application used for the collector to group logs
|
|
10
|
-
*/
|
|
11
|
-
serviceName?: string;
|
|
12
|
-
/**
|
|
13
|
-
* Diagnostic log level for the internal runtime instrumentation
|
|
14
|
-
*
|
|
15
|
-
* @type string
|
|
16
|
-
* @default INFO
|
|
17
|
-
*/
|
|
18
|
-
diagLogLevel?: SDKLogLevel;
|
|
19
|
-
/**
|
|
20
|
-
* Collector signals processing mode.
|
|
21
|
-
* signle: makes an http/grpc request for each signal and it is immediately processed inside grafana
|
|
22
|
-
* batch: sends multiple signals within a time window, optimized to reduce http/grpc calls in production
|
|
23
|
-
*
|
|
24
|
-
* @type string
|
|
25
|
-
* @default batch
|
|
26
|
-
*/
|
|
27
|
-
collectorMode?: SDKCollectorMode;
|
|
28
|
-
}
|
|
29
|
-
export interface NodeSDKConfig extends SDKConfig {
|
|
30
|
-
/**
|
|
31
|
-
* Flag to enable or disable the tracing for node:fs module
|
|
32
|
-
*
|
|
33
|
-
* @default false disabling `instrumentation-fs` because it bloating the traces
|
|
34
|
-
*/
|
|
35
|
-
enableFS?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* http based connection protocol used to send signals.
|
|
38
|
-
*
|
|
39
|
-
* @default grpc
|
|
40
|
-
*/
|
|
41
|
-
protocol?: SDKProtocol;
|
|
42
|
-
}
|
|
43
|
-
export type SDKCollectorMode = "single" | "batch";
|
|
44
|
-
export type SDKProtocol = "grpc" | "http";
|
|
45
|
-
export type SDKLogLevel = "NONE" | "ERROR" | "WARN" | "INFO" | "DEBUG" | "VERBOSE" | "ALL";
|
|
46
|
-
export {};
|
package/dist/lib/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { NodeSDK } from "@opentelemetry/sdk-node";
|
|
2
|
-
import isUrl from "is-url";
|
|
3
|
-
import buildHttpExporters from "./http.js";
|
|
4
|
-
import buildGrpcExporters from "./grpc.js";
|
|
5
|
-
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
|
|
6
|
-
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
7
|
-
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
8
|
-
export default function buildNodeInstrumentation(config) {
|
|
9
|
-
if (!config) {
|
|
10
|
-
console.warn("observability config not set. Skipping NodeJS OpenTelemetry instrumentation.");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (!config.collectorUrl) {
|
|
14
|
-
console.warn("collectorUrl not set. Skipping NodeJS OpenTelemetry instrumentation.");
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (!isUrl(config.collectorUrl)) {
|
|
18
|
-
console.error("collectorUrl does not use a valid format. Skipping NodeJS OpenTelemetry instrumentation.");
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
let exporter;
|
|
22
|
-
if (config.protocol === "http") {
|
|
23
|
-
exporter = buildHttpExporters(config);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
exporter = buildGrpcExporters(config);
|
|
27
|
-
}
|
|
28
|
-
try {
|
|
29
|
-
diag.setLogger(new DiagConsoleLogger(), config.diagLogLevel
|
|
30
|
-
? DiagLogLevel[config.diagLogLevel]
|
|
31
|
-
: DiagLogLevel.INFO);
|
|
32
|
-
const sdk = new NodeSDK({
|
|
33
|
-
serviceName: config.serviceName,
|
|
34
|
-
traceExporter: exporter.traces,
|
|
35
|
-
metricReader: exporter.metrics,
|
|
36
|
-
logRecordProcessors: exporter.logs,
|
|
37
|
-
textMapPropagator: new W3CTraceContextPropagator(),
|
|
38
|
-
instrumentations: [
|
|
39
|
-
getNodeAutoInstrumentations({
|
|
40
|
-
"@opentelemetry/instrumentation-fs": {
|
|
41
|
-
enabled: config.enableFS ?? false,
|
|
42
|
-
},
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
});
|
|
46
|
-
sdk.start();
|
|
47
|
-
console.log("NodeJS OpenTelemetry instrumentation started successfully.");
|
|
48
|
-
return sdk;
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
console.error("Error starting NodeJS OpenTelemetry instrumentation:", error);
|
|
52
|
-
}
|
|
53
|
-
}
|
package/dist/lib/options.d.ts
DELETED
package/dist/lib/options.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/utils.d.ts
DELETED
package/dist/lib/utils.js
DELETED
package/dist/vitest.config.d.ts
DELETED
package/dist/vitest.config.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "vitest/config";
|
|
2
|
-
export default defineConfig({
|
|
3
|
-
test: {
|
|
4
|
-
globals: true,
|
|
5
|
-
watch: false,
|
|
6
|
-
include: ["**/test/*.test.ts"],
|
|
7
|
-
exclude: ["**/fixtures/**", "**/dist/**"],
|
|
8
|
-
poolOptions: {
|
|
9
|
-
threads: {
|
|
10
|
-
maxThreads: 8,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
clearMocks: true,
|
|
14
|
-
testTimeout: 30_000,
|
|
15
|
-
coverage: {
|
|
16
|
-
enabled: true,
|
|
17
|
-
provider: "v8",
|
|
18
|
-
reportsDirectory: "coverage",
|
|
19
|
-
reporter: ["lcov", "cobertura"],
|
|
20
|
-
clean: true,
|
|
21
|
-
},
|
|
22
|
-
reporters: ["default", ["junit", { outputFile: "test-report.xml" }]],
|
|
23
|
-
environment: "node",
|
|
24
|
-
},
|
|
25
|
-
});
|
package/test-report.xml
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
-
<testsuites name="vitest tests" tests="9" failures="0" errors="0" time="0.781">
|
|
3
|
-
<testsuite name="test/index.test.ts" timestamp="2024-11-26T09:25:25.586Z" hostname="ABozzelli-ITMAC24" tests="2" failures="0" errors="0" skipped="0" time="0.002388">
|
|
4
|
-
<testcase classname="test/index.test.ts" name="instrumentNode > should call buildNodeInstrumentation with the provided config" time="0.001363792">
|
|
5
|
-
</testcase>
|
|
6
|
-
<testcase classname="test/index.test.ts" name="instrumentNode > should not throw when called without arguments" time="0.000454542">
|
|
7
|
-
</testcase>
|
|
8
|
-
</testsuite>
|
|
9
|
-
<testsuite name="test/node-config.test.ts" timestamp="2024-11-26T09:25:25.587Z" hostname="ABozzelli-ITMAC24" tests="4" failures="0" errors="0" skipped="0" time="0.042719333">
|
|
10
|
-
<testcase classname="test/node-config.test.ts" name="verify config settings > grpc config" time="0.017177333">
|
|
11
|
-
<system-out>
|
|
12
|
-
NodeJS OpenTelemetry instrumentation started successfully.
|
|
13
|
-
|
|
14
|
-
</system-out>
|
|
15
|
-
</testcase>
|
|
16
|
-
<testcase classname="test/node-config.test.ts" name="verify config settings > http config" time="0.016206917">
|
|
17
|
-
<system-out>
|
|
18
|
-
NodeJS OpenTelemetry instrumentation started successfully.
|
|
19
|
-
|
|
20
|
-
</system-out>
|
|
21
|
-
</testcase>
|
|
22
|
-
<testcase classname="test/node-config.test.ts" name="verify config settings > single log sending config" time="0.008346875">
|
|
23
|
-
<system-out>
|
|
24
|
-
NodeJS OpenTelemetry instrumentation started successfully.
|
|
25
|
-
|
|
26
|
-
</system-out>
|
|
27
|
-
</testcase>
|
|
28
|
-
<testcase classname="test/node-config.test.ts" name="verify config settings > check if clear base endpoint final slash" time="0.000374">
|
|
29
|
-
</testcase>
|
|
30
|
-
</testsuite>
|
|
31
|
-
<testsuite name="test/validation.test.ts" timestamp="2024-11-26T09:25:25.587Z" hostname="ABozzelli-ITMAC24" tests="3" failures="0" errors="0" skipped="0" time="0.003302375">
|
|
32
|
-
<testcase classname="test/validation.test.ts" name="validation config: should return without breaking the execution > should call buildNodeInstrumentation without config and skip instrumentation" time="0.00188275">
|
|
33
|
-
</testcase>
|
|
34
|
-
<testcase classname="test/validation.test.ts" name="validation config: should return without breaking the execution > node instrumentation: url undefined" time="0.000551875">
|
|
35
|
-
</testcase>
|
|
36
|
-
<testcase classname="test/validation.test.ts" name="validation config: should return without breaking the execution > node instrumentation: invalid url" time="0.000253958">
|
|
37
|
-
</testcase>
|
|
38
|
-
</testsuite>
|
|
39
|
-
</testsuites>
|