@ogcio/o11y-sdk-node 0.1.0-beta.11 → 0.1.0-beta.13
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 +35 -0
- package/dist/lib/instrumentation.node.js +11 -0
- package/dist/package.json +4 -4
- package/dist/vitest.config.js +1 -1
- package/lib/instrumentation.node.ts +17 -0
- package/package.json +4 -4
- package/test/index.test.ts +34 -3
- package/vitest.config.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.0-beta.13](https://github.com/ogcio/o11y/compare/@ogcio/o11y-sdk-node@v0.1.0-beta.12...@ogcio/o11y-sdk-node@v0.1.0-beta.13) (2025-06-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **sdk-node:** allow graceful shutdown of instrumentation on SIGTERM AB[#28329](https://github.com/ogcio/o11y/issues/28329) ([#151](https://github.com/ogcio/o11y/issues/151)) ([991ee15](https://github.com/ogcio/o11y/commit/991ee1559898b721823cb9d1e0490e2ad82e6d0a))
|
|
9
|
+
|
|
10
|
+
## [0.1.0-beta.12](https://github.com/ogcio/o11y/compare/@ogcio/o11y-sdk-node@v0.1.0-beta.11...@ogcio/o11y-sdk-node@v0.1.0-beta.12) (2025-06-04)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add custom log processor for span enrich ([#102](https://github.com/ogcio/o11y/issues/102)) ([bbf8334](https://github.com/ogcio/o11y/commit/bbf83340940ed651dff63bbe7aaa52881d1e8c8c))
|
|
16
|
+
* add opentelemetry sampler ([#66](https://github.com/ogcio/o11y/issues/66)) ([48a1761](https://github.com/ogcio/o11y/commit/48a1761d68fbccf7b63e4232a62376caecf01fbc))
|
|
17
|
+
* april depedency upgrade AB[#27200](https://github.com/ogcio/o11y/issues/27200) ([#116](https://github.com/ogcio/o11y/issues/116)) ([d792fe5](https://github.com/ogcio/o11y/commit/d792fe5a783b0b495912b5bef2babfe11ef5e01d))
|
|
18
|
+
* june deps update ([#147](https://github.com/ogcio/o11y/issues/147)) ([b365a40](https://github.com/ogcio/o11y/commit/b365a4099cdfd8533ffa4948620d29f0044bbd70))
|
|
19
|
+
* may deps update ([#136](https://github.com/ogcio/o11y/issues/136)) ([3edd8b1](https://github.com/ogcio/o11y/commit/3edd8b1d823740d555fc4d93be427e9dc1438a95))
|
|
20
|
+
* o11y sdk repo setup ([#15](https://github.com/ogcio/o11y/issues/15)) ([c5816ba](https://github.com/ogcio/o11y/commit/c5816baff1454353f12539949959e84964ed6401))
|
|
21
|
+
* o11y showcase AB[#25895](https://github.com/ogcio/o11y/issues/25895) ([#84](https://github.com/ogcio/o11y/issues/84)) ([f8f10af](https://github.com/ogcio/o11y/commit/f8f10af97d9f5c188e3e65f7d62d5c673edce25a))
|
|
22
|
+
* remove pnpm test on prepublishOnly script ([#68](https://github.com/ogcio/o11y/issues/68)) ([41f6f57](https://github.com/ogcio/o11y/commit/41f6f57fa415c4f7adc29f49f983539274ef7320))
|
|
23
|
+
* **sdk-node:** add span customization AB[#25358](https://github.com/ogcio/o11y/issues/25358) ([46ba97b](https://github.com/ogcio/o11y/commit/46ba97bac4004ff326a954592f45213ce0e4d683))
|
|
24
|
+
* **sdk-node:** custom metrics ([#53](https://github.com/ogcio/o11y/issues/53)) ([3cb40b1](https://github.com/ogcio/o11y/commit/3cb40b1add3d80615c8d123d233724094559c7ff))
|
|
25
|
+
* **sdk-node:** renaming MetricsParams interface properties AB[#26188](https://github.com/ogcio/o11y/issues/26188) ([#96](https://github.com/ogcio/o11y/issues/96)) ([244aee0](https://github.com/ogcio/o11y/commit/244aee01ae6e7f319ae7f9fdeff27eb40ee3c863))
|
|
26
|
+
* upgrade to opentelemetry 2 AB[#25863](https://github.com/ogcio/o11y/issues/25863) ([#106](https://github.com/ogcio/o11y/issues/106)) ([3ff0314](https://github.com/ogcio/o11y/commit/3ff0314fef9f4d7b5db76da3b94e9035801384c7))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* add readme file inside submodule ([#27](https://github.com/ogcio/o11y/issues/27)) ([dc518d5](https://github.com/ogcio/o11y/commit/dc518d5dde573368443bc0f8619e80e331880c78))
|
|
32
|
+
* default attributes in resource ([#112](https://github.com/ogcio/o11y/issues/112)) ([f0f0b9d](https://github.com/ogcio/o11y/commit/f0f0b9d555ef321d31f7171e25dc4b8a5b044522))
|
|
33
|
+
* improve getMetric attributes types ([#76](https://github.com/ogcio/o11y/issues/76)) ([243649c](https://github.com/ogcio/o11y/commit/243649c4bfe750687a729fbd836772cce16e0cb1))
|
|
34
|
+
* prepublishOnly hook ([#60](https://github.com/ogcio/o11y/issues/60)) ([9fbd3ad](https://github.com/ogcio/o11y/commit/9fbd3ad0b45a1604cf2eccc26b2f8855640417a1))
|
|
35
|
+
* **sdk-node:** add waitForReady for grpc-client to handle transient init connection errors AB[#28329](https://github.com/ogcio/o11y/issues/28329) ([#144](https://github.com/ogcio/o11y/issues/144)) ([6f260da](https://github.com/ogcio/o11y/commit/6f260da15fcbcd2c629ec6d4bb9fb3592803f399))
|
|
36
|
+
* **sdk-node:** update sdk init examples AB[#28329](https://github.com/ogcio/o11y/issues/28329) ([#146](https://github.com/ogcio/o11y/issues/146)) ([81de295](https://github.com/ogcio/o11y/commit/81de2957a7bef7430a46c6677f3c876255ef7c88))
|
|
37
|
+
|
|
3
38
|
## [0.1.0-beta.11](https://github.com/ogcio/o11y/compare/@ogcio/o11y-sdk-node@v0.1.0-beta.10...@ogcio/o11y-sdk-node@v0.1.0-beta.11) (2025-05-21)
|
|
4
39
|
|
|
5
40
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from "process";
|
|
1
2
|
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
|
|
2
3
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
3
4
|
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
@@ -60,6 +61,16 @@ export default async function buildNodeInstrumentation(config) {
|
|
|
60
61
|
});
|
|
61
62
|
sdk.start();
|
|
62
63
|
console.log("NodeJS OpenTelemetry instrumentation started successfully.");
|
|
64
|
+
process.on("SIGTERM", async () => {
|
|
65
|
+
try {
|
|
66
|
+
// Flushing before shutdown is implemented on a per-exporter basis.
|
|
67
|
+
await sdk.shutdown();
|
|
68
|
+
console.log("NodeJS OpenTelemetry instrumentation shutdown successfully");
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error("Error shutting down NodeJS OpenTelemetry instrumentation:", error);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
63
74
|
return sdk;
|
|
64
75
|
}
|
|
65
76
|
catch (error) {
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogcio/o11y-sdk-node",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.13",
|
|
4
4
|
"description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"@opentelemetry/sdk-trace-base": "^2.0.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/node": "^22.15.
|
|
50
|
-
"@vitest/coverage-v8": "^3.2.
|
|
49
|
+
"@types/node": "^22.15.30",
|
|
50
|
+
"@vitest/coverage-v8": "^3.2.2",
|
|
51
51
|
"tsx": "^4.19.4",
|
|
52
52
|
"typescript": "^5.8.3",
|
|
53
|
-
"vitest": "^3.2.
|
|
53
|
+
"vitest": "^3.2.2"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=20.6.0"
|
package/dist/vitest.config.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from "process";
|
|
1
2
|
import { diag, DiagConsoleLogger, DiagLogLevel } from "@opentelemetry/api";
|
|
2
3
|
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
|
|
3
4
|
import { W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
@@ -89,6 +90,22 @@ export default async function buildNodeInstrumentation(
|
|
|
89
90
|
|
|
90
91
|
sdk.start();
|
|
91
92
|
console.log("NodeJS OpenTelemetry instrumentation started successfully.");
|
|
93
|
+
|
|
94
|
+
process.on("SIGTERM", async () => {
|
|
95
|
+
try {
|
|
96
|
+
// Flushing before shutdown is implemented on a per-exporter basis.
|
|
97
|
+
await sdk.shutdown();
|
|
98
|
+
console.log(
|
|
99
|
+
"NodeJS OpenTelemetry instrumentation shutdown successfully",
|
|
100
|
+
);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error(
|
|
103
|
+
"Error shutting down NodeJS OpenTelemetry instrumentation:",
|
|
104
|
+
error,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
|
|
92
109
|
return sdk;
|
|
93
110
|
} catch (error) {
|
|
94
111
|
console.error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogcio/o11y-sdk-node",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.13",
|
|
4
4
|
"description": "Opentelemetry standard instrumentation SDK for NodeJS based project",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"@opentelemetry/sdk-trace-base": "^2.0.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^22.15.
|
|
42
|
-
"@vitest/coverage-v8": "^3.2.
|
|
41
|
+
"@types/node": "^22.15.30",
|
|
42
|
+
"@vitest/coverage-v8": "^3.2.2",
|
|
43
43
|
"tsx": "^4.19.4",
|
|
44
44
|
"typescript": "^5.8.3",
|
|
45
|
-
"vitest": "^3.2.
|
|
45
|
+
"vitest": "^3.2.2"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=20.6.0"
|
package/test/index.test.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { describe, test, expect, vi, beforeEach } from "vitest";
|
|
1
|
+
import { describe, test, expect, vi, beforeEach, afterEach } from "vitest";
|
|
2
2
|
import { NodeSDKConfig } from "../index";
|
|
3
3
|
import { instrumentNode } from "../index";
|
|
4
4
|
import * as buildNodeInstrumentationModule from "../lib/instrumentation.node";
|
|
5
|
+
import { metrics } from "@opentelemetry/sdk-node";
|
|
5
6
|
|
|
6
7
|
describe("instrumentNode", () => {
|
|
7
8
|
beforeEach(() => {
|
|
9
|
+
// @ts-ignore Avoid actually running exporters at any time in tests (overriding private method)
|
|
10
|
+
vi.spyOn(
|
|
11
|
+
metrics.PeriodicExportingMetricReader.prototype,
|
|
12
|
+
"_doRun",
|
|
13
|
+
).mockImplementation(vi.fn());
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
8
17
|
vi.restoreAllMocks();
|
|
9
18
|
});
|
|
10
19
|
|
|
@@ -33,7 +42,29 @@ describe("instrumentNode", () => {
|
|
|
33
42
|
expect(instrumentationMock).toHaveBeenCalledWith(config);
|
|
34
43
|
});
|
|
35
44
|
|
|
36
|
-
test("should not throw when called without arguments", () => {
|
|
37
|
-
expect(instrumentNode()).resolves.not.toThrow();
|
|
45
|
+
test("should not throw when called without arguments", async () => {
|
|
46
|
+
await expect(instrumentNode()).resolves.not.toThrow();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("should invoke instrumentation shutdown on SIGTERM", async () => {
|
|
50
|
+
const config: NodeSDKConfig = {
|
|
51
|
+
serviceName: "custom-service",
|
|
52
|
+
collectorUrl: "http://custom-collector.com",
|
|
53
|
+
protocol: "grpc",
|
|
54
|
+
resourceAttributes: {
|
|
55
|
+
"team.infra.cluster": "dev-01",
|
|
56
|
+
"team.infra.pod": "01",
|
|
57
|
+
"team.service.type": "fastify",
|
|
58
|
+
},
|
|
59
|
+
spanAttributes: {
|
|
60
|
+
"signal.namespace": "example",
|
|
61
|
+
"signal.number": () => "callback",
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const sdk = await instrumentNode(config);
|
|
66
|
+
const shutdownMock = vi.spyOn(sdk, "shutdown");
|
|
67
|
+
process.emit("SIGTERM");
|
|
68
|
+
expect(shutdownMock).toHaveBeenCalled();
|
|
38
69
|
});
|
|
39
70
|
});
|
package/vitest.config.ts
CHANGED