@nestjs/observe 0.0.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/LICENSE +23 -0
- package/README.md +135 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/agent/detached-observe-worker.d.ts +1 -0
- package/dist/agent/detached-observe-worker.js +104 -0
- package/dist/agent/observe-agent.shared-buffer.d.ts +42 -0
- package/dist/agent/observe-agent.shared-buffer.js +211 -0
- package/dist/agent/observe-agent.worker.d.ts +25 -0
- package/dist/agent/observe-agent.worker.js +213 -0
- package/dist/custom-metrics/counter.d.ts +39 -0
- package/dist/custom-metrics/counter.js +128 -0
- package/dist/custom-metrics/gauge.d.ts +40 -0
- package/dist/custom-metrics/gauge.js +134 -0
- package/dist/custom-metrics/index.d.ts +3 -0
- package/dist/custom-metrics/index.js +3 -0
- package/dist/custom-metrics/summary.d.ts +38 -0
- package/dist/custom-metrics/summary.js +106 -0
- package/dist/encoders/custom-metrics.encoder.d.ts +25 -0
- package/dist/encoders/custom-metrics.encoder.js +50 -0
- package/dist/encoders/job-snapshot.encoder.d.ts +28 -0
- package/dist/encoders/job-snapshot.encoder.js +28 -0
- package/dist/encoders/remap-keys.util.d.ts +1 -0
- package/dist/encoders/remap-keys.util.js +10 -0
- package/dist/encoders/request-snapshot.encoder.d.ts +33 -0
- package/dist/encoders/request-snapshot.encoder.js +32 -0
- package/dist/encoders/runtime-metrics.encoder.d.ts +63 -0
- package/dist/encoders/runtime-metrics.encoder.js +55 -0
- package/dist/encoders/trace.encoder.d.ts +19 -0
- package/dist/encoders/trace.encoder.js +20 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/instrument/create-instance-decorator.instrument.d.ts +7 -0
- package/dist/instrument/create-instance-decorator.instrument.js +165 -0
- package/dist/interfaces/custom-metric.interface.d.ts +18 -0
- package/dist/interfaces/custom-metric.interface.js +1 -0
- package/dist/interfaces/graphql.interfaces.d.ts +12 -0
- package/dist/interfaces/graphql.interfaces.js +1 -0
- package/dist/interfaces/index.d.ts +7 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/job-snapshot.interface.d.ts +23 -0
- package/dist/interfaces/job-snapshot.interface.js +1 -0
- package/dist/interfaces/node-runtime-metrics.interface.d.ts +37 -0
- package/dist/interfaces/node-runtime-metrics.interface.js +1 -0
- package/dist/interfaces/observe-options.interface.d.ts +93 -0
- package/dist/interfaces/observe-options.interface.js +1 -0
- package/dist/interfaces/request-snapshot.interface.d.ts +23 -0
- package/dist/interfaces/request-snapshot.interface.js +1 -0
- package/dist/interfaces/trace-events.interfaces.d.ts +17 -0
- package/dist/interfaces/trace-events.interfaces.js +1 -0
- package/dist/interfaces/trace-span.interface.d.ts +12 -0
- package/dist/interfaces/trace-span.interface.js +1 -0
- package/dist/observe.constants.d.ts +2 -0
- package/dist/observe.constants.js +2 -0
- package/dist/observe.module.d.ts +20 -0
- package/dist/observe.module.js +181 -0
- package/dist/profiling/cpu-profiler.service.d.ts +45 -0
- package/dist/profiling/cpu-profiler.service.js +146 -0
- package/dist/profiling/fold-profile.util.d.ts +28 -0
- package/dist/profiling/fold-profile.util.js +0 -0
- package/dist/profiling/profile-uploader.d.ts +19 -0
- package/dist/profiling/profile-uploader.js +88 -0
- package/dist/profiling/span-slice-recorder.d.ts +18 -0
- package/dist/profiling/span-slice-recorder.js +78 -0
- package/dist/protocols/graphql-observe-agent.service.d.ts +58 -0
- package/dist/protocols/graphql-observe-agent.service.js +261 -0
- package/dist/protocols/graphql-operation-parser.d.ts +10 -0
- package/dist/protocols/graphql-operation-parser.js +174 -0
- package/dist/protocols/http-observe-agent.service.d.ts +31 -0
- package/dist/protocols/http-observe-agent.service.js +186 -0
- package/dist/protocols/queue-observe-agent.service.d.ts +15 -0
- package/dist/protocols/queue-observe-agent.service.js +132 -0
- package/dist/protocols/rpc-observe-agent.service.d.ts +33 -0
- package/dist/protocols/rpc-observe-agent.service.js +183 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/logger-patcher.service.d.ts +12 -0
- package/dist/services/logger-patcher.service.js +76 -0
- package/dist/services/node-runtime-metrics.service.d.ts +23 -0
- package/dist/services/node-runtime-metrics.service.js +156 -0
- package/dist/services/operation-trace.registry.d.ts +49 -0
- package/dist/services/operation-trace.registry.js +364 -0
- package/dist/services/stdout-forwarder.service.d.ts +21 -0
- package/dist/services/stdout-forwarder.service.js +128 -0
- package/dist/services/trace-sampler.service.d.ts +19 -0
- package/dist/services/trace-sampler.service.js +38 -0
- package/dist/services/tracer.service.d.ts +48 -0
- package/dist/services/tracer.service.js +186 -0
- package/dist/trace-span.delegate.d.ts +10 -0
- package/dist/trace-span.delegate.js +24 -0
- package/dist/types/key-of.type.d.ts +1 -0
- package/dist/types/key-of.type.js +1 -0
- package/dist/types/path-value.type.d.ts +6 -0
- package/dist/types/path-value.type.js +1 -0
- package/dist/utils/assert-module-options.util.d.ts +2 -0
- package/dist/utils/assert-module-options.util.js +8 -0
- package/dist/utils/default-trace-id-generator.util.d.ts +1 -0
- package/dist/utils/default-trace-id-generator.util.js +11 -0
- package/dist/utils/log-line.parser.d.ts +9 -0
- package/dist/utils/log-line.parser.js +59 -0
- package/dist/utils/log-redactor.d.ts +11 -0
- package/dist/utils/log-redactor.js +150 -0
- package/dist/utils/redact-url-query.d.ts +2 -0
- package/dist/utils/redact-url-query.js +51 -0
- package/dist/utils/source-context.util.d.ts +11 -0
- package/dist/utils/source-context.util.js +130 -0
- package/dist/utils/source-map-resolver.util.d.ts +7 -0
- package/dist/utils/source-map-resolver.util.js +107 -0
- package/package.json +129 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var QueueObserveAgentService_1;
|
|
14
|
+
import { ProcessorDecoratorService } from "@nestjs/bullmq/dist/instrument/processor-decorator.service.js";
|
|
15
|
+
import { Inject, Injectable, Logger } from "@nestjs/common";
|
|
16
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
17
|
+
import { randomUUID } from "crypto";
|
|
18
|
+
import { ObserveAgentSharedBuffer } from "../agent/observe-agent.shared-buffer.js";
|
|
19
|
+
import { OperationTraceRegistry } from "../services/operation-trace.registry.js";
|
|
20
|
+
import { OBSERVE_OPTIONS } from "../observe.constants.js";
|
|
21
|
+
let QueueObserveAgentService = QueueObserveAgentService_1 = class QueueObserveAgentService {
|
|
22
|
+
observeAgentSharedBuffer;
|
|
23
|
+
options;
|
|
24
|
+
operationTraceRegistry;
|
|
25
|
+
asyncLocalStorage;
|
|
26
|
+
logger = new Logger(QueueObserveAgentService_1.name);
|
|
27
|
+
constructor(observeAgentSharedBuffer, options, operationTraceRegistry, asyncLocalStorage) {
|
|
28
|
+
this.observeAgentSharedBuffer = observeAgentSharedBuffer;
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.operationTraceRegistry = operationTraceRegistry;
|
|
31
|
+
this.asyncLocalStorage = asyncLocalStorage;
|
|
32
|
+
this.patchDecorate();
|
|
33
|
+
}
|
|
34
|
+
readQueueMetadata(job) {
|
|
35
|
+
const metadata = {};
|
|
36
|
+
if (typeof job.timestamp === "number") {
|
|
37
|
+
metadata.enqueuedAt = new Date(job.timestamp).toISOString();
|
|
38
|
+
const startedAt = typeof job.processedOn === "number" ? job.processedOn : Date.now();
|
|
39
|
+
const availableAt = job.timestamp + (job.delay ?? 0);
|
|
40
|
+
metadata.waitDuration = Math.max(0, startedAt - availableAt);
|
|
41
|
+
}
|
|
42
|
+
if (typeof job.attemptsMade === "number") {
|
|
43
|
+
metadata.attemptsMade = job.attemptsMade;
|
|
44
|
+
}
|
|
45
|
+
const maxAttempts = job.opts?.attempts;
|
|
46
|
+
if (typeof maxAttempts === "number") {
|
|
47
|
+
metadata.maxAttempts = maxAttempts;
|
|
48
|
+
}
|
|
49
|
+
return metadata;
|
|
50
|
+
}
|
|
51
|
+
patchDecorate() {
|
|
52
|
+
if (!ProcessorDecoratorService?.prototype) {
|
|
53
|
+
this.logger.warn("ProcessorDecoratorService is not available. Please, update to the latest version of @nestjs/bullmq. Skipping patching.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
ProcessorDecoratorService.prototype["decorate"] =
|
|
57
|
+
(processor) => (job) => {
|
|
58
|
+
const hasOuterContext = this.asyncLocalStorage
|
|
59
|
+
.getStore()
|
|
60
|
+
?.has(this.options.traceIdKey);
|
|
61
|
+
const store = new Map();
|
|
62
|
+
return this.asyncLocalStorage.run(store, () => {
|
|
63
|
+
if (hasOuterContext) {
|
|
64
|
+
if (this.options.debug) {
|
|
65
|
+
this.logger.debug(`Outer context already has a trace ID. Skipping inner context for job "${job.name}" job.id: ${job.id}`);
|
|
66
|
+
}
|
|
67
|
+
return processor(job);
|
|
68
|
+
}
|
|
69
|
+
const traceId = randomUUID();
|
|
70
|
+
store.set(this.options.traceIdKey, traceId);
|
|
71
|
+
if (this.options.jobs?.setAttributes) {
|
|
72
|
+
const attributes = this.options.jobs?.setAttributes?.({
|
|
73
|
+
queueName: job.queueName,
|
|
74
|
+
name: job.name,
|
|
75
|
+
id: job.id,
|
|
76
|
+
});
|
|
77
|
+
if (attributes) {
|
|
78
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
79
|
+
store.set(key, value);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
this.operationTraceRegistry.startTrace(traceId, {
|
|
84
|
+
tags: this.options.jobs?.tags,
|
|
85
|
+
queueName: job.queueName,
|
|
86
|
+
name: job.name,
|
|
87
|
+
id: typeof job.id === "number" ? `${job.id}` : job.id,
|
|
88
|
+
...this.readQueueMetadata(job),
|
|
89
|
+
});
|
|
90
|
+
const endTrace = (status) => {
|
|
91
|
+
setTimeout(async () => {
|
|
92
|
+
this.operationTraceRegistry.endTrace(traceId, { status });
|
|
93
|
+
const snapshot = (await this.operationTraceRegistry.pluckSnapshot(traceId));
|
|
94
|
+
if (!snapshot) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
this.observeAgentSharedBuffer.insertJobSnapshot(snapshot);
|
|
98
|
+
}, 0);
|
|
99
|
+
};
|
|
100
|
+
try {
|
|
101
|
+
const returnValue = processor(job);
|
|
102
|
+
if (returnValue instanceof Promise) {
|
|
103
|
+
return returnValue
|
|
104
|
+
.then((ret) => {
|
|
105
|
+
endTrace("completed");
|
|
106
|
+
return ret;
|
|
107
|
+
})
|
|
108
|
+
.catch((error) => {
|
|
109
|
+
console.error("ending trace with error:", error);
|
|
110
|
+
endTrace("failed");
|
|
111
|
+
throw error;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
endTrace("completed");
|
|
115
|
+
return returnValue;
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error("rethrowing again?");
|
|
119
|
+
endTrace("failed");
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
QueueObserveAgentService = QueueObserveAgentService_1 = __decorate([
|
|
127
|
+
Injectable(),
|
|
128
|
+
__param(1, Inject(OBSERVE_OPTIONS)),
|
|
129
|
+
__metadata("design:paramtypes", [ObserveAgentSharedBuffer, Object, OperationTraceRegistry,
|
|
130
|
+
AsyncLocalStorage])
|
|
131
|
+
], QueueObserveAgentService);
|
|
132
|
+
export { QueueObserveAgentService };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OnModuleDestroy, OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { ModulesContainer } from "@nestjs/core";
|
|
3
|
+
import { BaseRpcContext, Server, Transport } from "@nestjs/microservices";
|
|
4
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
5
|
+
import { ObserveAgentSharedBuffer } from "../agent/observe-agent.shared-buffer.js";
|
|
6
|
+
import { ObserveModuleOptionsWithDefaults } from "../interfaces/observe-options.interface.js";
|
|
7
|
+
import { OperationTraceRegistry } from "../services/operation-trace.registry.js";
|
|
8
|
+
import { TraceSamplerService } from "../services/trace-sampler.service.js";
|
|
9
|
+
import { KeyOf } from "../types/key-of.type.js";
|
|
10
|
+
interface GrpcCall<TRequest = any, TMetadata = any> {
|
|
11
|
+
request: TRequest;
|
|
12
|
+
metadata: TMetadata;
|
|
13
|
+
operationId: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class RpcObserveAgentService<Store extends Record<string, unknown>> implements OnModuleInit, OnModuleDestroy {
|
|
16
|
+
private readonly asyncLocalStorage;
|
|
17
|
+
private readonly options;
|
|
18
|
+
private readonly modulesContainer;
|
|
19
|
+
private readonly operationTraceRegistry;
|
|
20
|
+
private readonly observeAgentSharedBuffer;
|
|
21
|
+
private readonly traceSamplerService;
|
|
22
|
+
private rpcTargetAddedSubscription;
|
|
23
|
+
constructor(asyncLocalStorage: AsyncLocalStorage<Map<KeyOf<Store>, any>>, options: ObserveModuleOptionsWithDefaults, modulesContainer: ModulesContainer, operationTraceRegistry: OperationTraceRegistry, observeAgentSharedBuffer: ObserveAgentSharedBuffer, traceSamplerService: TraceSamplerService);
|
|
24
|
+
onModuleInit(): void;
|
|
25
|
+
onModuleDestroy(): void;
|
|
26
|
+
registerRpcHooks(target: Server): void;
|
|
27
|
+
private toProtocolName;
|
|
28
|
+
startRpcRequestTracing(transportId: Transport | symbol, ctx: BaseRpcContext, done: () => Promise<any>): void;
|
|
29
|
+
startGrpcRequestTracing(transportId: Transport | symbol, call: GrpcCall, done: () => Promise<any>): void;
|
|
30
|
+
endRpcRequestTracing(transportId: Transport | symbol, ctx: BaseRpcContext | GrpcCall): void;
|
|
31
|
+
private getOperationIdFromContext;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Inject, Injectable, } from "@nestjs/common";
|
|
14
|
+
import { ModulesContainer } from "@nestjs/core";
|
|
15
|
+
import { KafkaContext, MqttContext, NatsContext, RedisContext, RmqContext, TcpContext, Transport, } from "@nestjs/microservices";
|
|
16
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
17
|
+
import { ObserveAgentSharedBuffer } from "../agent/observe-agent.shared-buffer.js";
|
|
18
|
+
import { OperationTraceRegistry } from "../services/operation-trace.registry.js";
|
|
19
|
+
import { TraceSamplerService } from "../services/trace-sampler.service.js";
|
|
20
|
+
import { OBSERVE_OPTIONS } from "../observe.constants.js";
|
|
21
|
+
let RpcObserveAgentService = class RpcObserveAgentService {
|
|
22
|
+
asyncLocalStorage;
|
|
23
|
+
options;
|
|
24
|
+
modulesContainer;
|
|
25
|
+
operationTraceRegistry;
|
|
26
|
+
observeAgentSharedBuffer;
|
|
27
|
+
traceSamplerService;
|
|
28
|
+
rpcTargetAddedSubscription;
|
|
29
|
+
constructor(asyncLocalStorage, options, modulesContainer, operationTraceRegistry, observeAgentSharedBuffer, traceSamplerService) {
|
|
30
|
+
this.asyncLocalStorage = asyncLocalStorage;
|
|
31
|
+
this.options = options;
|
|
32
|
+
this.modulesContainer = modulesContainer;
|
|
33
|
+
this.operationTraceRegistry = operationTraceRegistry;
|
|
34
|
+
this.observeAgentSharedBuffer = observeAgentSharedBuffer;
|
|
35
|
+
this.traceSamplerService = traceSamplerService;
|
|
36
|
+
}
|
|
37
|
+
onModuleInit() {
|
|
38
|
+
this.rpcTargetAddedSubscription = this.modulesContainer
|
|
39
|
+
.getRpcTargetRegistry?.()
|
|
40
|
+
.subscribe((target) => this.registerRpcHooks(target));
|
|
41
|
+
}
|
|
42
|
+
onModuleDestroy() {
|
|
43
|
+
if (this.rpcTargetAddedSubscription) {
|
|
44
|
+
this.rpcTargetAddedSubscription.unsubscribe();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
registerRpcHooks(target) {
|
|
48
|
+
target.setOnProcessingStartHook((transportId, ctx, done) => {
|
|
49
|
+
if (transportId === Transport.GRPC) {
|
|
50
|
+
this.startGrpcRequestTracing(transportId, ctx, done);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.startRpcRequestTracing(transportId, ctx, done);
|
|
54
|
+
});
|
|
55
|
+
target.setOnProcessingEndHook((transportId, ctx) => {
|
|
56
|
+
this.endRpcRequestTracing(transportId, ctx);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
toProtocolName(transportId) {
|
|
60
|
+
return typeof transportId === "symbol"
|
|
61
|
+
? transportId.description ?? "custom"
|
|
62
|
+
: Transport[transportId];
|
|
63
|
+
}
|
|
64
|
+
startRpcRequestTracing(transportId, ctx, done) {
|
|
65
|
+
const store = new Map();
|
|
66
|
+
this.asyncLocalStorage.run(store, () => {
|
|
67
|
+
const traceId = this.options.traceIdGenerator(ctx);
|
|
68
|
+
store.set(this.options.traceIdKey, traceId);
|
|
69
|
+
if (this.options.rpc?.setAttributes) {
|
|
70
|
+
const attributes = this.options.rpc?.setAttributes?.(transportId, ctx);
|
|
71
|
+
if (attributes) {
|
|
72
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
73
|
+
store.set(key, value);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (this.options.rpc?.ignore?.(transportId, ctx)) {
|
|
78
|
+
return done();
|
|
79
|
+
}
|
|
80
|
+
const shouldCapture = this.traceSamplerService.shouldCapture("rpc", {
|
|
81
|
+
transport: transportId.toString(),
|
|
82
|
+
ctx: ctx,
|
|
83
|
+
});
|
|
84
|
+
if (!shouldCapture) {
|
|
85
|
+
return done();
|
|
86
|
+
}
|
|
87
|
+
this.operationTraceRegistry.startTrace(traceId, {
|
|
88
|
+
protocol: this.toProtocolName(transportId),
|
|
89
|
+
operationId: this.getOperationIdFromContext(ctx),
|
|
90
|
+
tags: this.options.rpc?.tags,
|
|
91
|
+
});
|
|
92
|
+
done();
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
startGrpcRequestTracing(transportId, call, done) {
|
|
96
|
+
const store = new Map();
|
|
97
|
+
this.asyncLocalStorage.run(store, () => {
|
|
98
|
+
const traceId = this.options.traceIdGenerator(call);
|
|
99
|
+
store.set(this.options.traceIdKey, traceId);
|
|
100
|
+
if (this.options.grpc?.setAttributes) {
|
|
101
|
+
const attributes = this.options.grpc?.setAttributes?.(call);
|
|
102
|
+
if (attributes) {
|
|
103
|
+
for (const [key, value] of Object.entries(attributes)) {
|
|
104
|
+
store.set(key, value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
if (this.options.grpc?.ignore?.(call)) {
|
|
110
|
+
return done();
|
|
111
|
+
}
|
|
112
|
+
const shouldCapture = this.traceSamplerService.shouldCapture("grpc", {
|
|
113
|
+
call,
|
|
114
|
+
});
|
|
115
|
+
if (!shouldCapture) {
|
|
116
|
+
return done();
|
|
117
|
+
}
|
|
118
|
+
this.operationTraceRegistry.startTrace(traceId, {
|
|
119
|
+
protocol: this.toProtocolName(transportId),
|
|
120
|
+
operationId: call.operationId,
|
|
121
|
+
tags: this.options.grpc?.tags,
|
|
122
|
+
});
|
|
123
|
+
done();
|
|
124
|
+
}, 0);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
endRpcRequestTracing(transportId, ctx) {
|
|
128
|
+
const store = this.asyncLocalStorage.getStore();
|
|
129
|
+
if (!store) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const traceId = store.get(this.options.traceIdKey);
|
|
133
|
+
if (!traceId) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
setTimeout(async () => {
|
|
137
|
+
let userId;
|
|
138
|
+
if (transportId === Transport.GRPC) {
|
|
139
|
+
if (this.options.grpc?.getUserId) {
|
|
140
|
+
userId = this.options.grpc?.getUserId?.(ctx);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
if (this.options.rpc?.getUserId) {
|
|
145
|
+
userId = this.options.rpc?.getUserId?.(transportId, ctx);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.operationTraceRegistry.endTrace(traceId, {
|
|
149
|
+
userId,
|
|
150
|
+
});
|
|
151
|
+
const snapshot = await this.operationTraceRegistry.pluckSnapshot(traceId);
|
|
152
|
+
if (!snapshot) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this.observeAgentSharedBuffer.insertRequestSnapshot(snapshot);
|
|
156
|
+
}, 0);
|
|
157
|
+
}
|
|
158
|
+
getOperationIdFromContext(ctx) {
|
|
159
|
+
switch (true) {
|
|
160
|
+
case ctx instanceof KafkaContext:
|
|
161
|
+
case ctx instanceof MqttContext:
|
|
162
|
+
return ctx.getTopic();
|
|
163
|
+
case ctx instanceof RmqContext:
|
|
164
|
+
case ctx instanceof TcpContext:
|
|
165
|
+
return ctx.getPattern();
|
|
166
|
+
case ctx instanceof RedisContext:
|
|
167
|
+
return ctx.getChannel();
|
|
168
|
+
case ctx instanceof NatsContext:
|
|
169
|
+
return ctx.getSubject();
|
|
170
|
+
default:
|
|
171
|
+
throw new Error(`Unsupported context type: ${ctx.constructor.name}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
RpcObserveAgentService = __decorate([
|
|
176
|
+
Injectable(),
|
|
177
|
+
__param(1, Inject(OBSERVE_OPTIONS)),
|
|
178
|
+
__metadata("design:paramtypes", [AsyncLocalStorage, Object, ModulesContainer,
|
|
179
|
+
OperationTraceRegistry,
|
|
180
|
+
ObserveAgentSharedBuffer,
|
|
181
|
+
TraceSamplerService])
|
|
182
|
+
], RpcObserveAgentService);
|
|
183
|
+
export { RpcObserveAgentService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./tracer.service.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./tracer.service.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
import { ObserveModuleOptionsWithDefaults } from "../interfaces/observe-options.interface.js";
|
|
4
|
+
export declare class LoggerPatcherService implements OnModuleInit {
|
|
5
|
+
private readonly asyncLocalStorage;
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly patchedWatermark;
|
|
9
|
+
constructor(asyncLocalStorage: AsyncLocalStorage<any>, options: ObserveModuleOptionsWithDefaults);
|
|
10
|
+
onModuleInit(): void;
|
|
11
|
+
injectTraceIdIntoLogs(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var LoggerPatcherService_1;
|
|
14
|
+
import { ConsoleLogger, Inject, Injectable, Logger, } from "@nestjs/common";
|
|
15
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
16
|
+
import { OBSERVE_OPTIONS } from "../observe.constants.js";
|
|
17
|
+
let LoggerPatcherService = LoggerPatcherService_1 = class LoggerPatcherService {
|
|
18
|
+
asyncLocalStorage;
|
|
19
|
+
options;
|
|
20
|
+
logger = new Logger(LoggerPatcherService_1.name);
|
|
21
|
+
patchedWatermark = Symbol("observe:logger_patched");
|
|
22
|
+
constructor(asyncLocalStorage, options) {
|
|
23
|
+
this.asyncLocalStorage = asyncLocalStorage;
|
|
24
|
+
this.options = options;
|
|
25
|
+
}
|
|
26
|
+
onModuleInit() {
|
|
27
|
+
this.injectTraceIdIntoLogs();
|
|
28
|
+
}
|
|
29
|
+
injectTraceIdIntoLogs() {
|
|
30
|
+
if (!this.options.attachTraceIdToLogs) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const isAlreadyPatched = Reflect.getOwnPropertyDescriptor(ConsoleLogger.prototype, this.patchedWatermark)?.value === true;
|
|
34
|
+
if (isAlreadyPatched) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const options = this.options;
|
|
38
|
+
const asyncLocalStorage = this.asyncLocalStorage;
|
|
39
|
+
const originalFormatMessage = ConsoleLogger.prototype["formatMessage"];
|
|
40
|
+
const originalGetJsonLogObject = ConsoleLogger.prototype["getJsonLogObject"];
|
|
41
|
+
if (!originalFormatMessage || !originalGetJsonLogObject) {
|
|
42
|
+
this.logger.warn('ConsoleLogger methods "formatMessage" or "getJsonLogObject" are not available, which means that you are likely using a version of NestJS that does not support these methods. Please, upgrade to at least NestJS 11.2.0. Skipping trace ID injection.');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
ConsoleLogger.prototype["getJsonLogObject"] = function (message, logOptions) {
|
|
46
|
+
const store = asyncLocalStorage.getStore();
|
|
47
|
+
const requestId = store?.get(options.traceIdKey);
|
|
48
|
+
const jsonLogObject = originalGetJsonLogObject.call(this, message, logOptions);
|
|
49
|
+
if (requestId) {
|
|
50
|
+
jsonLogObject["traceId"] = requestId;
|
|
51
|
+
}
|
|
52
|
+
return jsonLogObject;
|
|
53
|
+
};
|
|
54
|
+
ConsoleLogger.prototype["formatMessage"] = function (logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff) {
|
|
55
|
+
const store = asyncLocalStorage.getStore();
|
|
56
|
+
const requestId = store?.get(options.traceIdKey);
|
|
57
|
+
const output = originalFormatMessage.call(this, logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff);
|
|
58
|
+
if (requestId) {
|
|
59
|
+
return `${output} Trace ID: ${this.colorize(requestId, logLevel)}\n`;
|
|
60
|
+
}
|
|
61
|
+
return output;
|
|
62
|
+
};
|
|
63
|
+
Reflect.defineProperty(ConsoleLogger.prototype, this.patchedWatermark, {
|
|
64
|
+
value: true,
|
|
65
|
+
writable: false,
|
|
66
|
+
enumerable: false,
|
|
67
|
+
configurable: false,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
LoggerPatcherService = LoggerPatcherService_1 = __decorate([
|
|
72
|
+
Injectable(),
|
|
73
|
+
__param(1, Inject(OBSERVE_OPTIONS)),
|
|
74
|
+
__metadata("design:paramtypes", [AsyncLocalStorage, Object])
|
|
75
|
+
], LoggerPatcherService);
|
|
76
|
+
export { LoggerPatcherService };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OnApplicationShutdown, OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { NodeRuntimeMetrics } from "../interfaces/node-runtime-metrics.interface.js";
|
|
3
|
+
import { ObserveModuleOptionsWithDefaults } from "../interfaces/observe-options.interface.js";
|
|
4
|
+
export declare class NodeRuntimeMetricsService implements OnModuleInit, OnApplicationShutdown {
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly logger;
|
|
7
|
+
private eventLoopDelayMonitor;
|
|
8
|
+
private gcObserver;
|
|
9
|
+
private gcCount;
|
|
10
|
+
private gcTotalDuration;
|
|
11
|
+
private gcBreakdown;
|
|
12
|
+
private lastCpuUsage;
|
|
13
|
+
private lastCpuUsageTimestamp;
|
|
14
|
+
private osTotalMemory;
|
|
15
|
+
constructor(options: ObserveModuleOptionsWithDefaults);
|
|
16
|
+
onModuleInit(): void;
|
|
17
|
+
onApplicationShutdown(): Promise<void>;
|
|
18
|
+
monitorEventLoopDelay(): void;
|
|
19
|
+
observeGcPerformance(): void;
|
|
20
|
+
collectNodeRuntimeMetrics(): NodeRuntimeMetrics;
|
|
21
|
+
private resetGcMetrics;
|
|
22
|
+
private updateLastCpuUsage;
|
|
23
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var NodeRuntimeMetricsService_1;
|
|
14
|
+
import { Inject, Injectable, Logger, } from "@nestjs/common";
|
|
15
|
+
import * as os from "node:os";
|
|
16
|
+
import { monitorEventLoopDelay, performance, PerformanceObserver, } from "node:perf_hooks";
|
|
17
|
+
import { OBSERVE_OPTIONS } from "../observe.constants.js";
|
|
18
|
+
let NodeRuntimeMetricsService = NodeRuntimeMetricsService_1 = class NodeRuntimeMetricsService {
|
|
19
|
+
options;
|
|
20
|
+
logger = new Logger(NodeRuntimeMetricsService_1.name);
|
|
21
|
+
eventLoopDelayMonitor = null;
|
|
22
|
+
gcObserver = null;
|
|
23
|
+
gcCount = 0;
|
|
24
|
+
gcTotalDuration = 0;
|
|
25
|
+
gcBreakdown = null;
|
|
26
|
+
lastCpuUsage = process.cpuUsage();
|
|
27
|
+
lastCpuUsageTimestamp = Date.now();
|
|
28
|
+
osTotalMemory = os.totalmem();
|
|
29
|
+
constructor(options) {
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.options.runtimeMetrics ??= true;
|
|
32
|
+
}
|
|
33
|
+
onModuleInit() {
|
|
34
|
+
if (!this.options.runtimeMetrics) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.lastCpuUsage = process.cpuUsage();
|
|
38
|
+
this.lastCpuUsageTimestamp = Date.now();
|
|
39
|
+
this.osTotalMemory = os.totalmem();
|
|
40
|
+
this.monitorEventLoopDelay();
|
|
41
|
+
this.observeGcPerformance();
|
|
42
|
+
}
|
|
43
|
+
async onApplicationShutdown() {
|
|
44
|
+
if (this.gcObserver) {
|
|
45
|
+
this.gcObserver.disconnect();
|
|
46
|
+
this.logger.debug("Garbage collection observer disconnected.");
|
|
47
|
+
}
|
|
48
|
+
if (this.eventLoopDelayMonitor) {
|
|
49
|
+
this.eventLoopDelayMonitor.disable();
|
|
50
|
+
this.logger.debug("Event loop delay monitoring disabled.");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
monitorEventLoopDelay() {
|
|
54
|
+
if (this.options.debug) {
|
|
55
|
+
this.logger.debug("Monitoring event loop delay.");
|
|
56
|
+
}
|
|
57
|
+
const h = monitorEventLoopDelay();
|
|
58
|
+
h.enable();
|
|
59
|
+
this.eventLoopDelayMonitor = h;
|
|
60
|
+
}
|
|
61
|
+
observeGcPerformance() {
|
|
62
|
+
if (this.options.debug) {
|
|
63
|
+
this.logger.debug("Observing garbage collection performance.");
|
|
64
|
+
}
|
|
65
|
+
this.gcObserver = new PerformanceObserver((list) => {
|
|
66
|
+
for (const entry of list.getEntries()) {
|
|
67
|
+
if (entry.entryType !== "gc") {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
this.gcCount++;
|
|
71
|
+
this.gcTotalDuration += entry.duration;
|
|
72
|
+
if ("detail" in entry && "kind" in entry.detail) {
|
|
73
|
+
const detail = entry.detail;
|
|
74
|
+
const kind = detail.kind === 1
|
|
75
|
+
? "major"
|
|
76
|
+
: detail.kind === 2
|
|
77
|
+
? "minor"
|
|
78
|
+
: detail.kind === 4
|
|
79
|
+
? "incremental"
|
|
80
|
+
: undefined;
|
|
81
|
+
if (!kind) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
this.gcBreakdown ??= {
|
|
85
|
+
minor: { count: 0, duration: 0 },
|
|
86
|
+
major: { count: 0, duration: 0 },
|
|
87
|
+
incremental: { count: 0, duration: 0 },
|
|
88
|
+
};
|
|
89
|
+
const bucket = (this.gcBreakdown[kind] ??= {
|
|
90
|
+
count: 0,
|
|
91
|
+
duration: 0,
|
|
92
|
+
});
|
|
93
|
+
bucket.count++;
|
|
94
|
+
bucket.duration += entry.duration;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
this.gcObserver.observe({ type: "gc", buffered: true });
|
|
99
|
+
}
|
|
100
|
+
collectNodeRuntimeMetrics() {
|
|
101
|
+
if (!this.eventLoopDelayMonitor) {
|
|
102
|
+
throw new Error("Runtime metrics are not being collected. `collectNodeRuntimeMetrics()` requires `onModuleInit()` to have run with the `runtimeMetrics` option enabled.");
|
|
103
|
+
}
|
|
104
|
+
const timestamp = Date.now();
|
|
105
|
+
const elapsedTime = timestamp - this.lastCpuUsageTimestamp;
|
|
106
|
+
const memoryUsage = process.memoryUsage();
|
|
107
|
+
const cpuUsage = process.cpuUsage();
|
|
108
|
+
const diffCpuUsage = process.cpuUsage(this.lastCpuUsage);
|
|
109
|
+
const eventLoop = performance.eventLoopUtilization();
|
|
110
|
+
const meanDelay = this.eventLoopDelayMonitor.mean;
|
|
111
|
+
const lag = Number.isFinite(meanDelay) ? meanDelay / 1e6 : 0;
|
|
112
|
+
const metrics = {
|
|
113
|
+
memory: {
|
|
114
|
+
rss: memoryUsage.rss / 1024 / 1024,
|
|
115
|
+
heapTotal: memoryUsage.heapTotal / 1024 / 1024,
|
|
116
|
+
heapUsed: memoryUsage.heapUsed / 1024 / 1024,
|
|
117
|
+
external: memoryUsage.external / 1024 / 1024,
|
|
118
|
+
arrayBuffers: memoryUsage.arrayBuffers / 1024 / 1024,
|
|
119
|
+
percentageUsed: (memoryUsage.rss / this.osTotalMemory) * 100,
|
|
120
|
+
},
|
|
121
|
+
cpu: {
|
|
122
|
+
user: diffCpuUsage.user / 1000,
|
|
123
|
+
system: diffCpuUsage.system / 1000,
|
|
124
|
+
percentageUsed: ((diffCpuUsage.user + diffCpuUsage.system) / 1000 / elapsedTime) *
|
|
125
|
+
100,
|
|
126
|
+
},
|
|
127
|
+
eventLoop: {
|
|
128
|
+
lag,
|
|
129
|
+
utilization: eventLoop.utilization,
|
|
130
|
+
},
|
|
131
|
+
gc: {
|
|
132
|
+
count: this.gcCount,
|
|
133
|
+
totalDuration: this.gcTotalDuration,
|
|
134
|
+
breakdown: { ...this.gcBreakdown },
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
this.resetGcMetrics();
|
|
138
|
+
this.updateLastCpuUsage(cpuUsage, timestamp);
|
|
139
|
+
return metrics;
|
|
140
|
+
}
|
|
141
|
+
resetGcMetrics() {
|
|
142
|
+
this.gcCount = 0;
|
|
143
|
+
this.gcTotalDuration = 0;
|
|
144
|
+
this.gcBreakdown = null;
|
|
145
|
+
}
|
|
146
|
+
updateLastCpuUsage(cpuUsage, timestamp) {
|
|
147
|
+
this.lastCpuUsage = cpuUsage;
|
|
148
|
+
this.lastCpuUsageTimestamp = timestamp;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
NodeRuntimeMetricsService = NodeRuntimeMetricsService_1 = __decorate([
|
|
152
|
+
Injectable(),
|
|
153
|
+
__param(0, Inject(OBSERVE_OPTIONS)),
|
|
154
|
+
__metadata("design:paramtypes", [Object])
|
|
155
|
+
], NodeRuntimeMetricsService);
|
|
156
|
+
export { NodeRuntimeMetricsService };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RequestMethod } from "@nestjs/common";
|
|
2
|
+
import { AsyncLocalStorage } from "async_hooks";
|
|
3
|
+
import { JobSnapshot } from "../interfaces/index.js";
|
|
4
|
+
import { RequestSnapshot } from "../interfaces/request-snapshot.interface.js";
|
|
5
|
+
import { CreateObserveModuleOptions } from "../interfaces/observe-options.interface.js";
|
|
6
|
+
import { OngoingTraceEventNode } from "../interfaces/trace-events.interfaces.js";
|
|
7
|
+
import { TraceSpanDelegate } from "../trace-span.delegate.js";
|
|
8
|
+
import { KeyOf } from "../types/key-of.type.js";
|
|
9
|
+
import { CALLER_METADATA_KEY } from "../observe.constants.js";
|
|
10
|
+
type TraceId = string;
|
|
11
|
+
export declare class OperationTraceRegistry {
|
|
12
|
+
private readonly als;
|
|
13
|
+
private readonly sourceContext;
|
|
14
|
+
private readonly traceSnapshots;
|
|
15
|
+
private readonly callerIdsByTraceId;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
private hasReportedMissingInstrumentation;
|
|
18
|
+
constructor(als: AsyncLocalStorage<Map<KeyOf<{
|
|
19
|
+
[CALLER_METADATA_KEY]: string;
|
|
20
|
+
}>, unknown>>, sourceContext?: CreateObserveModuleOptions["sourceContext"]);
|
|
21
|
+
private toErrorPayload;
|
|
22
|
+
startTrace(traceId: TraceId, data: Omit<RequestSnapshot, "traces" | "startTimestamp" | "calledAt" | "traceId"> | Omit<JobSnapshot, "duration">): void;
|
|
23
|
+
endTrace(traceId: string): void;
|
|
24
|
+
endTrace(traceId: string, opts?: {
|
|
25
|
+
statusCode?: number;
|
|
26
|
+
userId?: string;
|
|
27
|
+
}): void;
|
|
28
|
+
endTrace(traceId: string, opts?: {
|
|
29
|
+
status?: JobSnapshot["status"];
|
|
30
|
+
}): void;
|
|
31
|
+
private reportMissingInstrumentation;
|
|
32
|
+
private toErrorStatusCode;
|
|
33
|
+
private setStatusCode;
|
|
34
|
+
internalStartTraceStep(traceId: TraceId, className: string, methodKey: string, callerId: string | undefined): string | undefined;
|
|
35
|
+
internalEndTraceStep(traceId: TraceId, spanId: string | undefined, className: string, methodKey: string, callerId: string | undefined, error?: Error | string | object): void;
|
|
36
|
+
addRouteMetadataToTrace(requestId: string, requestMethod: RequestMethod, path: string): void;
|
|
37
|
+
addGraphQLMetadataToTrace(traceId: TraceId, metadata: {
|
|
38
|
+
operationId: string;
|
|
39
|
+
tags?: Record<string, string | number | boolean>;
|
|
40
|
+
attributes?: RequestSnapshot["attributes"];
|
|
41
|
+
}): void;
|
|
42
|
+
private toStartOffset;
|
|
43
|
+
captureError(traceId: string, callerId: string | undefined, error: Error | string, tags: Record<string, string | number | boolean>): void;
|
|
44
|
+
abandonTrace(traceId: TraceId): void;
|
|
45
|
+
pluckSnapshot(traceId: string): Promise<RequestSnapshot | JobSnapshot | undefined>;
|
|
46
|
+
getActiveSpan(traceId: string, callerId: string | undefined): OngoingTraceEventNode | undefined;
|
|
47
|
+
createManualSpan(traceId: string, callerId: string | undefined, name: string, spanFunction: (span: TraceSpanDelegate) => any): Promise<any>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|