@ogcio/o11y-sdk-node 0.1.0-beta.1 → 0.1.0-beta.11

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +81 -0
  2. package/README.md +222 -0
  3. package/dist/index.d.ts +3 -2
  4. package/dist/index.js +2 -0
  5. package/dist/lib/exporter/console.d.ts +3 -0
  6. package/dist/lib/exporter/console.js +20 -0
  7. package/dist/lib/exporter/grpc.d.ts +3 -0
  8. package/dist/lib/exporter/grpc.js +41 -0
  9. package/dist/lib/exporter/http.d.ts +3 -0
  10. package/dist/lib/{http.js → exporter/http.js} +15 -9
  11. package/dist/lib/exporter/index.d.ts +8 -0
  12. package/dist/lib/index.d.ts +36 -6
  13. package/dist/lib/instrumentation.node.d.ts +1 -1
  14. package/dist/lib/instrumentation.node.js +47 -23
  15. package/dist/lib/metrics.d.ts +18 -0
  16. package/dist/lib/metrics.js +24 -0
  17. package/dist/lib/processor/enrich-logger-processor.d.ts +10 -0
  18. package/dist/lib/processor/enrich-logger-processor.js +19 -0
  19. package/dist/lib/processor/enrich-span-processor.d.ts +11 -0
  20. package/dist/lib/processor/enrich-span-processor.js +22 -0
  21. package/dist/lib/resource.d.ts +7 -0
  22. package/dist/lib/resource.js +18 -0
  23. package/dist/lib/traces.d.ts +1 -0
  24. package/dist/lib/traces.js +4 -0
  25. package/dist/lib/url-sampler.d.ts +10 -0
  26. package/dist/lib/url-sampler.js +25 -0
  27. package/dist/lib/utils.d.ts +4 -2
  28. package/dist/lib/utils.js +8 -3
  29. package/dist/package.json +58 -0
  30. package/dist/vitest.config.js +15 -1
  31. package/index.ts +4 -2
  32. package/lib/exporter/console.ts +31 -0
  33. package/lib/exporter/grpc.ts +52 -0
  34. package/lib/{http.ts → exporter/http.ts} +19 -11
  35. package/lib/exporter/index.ts +9 -0
  36. package/lib/index.ts +46 -5
  37. package/lib/instrumentation.node.ts +61 -28
  38. package/lib/metrics.ts +75 -0
  39. package/lib/processor/enrich-logger-processor.ts +34 -0
  40. package/lib/processor/enrich-span-processor.ts +39 -0
  41. package/lib/resource.ts +30 -0
  42. package/lib/traces.ts +5 -0
  43. package/lib/url-sampler.ts +52 -0
  44. package/lib/utils.ts +16 -4
  45. package/package.json +33 -25
  46. package/test/index.test.ts +22 -12
  47. package/test/integration/README.md +26 -0
  48. package/test/integration/integration.test.ts +58 -0
  49. package/test/integration/run.sh +88 -0
  50. package/test/metrics.test.ts +142 -0
  51. package/test/node-config.test.ts +76 -44
  52. package/test/processor/enrich-logger-processor.test.ts +58 -0
  53. package/test/processor/enrich-span-processor.test.ts +104 -0
  54. package/test/resource.test.ts +33 -0
  55. package/test/url-sampler.test.ts +215 -0
  56. package/test/utils/alloy-log-parser.ts +46 -0
  57. package/test/validation.test.ts +48 -11
  58. package/tsconfig.json +2 -1
  59. package/vitest.config.ts +15 -1
  60. package/coverage/cobertura-coverage.xml +0 -199
  61. package/coverage/lcov-report/base.css +0 -224
  62. package/coverage/lcov-report/block-navigation.js +0 -87
  63. package/coverage/lcov-report/favicon.png +0 -0
  64. package/coverage/lcov-report/index.html +0 -131
  65. package/coverage/lcov-report/prettify.css +0 -1
  66. package/coverage/lcov-report/prettify.js +0 -2
  67. package/coverage/lcov-report/sdk-node/index.html +0 -116
  68. package/coverage/lcov-report/sdk-node/index.ts.html +0 -106
  69. package/coverage/lcov-report/sdk-node/lib/grpc.ts.html +0 -178
  70. package/coverage/lcov-report/sdk-node/lib/http.ts.html +0 -190
  71. package/coverage/lcov-report/sdk-node/lib/index.html +0 -191
  72. package/coverage/lcov-report/sdk-node/lib/index.ts.html +0 -265
  73. package/coverage/lcov-report/sdk-node/lib/instrumentation.node.ts.html +0 -310
  74. package/coverage/lcov-report/sdk-node/lib/options.ts.html +0 -109
  75. package/coverage/lcov-report/sdk-node/lib/utils.ts.html +0 -115
  76. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  77. package/coverage/lcov-report/sorter.js +0 -196
  78. package/coverage/lcov.info +0 -206
  79. package/dist/lib/grpc.d.ts +0 -3
  80. package/dist/lib/grpc.js +0 -26
  81. package/dist/lib/http.d.ts +0 -3
  82. package/dist/lib/options.d.ts +0 -7
  83. package/lib/grpc.ts +0 -31
  84. package/lib/options.ts +0 -8
  85. package/test-report.xml +0 -39
  86. /package/dist/lib/{options.js → exporter/index.js} +0 -0
