@peopl-health/nexus 2.2.9 → 2.3.0
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/lib/adapters/TwilioProvider.js +1 -7
- package/lib/helpers/assistantHelper.js +92 -269
- package/lib/helpers/baileysHelper.js +1 -11
- package/lib/helpers/filesHelper.js +75 -32
- package/lib/helpers/mediaHelper.js +4 -10
- package/lib/helpers/messageHelper.js +136 -0
- package/lib/helpers/processHelper.js +238 -0
- package/lib/helpers/threadHelper.js +73 -0
- package/lib/helpers/twilioHelper.js +2 -14
- package/lib/models/messageModel.js +0 -1
- package/lib/observability/index.js +184 -0
- package/lib/observability/telemetry.js +118 -0
- package/lib/providers/OpenAIResponsesProvider.js +0 -3
- package/lib/services/assistantService.js +106 -202
- package/lib/storage/MongoStorage.js +0 -2
- package/lib/utils/logger.js +91 -4
- package/lib/utils/sanitizer.js +62 -0
- package/lib/utils/tracingDecorator.js +48 -0
- package/package.json +13 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { createSpan } = require('../observability');
|
|
2
|
+
const { SpanStatusCode } = require('@opentelemetry/api');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Usage: const tracedFunction = withTracing(originalFunction, 'operation_name');
|
|
6
|
+
*/
|
|
7
|
+
const withTracing = (fn, spanName, attributeMapper = null) => {
|
|
8
|
+
return async function (...args) {
|
|
9
|
+
const span = createSpan(spanName);
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
if (attributeMapper && typeof attributeMapper === 'function') {
|
|
13
|
+
const attributes = attributeMapper(...args);
|
|
14
|
+
span.setAttributes(attributes);
|
|
15
|
+
}
|
|
16
|
+
const result = await fn.apply(this, args);
|
|
17
|
+
|
|
18
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
19
|
+
return result;
|
|
20
|
+
|
|
21
|
+
} catch (error) {
|
|
22
|
+
span.recordException(error);
|
|
23
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: error.message });
|
|
24
|
+
throw error;
|
|
25
|
+
} finally {
|
|
26
|
+
span.end();
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const withSimpleTracing = (fn, operationName) => {
|
|
32
|
+
return withTracing(fn, operationName);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* For class methods - preserves instance context via withTracing
|
|
37
|
+
*/
|
|
38
|
+
const withTracingMethod = (target, propertyKey, descriptor, spanName) => {
|
|
39
|
+
const originalMethod = descriptor.value;
|
|
40
|
+
descriptor.value = withTracing(originalMethod, spanName || `${target.constructor.name}.${propertyKey}`);
|
|
41
|
+
return descriptor;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
withTracing,
|
|
46
|
+
withSimpleTracing,
|
|
47
|
+
withTracingMethod
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peopl-health/nexus",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "Core messaging and assistant library for WhatsApp communication platforms",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"whatsapp",
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"./routes": {
|
|
43
43
|
"import": "./lib/routes/index.js",
|
|
44
44
|
"require": "./lib/routes/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./observability": {
|
|
47
|
+
"import": "./lib/observability/index.js",
|
|
48
|
+
"require": "./lib/observability/index.js"
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
"main": "lib/index.js",
|
|
@@ -70,6 +74,14 @@
|
|
|
70
74
|
"postversion": "git push && git push --tags"
|
|
71
75
|
},
|
|
72
76
|
"dependencies": {
|
|
77
|
+
"@opentelemetry/api": "1.9.0",
|
|
78
|
+
"@opentelemetry/auto-instrumentations-node": "0.67.0",
|
|
79
|
+
"@opentelemetry/exporter-jaeger": "2.2.0",
|
|
80
|
+
"@opentelemetry/exporter-prometheus": "0.208.0",
|
|
81
|
+
"@opentelemetry/resources": "2.2.0",
|
|
82
|
+
"@opentelemetry/sdk-node": "0.208.0",
|
|
83
|
+
"@opentelemetry/sdk-trace-node": "2.2.0",
|
|
84
|
+
"@opentelemetry/semantic-conventions": "1.38.0",
|
|
73
85
|
"airtable": "^0.12.2",
|
|
74
86
|
"aws-sdk": "2.1674.0",
|
|
75
87
|
"axios": "^1.5.0",
|