@saidsef/tracing-node 3.3.7 → 3.4.1
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/README.md +2 -6
- package/libs/index.mjs +9 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,13 +31,9 @@ You can set required params via env variables or function:
|
|
|
31
31
|
|
|
32
32
|
Env vars:
|
|
33
33
|
```
|
|
34
|
-
CONTAINER_NAME
|
|
35
|
-
NODE_ENV
|
|
36
|
-
HOSTNAME
|
|
37
|
-
SERVICE_NAME
|
|
38
|
-
NAME_SPACE
|
|
39
|
-
SERVICE_VERSION
|
|
34
|
+
CONTAINER_NAME || HOSTNAME
|
|
40
35
|
ENDPOINT
|
|
36
|
+
SERVICE_NAME
|
|
41
37
|
```
|
|
42
38
|
|
|
43
39
|
Function args
|
package/libs/index.mjs
CHANGED
|
@@ -31,8 +31,9 @@ import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
|
31
31
|
import {PinoInstrumentation} from '@opentelemetry/instrumentation-pino';
|
|
32
32
|
import {IORedisInstrumentation} from '@opentelemetry/instrumentation-ioredis';
|
|
33
33
|
import {registerInstrumentations} from '@opentelemetry/instrumentation';
|
|
34
|
-
import {Resource} from '@opentelemetry/resources';
|
|
34
|
+
import {Resource, detectResourcesSync} from '@opentelemetry/resources';
|
|
35
35
|
import {ATTR_SERVICE_NAME} from '@opentelemetry/semantic-conventions';
|
|
36
|
+
import {ATTR_CONTAINER_NAME} from '@opentelemetry/semantic-conventions/incubating';
|
|
36
37
|
|
|
37
38
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
38
39
|
|
|
@@ -55,6 +56,7 @@ let tracerProvider = null; // Declare provider in module scope for access in sto
|
|
|
55
56
|
|
|
56
57
|
export function setupTracing(options = {}) {
|
|
57
58
|
const {
|
|
59
|
+
hostname = process.env.CONTAINER_NAME || process.env.HOSTNAME,
|
|
58
60
|
serviceName = process.env.SERVICE_NAME,
|
|
59
61
|
url = process.env.ENDPOINT,
|
|
60
62
|
concurrencyLimit = 10,
|
|
@@ -73,9 +75,12 @@ export function setupTracing(options = {}) {
|
|
|
73
75
|
|
|
74
76
|
tracerProvider = new NodeTracerProvider({
|
|
75
77
|
spanProcessors: [spanProcessor],
|
|
76
|
-
resource:
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
resource: detectResourcesSync().merge(
|
|
79
|
+
new Resource({
|
|
80
|
+
[ATTR_SERVICE_NAME]: serviceName,
|
|
81
|
+
[ATTR_CONTAINER_NAME]: hostname,
|
|
82
|
+
}),
|
|
83
|
+
),
|
|
79
84
|
});
|
|
80
85
|
|
|
81
86
|
// Initialize the tracer provider with propagators
|