@eqxjs/nest-opentelemetry 3.1.2 → 3.2.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/EXAMPLES.md +392 -0
- package/README.md +6 -3
- package/dist/extend/common/m1.common.js +10 -11
- package/dist/extend/common/m1.common.js.map +1 -1
- package/dist/extend/common/m2.common.js +26 -27
- package/dist/extend/common/m2.common.js.map +1 -1
- package/dist/extend/common/m3.common.js +28 -29
- package/dist/extend/common/m3.common.js.map +1 -1
- package/dist/extend/kafka.span.js +2 -4
- package/dist/extend/kafka.span.js.map +1 -1
- package/dist/extend/socket-io.span.js +12 -14
- package/dist/extend/socket-io.span.js.map +1 -1
- package/dist/register.js +8 -0
- package/dist/register.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.js +3 -4
- package/dist/utils.js.map +1 -1
- package/package.json +55 -53
- package/tsconfig.json +5 -5
package/EXAMPLES.md
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
# Custom OpenTelemetry — Traces, Metrics & Logs in NestJS
|
|
2
|
+
|
|
3
|
+
All examples use the standard `@opentelemetry/api` and `@opentelemetry/api-logs` packages that are already pulled in transitively by `@eqxjs/nest-opentelemetry`. No extra dependencies are required.
|
|
4
|
+
|
|
5
|
+
> **Prerequisite** — register the SDK *before* your app loads (see README).
|
|
6
|
+
> All `trace`, `metrics`, and `logs` API calls are no-ops until the SDK is started.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 1 — Custom Traces
|
|
11
|
+
|
|
12
|
+
### 1.1 Simple span in a service method
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
// order.service.ts
|
|
16
|
+
import { Injectable } from '@nestjs/common';
|
|
17
|
+
import { trace, SpanStatusCode, context } from '@opentelemetry/api';
|
|
18
|
+
|
|
19
|
+
const tracer = trace.getTracer('order-service');
|
|
20
|
+
|
|
21
|
+
@Injectable()
|
|
22
|
+
export class OrderService {
|
|
23
|
+
async createOrder(dto: CreateOrderDto): Promise<Order> {
|
|
24
|
+
return tracer.startActiveSpan('order.create', async (span) => {
|
|
25
|
+
try {
|
|
26
|
+
span.setAttributes({
|
|
27
|
+
'order.user_id': dto.userId,
|
|
28
|
+
'order.item_count': dto.items.length,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const order = await this.repo.save(dto);
|
|
32
|
+
|
|
33
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
34
|
+
return order;
|
|
35
|
+
} catch (err) {
|
|
36
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: (err as Error).message });
|
|
37
|
+
span.recordException(err as Error);
|
|
38
|
+
throw err;
|
|
39
|
+
} finally {
|
|
40
|
+
span.end();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 1.2 Child span inside an active span
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { trace, context } from '@opentelemetry/api';
|
|
51
|
+
|
|
52
|
+
const tracer = trace.getTracer('payment-service');
|
|
53
|
+
|
|
54
|
+
async function chargeCard(orderId: string, amount: number) {
|
|
55
|
+
// Inherits the active context automatically
|
|
56
|
+
return tracer.startActiveSpan('payment.charge', async (span) => {
|
|
57
|
+
span.setAttributes({ 'payment.order_id': orderId, 'payment.amount': amount });
|
|
58
|
+
try {
|
|
59
|
+
const result = await gateway.charge(amount);
|
|
60
|
+
return result;
|
|
61
|
+
} finally {
|
|
62
|
+
span.end();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 1.3 Span decorator (reusable)
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// otel-span.decorator.ts
|
|
72
|
+
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
73
|
+
|
|
74
|
+
export function OtelSpan(name?: string) {
|
|
75
|
+
return function (target: any, propertyKey: string, descriptor: PropertyDescriptor) {
|
|
76
|
+
const original = descriptor.value;
|
|
77
|
+
const spanName = name ?? `${target.constructor.name}.${propertyKey}`;
|
|
78
|
+
const tracer = trace.getTracer(target.constructor.name);
|
|
79
|
+
|
|
80
|
+
descriptor.value = async function (...args: any[]) {
|
|
81
|
+
return tracer.startActiveSpan(spanName, async (span) => {
|
|
82
|
+
try {
|
|
83
|
+
const result = await original.apply(this, args);
|
|
84
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
85
|
+
return result;
|
|
86
|
+
} catch (err) {
|
|
87
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: (err as Error).message });
|
|
88
|
+
span.recordException(err as Error);
|
|
89
|
+
throw err;
|
|
90
|
+
} finally {
|
|
91
|
+
span.end();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return descriptor;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
// notification.service.ts
|
|
103
|
+
@Injectable()
|
|
104
|
+
export class NotificationService {
|
|
105
|
+
@OtelSpan('notification.send_email')
|
|
106
|
+
async sendEmail(to: string, subject: string) {
|
|
107
|
+
// ...
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 1.4 Trace interceptor (applies to every controller handler)
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
// trace.interceptor.ts
|
|
116
|
+
import {
|
|
117
|
+
Injectable,
|
|
118
|
+
NestInterceptor,
|
|
119
|
+
ExecutionContext,
|
|
120
|
+
CallHandler,
|
|
121
|
+
} from '@nestjs/common';
|
|
122
|
+
import { Observable, throwError } from 'rxjs';
|
|
123
|
+
import { catchError, tap } from 'rxjs/operators';
|
|
124
|
+
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
125
|
+
import { Request } from 'express';
|
|
126
|
+
|
|
127
|
+
@Injectable()
|
|
128
|
+
export class TraceInterceptor implements NestInterceptor {
|
|
129
|
+
intercept(ctx: ExecutionContext, next: CallHandler): Observable<any> {
|
|
130
|
+
const req: Request = ctx.switchToHttp().getRequest();
|
|
131
|
+
const tracer = trace.getTracer('http-interceptor');
|
|
132
|
+
const spanName = `${ctx.getClass().name}.${ctx.getHandler().name}`;
|
|
133
|
+
|
|
134
|
+
const span = tracer.startSpan(spanName, {
|
|
135
|
+
attributes: {
|
|
136
|
+
'http.method': req.method,
|
|
137
|
+
'http.url': req.url,
|
|
138
|
+
'http.route': req.route?.path,
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return next.handle().pipe(
|
|
143
|
+
tap(() => {
|
|
144
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
145
|
+
span.end();
|
|
146
|
+
}),
|
|
147
|
+
catchError((err) => {
|
|
148
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: err.message });
|
|
149
|
+
span.recordException(err);
|
|
150
|
+
span.end();
|
|
151
|
+
return throwError(() => err);
|
|
152
|
+
}),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 2 — Custom Metrics
|
|
161
|
+
|
|
162
|
+
### 2.1 Counter
|
|
163
|
+
|
|
164
|
+
```typescript
|
|
165
|
+
// order.metrics.ts
|
|
166
|
+
import { Injectable, OnModuleInit } from '@nestjs/common';
|
|
167
|
+
import { metrics, Counter } from '@opentelemetry/api';
|
|
168
|
+
|
|
169
|
+
@Injectable()
|
|
170
|
+
export class OrderMetrics implements OnModuleInit {
|
|
171
|
+
private ordersCreated: Counter;
|
|
172
|
+
|
|
173
|
+
onModuleInit() {
|
|
174
|
+
const meter = metrics.getMeter('order-service');
|
|
175
|
+
this.ordersCreated = meter.createCounter('orders.created', {
|
|
176
|
+
description: 'Total number of orders created',
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
recordOrderCreated(status: string) {
|
|
181
|
+
this.ordersCreated.add(1, { 'order.status': status });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### 2.2 Histogram (latency / duration)
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// db.metrics.ts
|
|
190
|
+
import { Injectable, OnModuleInit } from '@nestjs/common';
|
|
191
|
+
import { metrics, Histogram } from '@opentelemetry/api';
|
|
192
|
+
|
|
193
|
+
@Injectable()
|
|
194
|
+
export class DbMetrics implements OnModuleInit {
|
|
195
|
+
private queryDuration: Histogram;
|
|
196
|
+
|
|
197
|
+
onModuleInit() {
|
|
198
|
+
const meter = metrics.getMeter('database');
|
|
199
|
+
this.queryDuration = meter.createHistogram('db.query.duration', {
|
|
200
|
+
description: 'Database query duration in milliseconds',
|
|
201
|
+
unit: 'ms',
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async measureQuery<T>(table: string, fn: () => Promise<T>): Promise<T> {
|
|
206
|
+
const start = Date.now();
|
|
207
|
+
try {
|
|
208
|
+
return await fn();
|
|
209
|
+
} finally {
|
|
210
|
+
this.queryDuration.record(Date.now() - start, { 'db.table': table });
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 2.3 Observable gauge (active sessions)
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// session.metrics.ts
|
|
220
|
+
import { Injectable, OnModuleInit } from '@nestjs/common';
|
|
221
|
+
import { metrics } from '@opentelemetry/api';
|
|
222
|
+
|
|
223
|
+
@Injectable()
|
|
224
|
+
export class SessionMetrics implements OnModuleInit {
|
|
225
|
+
private activeSessions = 0;
|
|
226
|
+
|
|
227
|
+
onModuleInit() {
|
|
228
|
+
const meter = metrics.getMeter('session-service');
|
|
229
|
+
meter.createObservableGauge('sessions.active', {
|
|
230
|
+
description: 'Number of currently active sessions',
|
|
231
|
+
}).addCallback((result) => {
|
|
232
|
+
result.observe(this.activeSessions);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
increment() { this.activeSessions++; }
|
|
237
|
+
decrement() { this.activeSessions--; }
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### 2.4 Metrics module (centralised)
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
// telemetry.module.ts
|
|
245
|
+
import { Module, Global } from '@nestjs/common';
|
|
246
|
+
import { OrderMetrics } from './order.metrics';
|
|
247
|
+
import { DbMetrics } from './db.metrics';
|
|
248
|
+
import { SessionMetrics } from './session.metrics';
|
|
249
|
+
|
|
250
|
+
@Global()
|
|
251
|
+
@Module({
|
|
252
|
+
providers: [OrderMetrics, DbMetrics, SessionMetrics],
|
|
253
|
+
exports: [OrderMetrics, DbMetrics, SessionMetrics],
|
|
254
|
+
})
|
|
255
|
+
export class TelemetryModule {}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 3 — Custom Logs
|
|
261
|
+
|
|
262
|
+
### 3.1 OtelLogger service
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// otel-logger.service.ts
|
|
266
|
+
import { Injectable } from '@nestjs/common';
|
|
267
|
+
import { logs, SeverityNumber } from '@opentelemetry/api-logs';
|
|
268
|
+
|
|
269
|
+
@Injectable()
|
|
270
|
+
export class OtelLoggerService {
|
|
271
|
+
private readonly logger = logs.getLogger('app');
|
|
272
|
+
|
|
273
|
+
info(body: string, attributes?: Record<string, any>) {
|
|
274
|
+
this.logger.emit({
|
|
275
|
+
severityNumber: SeverityNumber.INFO,
|
|
276
|
+
severityText: 'INFO',
|
|
277
|
+
body,
|
|
278
|
+
attributes,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
warn(body: string, attributes?: Record<string, any>) {
|
|
283
|
+
this.logger.emit({
|
|
284
|
+
severityNumber: SeverityNumber.WARN,
|
|
285
|
+
severityText: 'WARN',
|
|
286
|
+
body,
|
|
287
|
+
attributes,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
error(body: string, err?: Error, attributes?: Record<string, any>) {
|
|
292
|
+
this.logger.emit({
|
|
293
|
+
severityNumber: SeverityNumber.ERROR,
|
|
294
|
+
severityText: 'ERROR',
|
|
295
|
+
body,
|
|
296
|
+
attributes: {
|
|
297
|
+
...attributes,
|
|
298
|
+
'exception.message': err?.message,
|
|
299
|
+
'exception.stacktrace': err?.stack,
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
### 3.2 Using OtelLoggerService in a service
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
// auth.service.ts
|
|
310
|
+
@Injectable()
|
|
311
|
+
export class AuthService {
|
|
312
|
+
constructor(private readonly otelLogger: OtelLoggerService) {}
|
|
313
|
+
|
|
314
|
+
async login(dto: LoginDto) {
|
|
315
|
+
try {
|
|
316
|
+
const token = await this.issueToken(dto);
|
|
317
|
+
this.otelLogger.info('User login succeeded', { 'user.id': dto.userId });
|
|
318
|
+
return token;
|
|
319
|
+
} catch (err) {
|
|
320
|
+
this.otelLogger.error('User login failed', err as Error, { 'user.id': dto.userId });
|
|
321
|
+
throw err;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### 3.3 Correlating logs with the active trace
|
|
328
|
+
|
|
329
|
+
Log records emitted while an active span exists are automatically correlated by the SDK via `traceId` / `spanId`. To add them explicitly:
|
|
330
|
+
|
|
331
|
+
```typescript
|
|
332
|
+
import { logs, SeverityNumber } from '@opentelemetry/api-logs';
|
|
333
|
+
import { trace, context } from '@opentelemetry/api';
|
|
334
|
+
|
|
335
|
+
function emitCorrelatedLog(body: string) {
|
|
336
|
+
const span = trace.getActiveSpan();
|
|
337
|
+
const spanCtx = span?.spanContext();
|
|
338
|
+
|
|
339
|
+
logs.getLogger('app').emit({
|
|
340
|
+
severityNumber: SeverityNumber.INFO,
|
|
341
|
+
severityText: 'INFO',
|
|
342
|
+
body,
|
|
343
|
+
attributes: {
|
|
344
|
+
'trace.id': spanCtx?.traceId,
|
|
345
|
+
'span.id': spanCtx?.spanId,
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## 4 — Putting It All Together
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// order.service.ts
|
|
357
|
+
import { Injectable } from '@nestjs/common';
|
|
358
|
+
import { trace, SpanStatusCode } from '@opentelemetry/api';
|
|
359
|
+
import { OrderMetrics } from './order.metrics';
|
|
360
|
+
import { OtelLoggerService } from './otel-logger.service';
|
|
361
|
+
|
|
362
|
+
const tracer = trace.getTracer('order-service');
|
|
363
|
+
|
|
364
|
+
@Injectable()
|
|
365
|
+
export class OrderService {
|
|
366
|
+
constructor(
|
|
367
|
+
private readonly metrics: OrderMetrics,
|
|
368
|
+
private readonly logger: OtelLoggerService,
|
|
369
|
+
) {}
|
|
370
|
+
|
|
371
|
+
async createOrder(dto: CreateOrderDto): Promise<Order> {
|
|
372
|
+
return tracer.startActiveSpan('order.create', async (span) => {
|
|
373
|
+
span.setAttributes({ 'order.user_id': dto.userId });
|
|
374
|
+
try {
|
|
375
|
+
const order = await this.repo.save(dto);
|
|
376
|
+
this.metrics.recordOrderCreated('success');
|
|
377
|
+
this.logger.info('Order created', { 'order.id': order.id });
|
|
378
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
379
|
+
return order;
|
|
380
|
+
} catch (err) {
|
|
381
|
+
this.metrics.recordOrderCreated('error');
|
|
382
|
+
this.logger.error('Order creation failed', err as Error, { 'order.user_id': dto.userId });
|
|
383
|
+
span.setStatus({ code: SpanStatusCode.ERROR, message: (err as Error).message });
|
|
384
|
+
span.recordException(err as Error);
|
|
385
|
+
throw err;
|
|
386
|
+
} finally {
|
|
387
|
+
span.end();
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
```
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @eqxjs/nest-opentelemetry
|
|
2
2
|
|
|
3
|
-
**Version: 3.
|
|
3
|
+
**Version: 3.2.0** (stable)
|
|
4
4
|
|
|
5
5
|
OpenTelemetry auto-instrumentation for NestJS applications. Wraps `@opentelemetry/sdk-node` with a pre-configured set of instrumentations, exporters, and resource detectors — all driven by environment variables.
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ OpenTelemetry auto-instrumentation for NestJS applications. Wraps `@opentelemetr
|
|
|
11
11
|
- **Custom Kafka span enrichment** — supports KafkaJS, `eqxjs-kafkajs`, and Confluent Kafka with M1/M2/M3 message protocol parsing
|
|
12
12
|
- **Custom Socket.IO span enrichment** — captures socket ID, key, and M1 protocol attributes
|
|
13
13
|
- **Cloud resource detection** — automatic detection for AWS, Azure, GCP, Alibaba, container, and more
|
|
14
|
-
- **Graceful shutdown** — listens for `SIGTERM` and flushes telemetry before exit
|
|
14
|
+
- **Graceful shutdown** — listens for `SIGTERM` and `beforeExit` and flushes telemetry before exit
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
@@ -64,6 +64,7 @@ Use `getNodeAutoInstrumentations(config?)` to build the instrumentation list wit
|
|
|
64
64
|
| `APPLICATIONINSIGHTS_CONNECTION_STRING_METRIC` | Azure Monitor connection string for metrics (takes priority over `METRICS_URL`) |
|
|
65
65
|
| `APPLICATIONINSIGHTS_CONNECTION_STRING_LOG` | Azure Monitor connection string for logs (takes priority over `LOGGER_URL`) |
|
|
66
66
|
| `METRIC_EXPORT_INTERVAL` | Metrics export interval in milliseconds (default: `60000`) |
|
|
67
|
+
| `METRIC_PROMETHEUS_PORT` | Expose a Prometheus scrape endpoint on this port (e.g. `8081`). Takes effect only when neither `APPLICATIONINSIGHTS_CONNECTION_STRING_METRIC` nor `METRICS_URL` is set. |
|
|
67
68
|
|
|
68
69
|
### Instrumentation
|
|
69
70
|
|
|
@@ -88,6 +89,7 @@ Valid values for `OTEL_NODE_ENABLED_INSTRUMENTATIONS`:
|
|
|
88
89
|
| `dns` | DNS |
|
|
89
90
|
| `eqxjs-ioredis` | EqxJS IORedis |
|
|
90
91
|
| `eqxjs-kafkajs` | EqxJS KafkaJS |
|
|
92
|
+
| `mongodb2` | MongoDB (legacy v2 driver) |
|
|
91
93
|
| `express` | Express |
|
|
92
94
|
| `fastify` | Fastify |
|
|
93
95
|
| `fs` | File System (fs) |
|
|
@@ -167,7 +169,8 @@ Available detector values:
|
|
|
167
169
|
| EqxJS KafkaJS | `opentelemetry-instrumentation-eqxjs-kafkajs` |
|
|
168
170
|
| Confluent Kafka | `opentelemetry-instrumentation-confluent-kafka` |
|
|
169
171
|
| AMQP (RabbitMQ) | `@opentelemetry/instrumentation-amqplib` |
|
|
170
|
-
| MongoDB | `@opentelemetry/instrumentation-mongodb`
|
|
172
|
+
| MongoDB | `@opentelemetry/instrumentation-mongodb` (enhanced reporting enabled) |
|
|
173
|
+
| MongoDB v2 driver | `opentelemetry-instrumentation-mongodb2` (enhanced reporting enabled) |
|
|
171
174
|
| Mongoose | `@opentelemetry/instrumentation-mongoose` |
|
|
172
175
|
| PostgreSQL | `@opentelemetry/instrumentation-pg` |
|
|
173
176
|
| MySQL / MySQL2 | `@opentelemetry/instrumentation-mysql`, `@opentelemetry/instrumentation-mysql2` |
|
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setSpanToM1 = setSpanToM1;
|
|
4
4
|
const m2_common_1 = require("./m2.common");
|
|
5
5
|
function setSpanToM1(span, m1Message) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
span.setAttribute("M1.protocol.version", (_b = m1Message.protocol) === null || _b === void 0 ? void 0 : _b.version);
|
|
6
|
+
if (m1Message.protocol?.version) {
|
|
7
|
+
span.setAttribute("M1.protocol.version", m1Message.protocol?.version);
|
|
9
8
|
}
|
|
10
|
-
if (
|
|
11
|
-
span.setAttribute("M1.protocol.command",
|
|
9
|
+
if (m1Message.protocol?.command) {
|
|
10
|
+
span.setAttribute("M1.protocol.command", m1Message.protocol?.command);
|
|
12
11
|
}
|
|
13
|
-
if (
|
|
14
|
-
span.setAttribute("M1.protocol.sub_command",
|
|
12
|
+
if (m1Message.protocol?.subCommand) {
|
|
13
|
+
span.setAttribute("M1.protocol.sub_command", m1Message.protocol?.subCommand);
|
|
15
14
|
}
|
|
16
|
-
if (
|
|
17
|
-
span.setAttribute("M1.protocol.invoke",
|
|
15
|
+
if (m1Message.protocol?.invoke) {
|
|
16
|
+
span.setAttribute("M1.protocol.invoke", m1Message.protocol?.invoke);
|
|
18
17
|
}
|
|
19
|
-
if (
|
|
20
|
-
span.setAttribute("M1.protocol.topic",
|
|
18
|
+
if (m1Message.protocol?.topic) {
|
|
19
|
+
span.setAttribute("M1.protocol.topic", m1Message.protocol?.topic);
|
|
21
20
|
}
|
|
22
21
|
(0, m2_common_1.setSpanToM2)(span, m1Message);
|
|
23
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m1.common.js","sourceRoot":"","sources":["../../../src/extend/common/m1.common.ts"],"names":[],"mappings":";;AAIA,kCAoBC;AAtBD,2CAA0C;AAE1C,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB
|
|
1
|
+
{"version":3,"file":"m1.common.js","sourceRoot":"","sources":["../../../src/extend/common/m1.common.ts"],"names":[],"mappings":";;AAIA,kCAoBC;AAtBD,2CAA0C;AAE1C,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB;IACxD,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QAChC,IAAI,CAAC,YAAY,CAAC,qBAAqB,EAAE,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CACf,yBAAyB,EACzB,SAAS,CAAC,QAAQ,EAAE,UAAU,CAC/B,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,SAAS,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IACD,IAAA,uBAAW,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -3,46 +3,45 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setSpanToM2 = setSpanToM2;
|
|
4
4
|
const generic_common_1 = require("./generic.common");
|
|
5
5
|
function setSpanToM2(span, m2Message) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3;
|
|
7
6
|
(0, generic_common_1.setSpanHookGeneric)(span);
|
|
8
|
-
if (
|
|
9
|
-
span.setAttribute("enduser.id",
|
|
7
|
+
if (m2Message.header?.identity?.user) {
|
|
8
|
+
span.setAttribute("enduser.id", m2Message.header?.identity?.user);
|
|
10
9
|
}
|
|
11
|
-
if (
|
|
12
|
-
span.setAttribute("M2.header.version",
|
|
10
|
+
if (m2Message.header?.version) {
|
|
11
|
+
span.setAttribute("M2.header.version", m2Message.header?.version);
|
|
13
12
|
}
|
|
14
|
-
if (
|
|
15
|
-
span.setAttribute("M2.header.org_service",
|
|
13
|
+
if (m2Message.header?.orgService) {
|
|
14
|
+
span.setAttribute("M2.header.org_service", m2Message.header?.orgService);
|
|
16
15
|
}
|
|
17
|
-
if (
|
|
18
|
-
span.setAttribute("M2.header.from",
|
|
16
|
+
if (m2Message.header?.from) {
|
|
17
|
+
span.setAttribute("M2.header.from", m2Message.header?.from);
|
|
19
18
|
}
|
|
20
|
-
if (
|
|
21
|
-
span.setAttribute("M2.header.channel",
|
|
19
|
+
if (m2Message.header?.channel) {
|
|
20
|
+
span.setAttribute("M2.header.channel", m2Message.header?.channel);
|
|
22
21
|
}
|
|
23
|
-
if (
|
|
24
|
-
span.setAttribute("M2.header.broker",
|
|
22
|
+
if (m2Message.header?.broker) {
|
|
23
|
+
span.setAttribute("M2.header.broker", m2Message.header?.broker);
|
|
25
24
|
}
|
|
26
|
-
if (
|
|
27
|
-
span.setAttribute("M2.header.agent",
|
|
25
|
+
if (m2Message.header?.agent) {
|
|
26
|
+
span.setAttribute("M2.header.agent", m2Message.header?.agent);
|
|
28
27
|
}
|
|
29
|
-
if (
|
|
30
|
-
span.setAttribute("M2.header.useCase",
|
|
28
|
+
if (m2Message.header?.useCase) {
|
|
29
|
+
span.setAttribute("M2.header.useCase", m2Message.header?.useCase);
|
|
31
30
|
}
|
|
32
|
-
if (
|
|
33
|
-
span.setAttribute("M2.header.use_case_step",
|
|
31
|
+
if (m2Message.header?.useCaseStep) {
|
|
32
|
+
span.setAttribute("M2.header.use_case_step", m2Message.header?.useCaseStep);
|
|
34
33
|
}
|
|
35
|
-
if (
|
|
36
|
-
span.setAttribute("M2.header.use_case_age",
|
|
34
|
+
if (m2Message.header?.useCaseAge) {
|
|
35
|
+
span.setAttribute("M2.header.use_case_age", m2Message.header?.useCaseAge);
|
|
37
36
|
}
|
|
38
|
-
if (
|
|
39
|
-
span.setAttribute("M2.header.function_name",
|
|
37
|
+
if (m2Message.header?.functionName) {
|
|
38
|
+
span.setAttribute("M2.header.function_name", m2Message.header?.functionName);
|
|
40
39
|
}
|
|
41
|
-
if (
|
|
42
|
-
span.setAttribute("M2.header.session",
|
|
40
|
+
if (m2Message.header?.session) {
|
|
41
|
+
span.setAttribute("M2.header.session", m2Message.header?.session);
|
|
43
42
|
}
|
|
44
|
-
if (
|
|
45
|
-
span.setAttribute("M2.header.transaction",
|
|
43
|
+
if (m2Message.header?.transaction) {
|
|
44
|
+
span.setAttribute("M2.header.transaction", m2Message.header?.transaction);
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
//# sourceMappingURL=m2.common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m2.common.js","sourceRoot":"","sources":["../../../src/extend/common/m2.common.ts"],"names":[],"mappings":";;AAIA,kCA4CC;AA9CD,qDAAsD;AAEtD,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB
|
|
1
|
+
{"version":3,"file":"m2.common.js","sourceRoot":"","sources":["../../../src/extend/common/m2.common.ts"],"names":[],"mappings":";;AAIA,kCA4CC;AA9CD,qDAAsD;AAEtD,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB;IACxD,IAAA,mCAAkB,EAAC,IAAI,CAAC,CAAC;IACzB,IAAI,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;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AC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC;QACnC,IAAI,CAAC,YAAY,CACf,yBAAyB,EACzB,SAAS,CAAC,MAAM,EAAE,YAAY,CAC/B,CAAC;IACJ,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IACD,IAAI,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC;QAClC,IAAI,CAAC,YAAY,CAAC,uBAAuB,EAAE,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -3,49 +3,48 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setSpanToM3 = setSpanToM3;
|
|
4
4
|
const generic_common_1 = require("./generic.common");
|
|
5
5
|
function setSpanToM3(span, m3Message) {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
|
|
7
6
|
(0, generic_common_1.setSpanHookGeneric)(span);
|
|
8
|
-
if (
|
|
9
|
-
span.setAttribute("enduser.id",
|
|
7
|
+
if (m3Message.service?.identity?.user) {
|
|
8
|
+
span.setAttribute("enduser.id", m3Message.service?.identity?.user);
|
|
10
9
|
}
|
|
11
|
-
if (
|
|
12
|
-
span.setAttribute("M3.service.version",
|
|
10
|
+
if (m3Message.service?.version) {
|
|
11
|
+
span.setAttribute("M3.service.version", m3Message.service?.version);
|
|
13
12
|
}
|
|
14
|
-
if (
|
|
15
|
-
span.setAttribute("M3.service.version",
|
|
13
|
+
if (m3Message.service?.version) {
|
|
14
|
+
span.setAttribute("M3.service.version", m3Message.service?.version);
|
|
16
15
|
}
|
|
17
|
-
if (
|
|
18
|
-
span.setAttribute("M3.service.org_service",
|
|
16
|
+
if (m3Message.service?.orgService) {
|
|
17
|
+
span.setAttribute("M3.service.org_service", m3Message.service?.orgService);
|
|
19
18
|
}
|
|
20
|
-
if (
|
|
21
|
-
span.setAttribute("M3.service.from",
|
|
19
|
+
if (m3Message.service?.from) {
|
|
20
|
+
span.setAttribute("M3.service.from", m3Message.service?.from);
|
|
22
21
|
}
|
|
23
|
-
if (
|
|
24
|
-
span.setAttribute("M3.service.channel",
|
|
22
|
+
if (m3Message.service?.channel) {
|
|
23
|
+
span.setAttribute("M3.service.channel", m3Message.service?.channel);
|
|
25
24
|
}
|
|
26
|
-
if (
|
|
27
|
-
span.setAttribute("M3.service.broker",
|
|
25
|
+
if (m3Message.service?.broker) {
|
|
26
|
+
span.setAttribute("M3.service.broker", m3Message.service?.broker);
|
|
28
27
|
}
|
|
29
|
-
if (
|
|
30
|
-
span.setAttribute("M3.service.agent",
|
|
28
|
+
if (m3Message.service?.agent) {
|
|
29
|
+
span.setAttribute("M3.service.agent", m3Message.service?.agent);
|
|
31
30
|
}
|
|
32
|
-
if (
|
|
33
|
-
span.setAttribute("M3.service.useCase",
|
|
31
|
+
if (m3Message.service?.useCase) {
|
|
32
|
+
span.setAttribute("M3.service.useCase", m3Message.service?.useCase);
|
|
34
33
|
}
|
|
35
|
-
if (
|
|
36
|
-
span.setAttribute("M3.service.use_case_step",
|
|
34
|
+
if (m3Message.service?.useCaseStep) {
|
|
35
|
+
span.setAttribute("M3.service.use_case_step", m3Message.service?.useCaseStep);
|
|
37
36
|
}
|
|
38
|
-
if (
|
|
39
|
-
span.setAttribute("M3.service.use_case_age",
|
|
37
|
+
if (m3Message.service?.useCaseAge) {
|
|
38
|
+
span.setAttribute("M3.service.use_case_age", m3Message.service?.useCaseAge);
|
|
40
39
|
}
|
|
41
|
-
if (
|
|
42
|
-
span.setAttribute("M3.service.function_name",
|
|
40
|
+
if (m3Message.service?.functionName) {
|
|
41
|
+
span.setAttribute("M3.service.function_name", m3Message.service?.functionName);
|
|
43
42
|
}
|
|
44
|
-
if (
|
|
45
|
-
span.setAttribute("M3.service.session",
|
|
43
|
+
if (m3Message.service?.session) {
|
|
44
|
+
span.setAttribute("M3.service.session", m3Message.service?.session);
|
|
46
45
|
}
|
|
47
|
-
if (
|
|
48
|
-
span.setAttribute("M3.service.transaction",
|
|
46
|
+
if (m3Message.service?.transaction) {
|
|
47
|
+
span.setAttribute("M3.service.transaction", m3Message.service?.transaction);
|
|
49
48
|
}
|
|
50
49
|
}
|
|
51
50
|
//# sourceMappingURL=m3.common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"m3.common.js","sourceRoot":"","sources":["../../../src/extend/common/m3.common.ts"],"names":[],"mappings":";;AAIA,kCAkDC;AApDD,qDAAsD;AAEtD,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB
|
|
1
|
+
{"version":3,"file":"m3.common.js","sourceRoot":"","sources":["../../../src/extend/common/m3.common.ts"],"names":[],"mappings":";;AAIA,kCAkDC;AApDD,qDAAsD;AAEtD,SAAgB,WAAW,CAAC,IAAU,EAAE,SAAkB;IACxD,IAAA,mCAAkB,EAAC,IAAI,CAAC,CAAC;IACzB,IAAI,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACtC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,YAAY,CAAC,oBAAoB,EAAE,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACtE,CAAC;IACD,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