@onlineapps/conn-base-monitoring 1.0.0 → 1.0.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/README.md +170 -0
- package/coverage/clover.xml +0 -0
- package/coverage/coverage-final.json +0 -0
- package/coverage/lcov-report/base.css +0 -0
- package/coverage/lcov-report/block-navigation.js +0 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -0
- package/coverage/lcov-report/index.js.html +0 -0
- package/coverage/lcov-report/prettify.css +0 -0
- package/coverage/lcov-report/prettify.js +0 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -0
- package/coverage/lcov.info +0 -0
- package/onlineapps-conn-base-monitoring-1.0.0.tgz +0 -0
- package/package.json +4 -4
- package/src/index.js +0 -0
- package/{test → tests}/component/integration.test.js +1 -1
- package/{test → tests}/unit/monitoring.test.js +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# @onlineapps/conn-base-monitoring
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
Monitoring connector providing OpenTelemetry-based observability for all services. Thin wrapper around monitoring-core factory.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
```bash
|
|
8
|
+
npm install @onlineapps/conn-base-monitoring
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
- OpenTelemetry tracing integration
|
|
13
|
+
- Workflow tracking with correlation IDs
|
|
14
|
+
- Automatic context propagation
|
|
15
|
+
- Performance metrics collection
|
|
16
|
+
- Configurable exporters
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
### Basic Setup
|
|
21
|
+
```javascript
|
|
22
|
+
const { MonitoringConnector } = require('@onlineapps/conn-base-monitoring');
|
|
23
|
+
|
|
24
|
+
const monitoring = new MonitoringConnector({
|
|
25
|
+
serviceName: 'hello-service',
|
|
26
|
+
enableTracing: true,
|
|
27
|
+
enableMetrics: true
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// Initialize monitoring
|
|
31
|
+
await monitoring.initialize();
|
|
32
|
+
|
|
33
|
+
// Create spans
|
|
34
|
+
const span = monitoring.startSpan('process_request');
|
|
35
|
+
try {
|
|
36
|
+
// Your business logic
|
|
37
|
+
await processRequest();
|
|
38
|
+
} finally {
|
|
39
|
+
monitoring.endSpan(span);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Workflow Tracking
|
|
44
|
+
```javascript
|
|
45
|
+
// Extract context from message headers
|
|
46
|
+
const context = monitoring.extractContext(message.headers);
|
|
47
|
+
|
|
48
|
+
// Create child span with workflow context
|
|
49
|
+
const span = monitoring.startSpan('step_execution', {
|
|
50
|
+
workflowId: context.workflowId,
|
|
51
|
+
parentSpanId: context.spanId
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Track workflow step
|
|
55
|
+
monitoring.trackWorkflowStep({
|
|
56
|
+
workflowId: context.workflowId,
|
|
57
|
+
step: 'validation',
|
|
58
|
+
status: 'completed',
|
|
59
|
+
duration: 45
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Configuration
|
|
64
|
+
|
|
65
|
+
### Environment Variables
|
|
66
|
+
```bash
|
|
67
|
+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
|
|
68
|
+
OTEL_SERVICE_NAME=my-service
|
|
69
|
+
OTEL_TRACES_EXPORTER=otlp
|
|
70
|
+
OTEL_METRICS_EXPORTER=otlp
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Options
|
|
74
|
+
```javascript
|
|
75
|
+
{
|
|
76
|
+
serviceName: 'service-name', // Required
|
|
77
|
+
enableTracing: true, // Default: true
|
|
78
|
+
enableMetrics: true, // Default: true
|
|
79
|
+
enableLogging: true, // Default: true
|
|
80
|
+
exporterUrl: 'http://...', // Optional, overrides env
|
|
81
|
+
samplingRate: 1.0, // Default: 1.0 (100%)
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## API Reference
|
|
86
|
+
|
|
87
|
+
### MonitoringConnector
|
|
88
|
+
|
|
89
|
+
#### initialize()
|
|
90
|
+
Initializes the monitoring system with configured exporters.
|
|
91
|
+
|
|
92
|
+
#### startSpan(name, attributes?)
|
|
93
|
+
Creates a new span with optional attributes.
|
|
94
|
+
|
|
95
|
+
#### endSpan(span)
|
|
96
|
+
Ends the specified span.
|
|
97
|
+
|
|
98
|
+
#### extractContext(headers)
|
|
99
|
+
Extracts tracing context from message headers.
|
|
100
|
+
|
|
101
|
+
#### injectContext(headers, context)
|
|
102
|
+
Injects tracing context into message headers.
|
|
103
|
+
|
|
104
|
+
#### trackWorkflowStep(data)
|
|
105
|
+
Records workflow step execution metrics.
|
|
106
|
+
|
|
107
|
+
#### getActiveWorkflows()
|
|
108
|
+
Returns list of currently active workflows.
|
|
109
|
+
|
|
110
|
+
#### shutdown()
|
|
111
|
+
Gracefully shuts down the monitoring system.
|
|
112
|
+
|
|
113
|
+
## Integration with Service Wrapper
|
|
114
|
+
|
|
115
|
+
The monitoring connector is automatically integrated when using service-wrapper:
|
|
116
|
+
|
|
117
|
+
```javascript
|
|
118
|
+
const { ServiceWrapper } = require('@onlineapps/service-wrapper');
|
|
119
|
+
|
|
120
|
+
const wrapper = new ServiceWrapper({
|
|
121
|
+
monitoring: {
|
|
122
|
+
enabled: true,
|
|
123
|
+
serviceName: 'my-service'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Monitoring is automatically configured
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Metrics Collected
|
|
131
|
+
|
|
132
|
+
### Automatic Metrics
|
|
133
|
+
- Request duration (histogram)
|
|
134
|
+
- Request count (counter)
|
|
135
|
+
- Active requests (gauge)
|
|
136
|
+
- Error rate (counter)
|
|
137
|
+
- Queue depth (gauge)
|
|
138
|
+
|
|
139
|
+
### Custom Metrics
|
|
140
|
+
```javascript
|
|
141
|
+
// Increment counter
|
|
142
|
+
monitoring.incrementCounter('custom_metric', { tag: 'value' });
|
|
143
|
+
|
|
144
|
+
// Record histogram
|
|
145
|
+
monitoring.recordHistogram('processing_time', 123, { type: 'invoice' });
|
|
146
|
+
|
|
147
|
+
// Update gauge
|
|
148
|
+
monitoring.setGauge('queue_depth', 45);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Testing
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npm test # Run all tests
|
|
155
|
+
npm run test:unit # Unit tests only
|
|
156
|
+
npm run test:component # Component tests
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Dependencies
|
|
160
|
+
- `@onlineapps/monitoring-core` - Core monitoring factory
|
|
161
|
+
- `@opentelemetry/api` - OpenTelemetry API
|
|
162
|
+
- `@opentelemetry/sdk-node` - OpenTelemetry SDK
|
|
163
|
+
|
|
164
|
+
## Related Documentation
|
|
165
|
+
- [Monitoring Module](/docs/modules/monitoring.md) - Architecture overview
|
|
166
|
+
- [Monitoring Core](/api/shared/monitoring-core/README.md) - Factory implementation
|
|
167
|
+
- [Service Wrapper](/shared/connector/service-wrapper/README.md) - Integration guide
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
*Version: 1.0.0 | License: MIT*
|
package/coverage/clover.xml
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/coverage/lcov.info
CHANGED
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onlineapps/conn-base-monitoring",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Monitoring connector for service-wrapper integration",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest",
|
|
8
8
|
"test:coverage": "jest --coverage",
|
|
9
|
-
"test:unit": "jest
|
|
10
|
-
"test:component": "jest
|
|
9
|
+
"test:unit": "jest tests/unit",
|
|
10
|
+
"test:component": "jest tests/component"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@onlineapps/monitoring-core": "
|
|
13
|
+
"@onlineapps/monitoring-core": "1.0.6"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"jest": "^29.5.0"
|
package/src/index.js
CHANGED
|
File without changes
|
|
@@ -63,7 +63,7 @@ jest.mock('@onlineapps/monitoring-core', () => {
|
|
|
63
63
|
|
|
64
64
|
const { init } = require('../../src');
|
|
65
65
|
|
|
66
|
-
describe('conn-base-monitoring Component Tests', () => {
|
|
66
|
+
describe('conn-base-monitoring Component Tests @component', () => {
|
|
67
67
|
let monitoring;
|
|
68
68
|
|
|
69
69
|
beforeAll(() => {
|
|
@@ -45,7 +45,7 @@ jest.mock('@onlineapps/monitoring-core', () => ({
|
|
|
45
45
|
|
|
46
46
|
const { init, getInstance, createLogger, WorkflowTracker } = require('../../src');
|
|
47
47
|
|
|
48
|
-
describe('conn-base-monitoring Unit Tests', () => {
|
|
48
|
+
describe('conn-base-monitoring Unit Tests @unit', () => {
|
|
49
49
|
beforeEach(() => {
|
|
50
50
|
jest.clearAllMocks();
|
|
51
51
|
});
|