@@ -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);
@@ -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
@@ -1,3 +0,0 @@
1
- import type { NodeSDKConfig } from "./index.js";
2
- import type { Exporters } from "./options.js";
3
- export default function buildGrpcExporters(config: NodeSDKConfig): Exporters;
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
- }
@@ -1,3 +0,0 @@
1
- import type { NodeSDKConfig } from "./index.js";
2
- import type { Exporters } from "./options.js";
3
- export default function buildHttpExporters(config: NodeSDKConfig): Exporters;
@@ -1,7 +0,0 @@
1
- import type { MetricReader } from "@opentelemetry/sdk-metrics";
2
- import type { logs, tracing } from "@opentelemetry/sdk-node";
3
- export type Exporters = {
4
- traces: tracing.SpanExporter;
5
- metrics: MetricReader;
6
- logs: logs.LogRecordProcessor[];
7
- };
package/lib/grpc.ts DELETED
@@ -1,31 +0,0 @@
1
- import type { NodeSDKConfig } from "./index.js";
2
- import type { Exporters } from "./options.js";
3
- import { LogRecordProcessorMap } from "./utils.js";
4
- import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
5
- import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
6
- import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-grpc";
7
- import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-grpc";
8
- import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-grpc";
9
-
10
- export default function buildGrpcExporters(config: NodeSDKConfig): Exporters {
11
- return {
12
- traces: new OTLPTraceExporter({
13
- url: `${config.collectorUrl}`,
14
- compression: CompressionAlgorithm.GZIP,
15
- }),
16
- metrics: new PeriodicExportingMetricReader({
17
- exporter: new OTLPMetricExporter({
18
- url: `${config.collectorUrl}`,
19
- compression: CompressionAlgorithm.GZIP,
20
- }),
21
- }),
22
- logs: [
23
- new LogRecordProcessorMap[config.collectorMode ?? "batch"](
24
- new OTLPLogExporter({
25
- url: `${config.collectorUrl}`,
26
- compression: CompressionAlgorithm.GZIP,
27
- }),
28
- ),
29
- ],
30
- };
31
- }
package/lib/options.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { MetricReader } from "@opentelemetry/sdk-metrics";
2
- import type { logs, tracing } from "@opentelemetry/sdk-node";
3
-
4
- export type Exporters = {
5
- traces: tracing.SpanExporter;
6
- metrics: MetricReader;
7
- logs: logs.LogRecordProcessor[];
8
- };
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 &gt; should call buildNodeInstrumentation with the provided config" time="0.001363792">
5
- </testcase>
6
- <testcase classname="test/index.test.ts" name="instrumentNode &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; 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 &gt; node instrumentation: invalid url" time="0.000253958">
37
- </testcase>
38
- </testsuite>
39
- </testsuites>
File without changes