@mereb/shared-packages 0.0.36 → 0.0.37
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../src/observability/otel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AASpE,MAAM,WAAW,UAAU;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACxC;AA2BD,wBAAgB,aAAa,CAAC,EACI,WAAW,EACX,YAAY,EACZ,gBAAqB,EACxB,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"otel.d.ts","sourceRoot":"","sources":["../../src/observability/otel.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AASpE,MAAM,WAAW,UAAU;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACxC;AA2BD,wBAAgB,aAAa,CAAC,EACI,WAAW,EACX,YAAY,EACZ,gBAAqB,EACxB,EAAE,UAAU,QA8B1C;AAED,wBAAgB,oBAAoB,CAChC,WAAW,EAAE,MAAM,EACnB,gBAAgB,GAAE,eAAe,EAAO,QAS3C"}
|
|
@@ -4,8 +4,8 @@ import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
|
4
4
|
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node';
|
|
5
5
|
import { OTLPTraceExporter as OTLPHttpTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';
|
|
6
6
|
import { registerInstrumentations } from '@opentelemetry/instrumentation';
|
|
7
|
-
import { FastifyInstrumentation } from '@opentelemetry/instrumentation-fastify';
|
|
8
7
|
import { HttpInstrumentation } from '@opentelemetry/instrumentation-http';
|
|
8
|
+
import { FastifyOtelInstrumentation } from '@fastify/otel';
|
|
9
9
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
10
10
|
let initialized = false;
|
|
11
11
|
function defaultEndpoint() {
|
|
@@ -25,7 +25,7 @@ function resolveEndpoint(override) {
|
|
|
25
25
|
return fromEnv ?? defaultEndpoint();
|
|
26
26
|
}
|
|
27
27
|
function defaultInstrumentations() {
|
|
28
|
-
return [new HttpInstrumentation(), new
|
|
28
|
+
return [new HttpInstrumentation(), new FastifyOtelInstrumentation()];
|
|
29
29
|
}
|
|
30
30
|
export function initTelemetry({ serviceName, otlpEndpoint, instrumentations = [] }) {
|
|
31
31
|
if (initialized) {
|
|
@@ -35,11 +35,14 @@ export function initTelemetry({ serviceName, otlpEndpoint, instrumentations = []
|
|
|
35
35
|
const resource = new Resource({
|
|
36
36
|
'service.name': serviceName
|
|
37
37
|
});
|
|
38
|
-
const
|
|
39
|
-
provider.addSpanProcessor(new BatchSpanProcessor(new OTLPHttpTraceExporter({
|
|
38
|
+
const exporter = new OTLPHttpTraceExporter({
|
|
40
39
|
// the HTTP exporter appends /v1/traces when no path is present
|
|
41
40
|
url: endpoint
|
|
42
|
-
})
|
|
41
|
+
});
|
|
42
|
+
const provider = new NodeTracerProvider({
|
|
43
|
+
resource,
|
|
44
|
+
spanProcessors: [new BatchSpanProcessor(exporter)]
|
|
45
|
+
});
|
|
43
46
|
provider.register();
|
|
44
47
|
registerInstrumentations({
|
|
45
48
|
instrumentations: instrumentations.length
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mereb/shared-packages",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@fastify/cors": "^9.0.1",
|
|
18
|
+
"@fastify/otel": "^0.16.0",
|
|
18
19
|
"@fastify/rate-limit": "^10.2.0",
|
|
19
20
|
"@fastify/sensible": "^5.6.0",
|
|
20
21
|
"@fastify/under-pressure": "^9.0.3",
|
|
@@ -23,7 +24,6 @@
|
|
|
23
24
|
"@opentelemetry/exporter-trace-otlp-http": "^0.52.1",
|
|
24
25
|
"@opentelemetry/host-metrics": "^0.36.2",
|
|
25
26
|
"@opentelemetry/instrumentation": "^0.52.0",
|
|
26
|
-
"@opentelemetry/instrumentation-fastify": "^0.52.0",
|
|
27
27
|
"@opentelemetry/instrumentation-http": "^0.52.0",
|
|
28
28
|
"@opentelemetry/resources": "^1.8.0",
|
|
29
29
|
"@opentelemetry/sdk-metrics": "^1.18.0",
|