@saidsef/tracing-node 1.10.0 → 1.10.2
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/.eslintrc.yml +19 -5
- package/libs/index.mjs +17 -17
- package/package.json +5 -5
package/.eslintrc.yml
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
env:
|
|
2
|
-
|
|
3
|
-
commonjs:
|
|
2
|
+
node: true
|
|
3
|
+
commonjs: false
|
|
4
4
|
es2021: true
|
|
5
|
-
jest: true
|
|
6
5
|
extends: eslint:recommended
|
|
7
6
|
parserOptions:
|
|
8
7
|
ecmaVersion: latest
|
|
9
8
|
sourceType: module
|
|
10
|
-
rules:
|
|
9
|
+
rules:
|
|
10
|
+
"prefer-const": ["error", { "ignoreReadBeforeAssign": true }]
|
|
11
|
+
arrow-spacing: ["error", { "before": true, "after": true }]
|
|
12
|
+
computed-property-spacing: ["error", "never"]
|
|
13
|
+
eol-last: ["error", "always"]
|
|
14
|
+
no-compare-neg-zero: "error"
|
|
15
|
+
no-tabs: ["error", { allowIndentationTabs: true }]
|
|
16
|
+
no-trailing-spaces: "error"
|
|
17
|
+
no-unused-vars: "error"
|
|
18
|
+
no-whitespace-before-property: "error"
|
|
19
|
+
object-curly-spacing: ["error", "never"]
|
|
20
|
+
quotes: ["warn", "single"]
|
|
21
|
+
rest-spread-spacing: ["error", "always"]
|
|
22
|
+
semi: ["warn", "always"]
|
|
23
|
+
space-before-blocks: "error"
|
|
24
|
+
template-curly-spacing: "error"
|
|
11
25
|
overrides:
|
|
12
|
-
- files: [
|
|
26
|
+
- files: [ "libs/index.mjs"]
|
package/libs/index.mjs
CHANGED
|
@@ -16,20 +16,20 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
19
|
+
import {CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator} from '@opentelemetry/core';
|
|
20
|
+
import {registerInstrumentations} from '@opentelemetry/instrumentation';
|
|
21
|
+
import {NodeTracerProvider} from '@opentelemetry/sdk-trace-node';
|
|
22
|
+
import {BatchSpanProcessor} from '@opentelemetry/sdk-trace-base';
|
|
23
|
+
import {OTLPTraceExporter} from '@opentelemetry/exporter-trace-otlp-grpc';
|
|
24
|
+
import {HttpInstrumentation} from '@opentelemetry/instrumentation-http';
|
|
25
|
+
import {ExpressInstrumentation} from '@opentelemetry/instrumentation-express';
|
|
26
|
+
import {diag, DiagConsoleLogger, DiagLogLevel} from '@opentelemetry/api';
|
|
27
|
+
import {Resource} from '@opentelemetry/resources';
|
|
28
|
+
import {SemanticResourceAttributes} from '@opentelemetry/semantic-conventions';
|
|
29
|
+
import {AwsInstrumentation} from '@opentelemetry/instrumentation-aws-sdk';
|
|
30
|
+
import {PinoInstrumentation} from '@opentelemetry/instrumentation-pino';
|
|
31
|
+
import {DnsInstrumentation} from '@opentelemetry/instrumentation-dns';
|
|
32
|
+
import {B3Propagator, B3InjectEncoding} from '@opentelemetry/propagator-b3';
|
|
33
33
|
|
|
34
34
|
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
35
35
|
|
|
@@ -55,7 +55,7 @@ diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.INFO);
|
|
|
55
55
|
* be used to create and export spans for tracing various operations within
|
|
56
56
|
* the service.
|
|
57
57
|
*/
|
|
58
|
-
export async function setupTracing (serviceName, appName=
|
|
58
|
+
export async function setupTracing (serviceName, appName='application', endpoint=null) {
|
|
59
59
|
const provider = new NodeTracerProvider({
|
|
60
60
|
resource: new Resource({
|
|
61
61
|
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
|
|
@@ -79,7 +79,7 @@ export async function setupTracing (serviceName, appName="application", endpoint
|
|
|
79
79
|
const ignoreIncomingRequestHook = (req) => {
|
|
80
80
|
const isStaticAsset = !!req.url.match(/^\/metrics|\/healthz.*$/);
|
|
81
81
|
return isStaticAsset;
|
|
82
|
-
}
|
|
82
|
+
};
|
|
83
83
|
|
|
84
84
|
// Register instrumentations
|
|
85
85
|
registerInstrumentations({
|
|
@@ -108,7 +108,7 @@ export async function setupTracing (serviceName, appName="application", endpoint
|
|
|
108
108
|
// Initialize the tracer provider
|
|
109
109
|
provider.register({
|
|
110
110
|
propagator: new CompositePropagator({
|
|
111
|
-
propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({
|
|
111
|
+
propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator(), new B3Propagator({injectEncoding: B3InjectEncoding.MULTI_HEADER})],
|
|
112
112
|
})});
|
|
113
113
|
|
|
114
114
|
// Return the tracer for the service
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saidsef/tracing-node",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.2",
|
|
4
4
|
"description": "tracing NodeJS - This is a wrapper for OpenTelemetry instrumentation packages",
|
|
5
5
|
"main": "libs/index.mjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node --trace-warnings --test --report-uncaught-exception --heap-prof --cpu-prof --track-heap-objects --report-dir=test/ --diagnostic-dir=test/ --heap-prof-dir=test/ libs/index.mjs",
|
|
8
|
-
"lint": "eslint
|
|
8
|
+
"lint": "eslint .",
|
|
9
9
|
"rebuild": "rm -rfv node_modules/ package-lock.json && npm install --prod --omit=dev"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"@opentelemetry/instrumentation": "^0.50.0",
|
|
44
44
|
"@opentelemetry/instrumentation-aws-sdk": "^0.40.0",
|
|
45
45
|
"@opentelemetry/instrumentation-dns": "^0.35.0",
|
|
46
|
-
"@opentelemetry/instrumentation-express": "^0.
|
|
47
|
-
"@opentelemetry/instrumentation-http": "^0.
|
|
46
|
+
"@opentelemetry/instrumentation-express": "^0.37.0",
|
|
47
|
+
"@opentelemetry/instrumentation-http": "^0.50.0",
|
|
48
48
|
"@opentelemetry/instrumentation-pino": "^0.37.0",
|
|
49
49
|
"@opentelemetry/propagator-b3": "^1.22.0",
|
|
50
50
|
"@opentelemetry/resources": "^1.21.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@opentelemetry/semantic-conventions": "^1.22.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"eslint": "
|
|
56
|
+
"eslint": "^8.57.0",
|
|
57
57
|
"jest": "^29.7.0"
|
|
58
58
|
}
|
|
59
59
|
}
|