@modainteract/moda-interact-shared 0.2.0 → 0.4.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/README.md +424 -21
- package/dist/chunk-5JNEZEKV.js +374 -0
- package/dist/chunk-5JNEZEKV.js.map +1 -0
- package/dist/chunk-XH6XHKXC.js +34 -0
- package/dist/chunk-XH6XHKXC.js.map +1 -0
- package/dist/chunk-XU4XX7SD.js +27 -0
- package/dist/chunk-XU4XX7SD.js.map +1 -0
- package/dist/logging/index.js +43 -1
- package/dist/logging/index.js.map +1 -1
- package/dist/logging/node.d.ts +103 -0
- package/dist/logging/node.js +18 -0
- package/dist/logging/node.js.map +1 -0
- package/dist/observability/bullmq.d.ts +10 -0
- package/dist/observability/bullmq.js +14 -0
- package/dist/observability/bullmq.js.map +1 -0
- package/dist/observability/genai.d.ts +10 -0
- package/dist/observability/genai.js +109 -0
- package/dist/observability/genai.js.map +1 -0
- package/dist/observability/index.d.ts +6 -0
- package/dist/observability/index.js +9 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/node.d.ts +29 -0
- package/dist/observability/node.js +352 -0
- package/dist/observability/node.js.map +1 -0
- package/package.json +41 -2
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
type NodeLokiLoggingOptions = {
|
|
2
|
+
serviceName: string;
|
|
3
|
+
environment: string;
|
|
4
|
+
serviceNamespace?: string;
|
|
5
|
+
/**
|
|
6
|
+
* Explicit Loki base URL.
|
|
7
|
+
*
|
|
8
|
+
* Production normally supplies LOKI_URL.
|
|
9
|
+
*/
|
|
10
|
+
host?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Optional Basic Auth override in `username:password` format.
|
|
13
|
+
*
|
|
14
|
+
* Prefer separate LOKI_USERNAME/LOKI_PASSWORD environment variables in
|
|
15
|
+
* deployed services so the composed value never needs to be committed.
|
|
16
|
+
*/
|
|
17
|
+
basicAuth?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional additional static headers.
|
|
20
|
+
*
|
|
21
|
+
* Never include these in log payloads or error messages.
|
|
22
|
+
*/
|
|
23
|
+
headers?: Record<string, string>;
|
|
24
|
+
batching?: boolean;
|
|
25
|
+
intervalSeconds?: number;
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
clearOnError?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Test-only override. In normal service bootstrap, the presence of a Loki
|
|
30
|
+
* host is sufficient to enable the transport.
|
|
31
|
+
*/
|
|
32
|
+
forceEnable?: boolean;
|
|
33
|
+
};
|
|
34
|
+
type NodeLokiLoggingRuntime = {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
host: string | null;
|
|
37
|
+
labels: Readonly<Record<string, string>>;
|
|
38
|
+
forceFlush: () => Promise<void>;
|
|
39
|
+
shutdown: () => Promise<void>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Installs the direct Grafana Loki destination exactly once per Node process.
|
|
43
|
+
*
|
|
44
|
+
* IMPORTANT:
|
|
45
|
+
* - This module is Node-only.
|
|
46
|
+
* - It is reached through @modainteract/moda-interact-shared/logging/node.
|
|
47
|
+
* - Do not import it from Vite/browser/application module graphs.
|
|
48
|
+
* - The normal ./logging entry contains no Winston/winston-loki imports.
|
|
49
|
+
*/
|
|
50
|
+
declare function initNodeLokiLogging(options: NodeLokiLoggingOptions): NodeLokiLoggingRuntime;
|
|
51
|
+
declare function getNodeLokiLoggingRuntime(): NodeLokiLoggingRuntime | null;
|
|
52
|
+
|
|
53
|
+
type NodeOpenTelemetryLoggingOptions = {
|
|
54
|
+
serviceName: string;
|
|
55
|
+
environment: string;
|
|
56
|
+
serviceNamespace?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Explicit endpoint override. Intended mainly for tests.
|
|
59
|
+
*
|
|
60
|
+
* Production normally uses:
|
|
61
|
+
* OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
|
|
62
|
+
* or:
|
|
63
|
+
* OTEL_EXPORTER_OTLP_ENDPOINT
|
|
64
|
+
*/
|
|
65
|
+
endpoint?: string;
|
|
66
|
+
/** Optional explicit OTLP headers override. */
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
/** Test-only switch. Production should rely on environment configuration. */
|
|
69
|
+
forceEnable?: boolean;
|
|
70
|
+
};
|
|
71
|
+
type NodeOpenTelemetryLoggingRuntime = {
|
|
72
|
+
enabled: boolean;
|
|
73
|
+
endpoint: string | null;
|
|
74
|
+
forceFlush: () => Promise<void>;
|
|
75
|
+
shutdown: () => Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Installs the Node OpenTelemetry LoggerProvider exactly once for this process.
|
|
79
|
+
*
|
|
80
|
+
* IMPORTANT:
|
|
81
|
+
* This module is Node-only. Import and initialize it from the process bootstrap
|
|
82
|
+
* before framework/application modules are loaded. Do not import this module
|
|
83
|
+
* through Vite/React/browser bundles.
|
|
84
|
+
*
|
|
85
|
+
* Application modules should import only:
|
|
86
|
+
*
|
|
87
|
+
* @modainteract/moda-interact-shared/logging
|
|
88
|
+
*
|
|
89
|
+
* Once this provider is installed, createLogger(...) automatically fans safe
|
|
90
|
+
* canonical log records out to stdout and the OpenTelemetry Logs API.
|
|
91
|
+
*
|
|
92
|
+
* Direct Loki delivery, when desired, is independently enabled with:
|
|
93
|
+
*
|
|
94
|
+
* initNodeLokiLogging(...)
|
|
95
|
+
*
|
|
96
|
+
* from this same Node-only package entry.
|
|
97
|
+
*/
|
|
98
|
+
declare function initNodeOpenTelemetryLogging(options: NodeOpenTelemetryLoggingOptions): NodeOpenTelemetryLoggingRuntime;
|
|
99
|
+
declare function getNodeOpenTelemetryLoggingRuntime(): NodeOpenTelemetryLoggingRuntime | null;
|
|
100
|
+
declare function resolveLogsEndpoint(explicitEndpoint?: string): string | undefined;
|
|
101
|
+
declare function parseOtlpHeaders(value: string | undefined): Record<string, string> | undefined;
|
|
102
|
+
|
|
103
|
+
export { type NodeLokiLoggingOptions, type NodeLokiLoggingRuntime, type NodeOpenTelemetryLoggingOptions, type NodeOpenTelemetryLoggingRuntime, getNodeLokiLoggingRuntime, getNodeOpenTelemetryLoggingRuntime, initNodeLokiLogging, initNodeOpenTelemetryLogging, parseOtlpHeaders, resolveLogsEndpoint };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getNodeLokiLoggingRuntime,
|
|
3
|
+
getNodeOpenTelemetryLoggingRuntime,
|
|
4
|
+
initNodeLokiLogging,
|
|
5
|
+
initNodeOpenTelemetryLogging,
|
|
6
|
+
parseOtlpHeaders,
|
|
7
|
+
resolveLogsEndpoint
|
|
8
|
+
} from "../chunk-5JNEZEKV.js";
|
|
9
|
+
import "../chunk-XU4XX7SD.js";
|
|
10
|
+
export {
|
|
11
|
+
getNodeLokiLoggingRuntime,
|
|
12
|
+
getNodeOpenTelemetryLoggingRuntime,
|
|
13
|
+
initNodeLokiLogging,
|
|
14
|
+
initNodeOpenTelemetryLogging,
|
|
15
|
+
parseOtlpHeaders,
|
|
16
|
+
resolveLogsEndpoint
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BullMQOtel } from 'bullmq-otel';
|
|
2
|
+
|
|
3
|
+
type BullMQTelemetryOptions = {
|
|
4
|
+
serviceName: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
enableMetrics?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function createBullMQTelemetry(options: BullMQTelemetryOptions): BullMQOtel;
|
|
9
|
+
|
|
10
|
+
export { type BullMQTelemetryOptions, createBullMQTelemetry };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/observability/bullmq.ts
|
|
2
|
+
import { BullMQOtel } from "bullmq-otel";
|
|
3
|
+
function createBullMQTelemetry(options) {
|
|
4
|
+
return new BullMQOtel({
|
|
5
|
+
tracerName: options.serviceName,
|
|
6
|
+
meterName: options.serviceName,
|
|
7
|
+
version: options.version ?? "unknown",
|
|
8
|
+
enableMetrics: options.enableMetrics ?? true
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
createBullMQTelemetry
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=bullmq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/observability/bullmq.ts"],"sourcesContent":["import { BullMQOtel } from \"bullmq-otel\";\n\nexport type BullMQTelemetryOptions = {\n serviceName: string;\n version?: string;\n enableMetrics?: boolean;\n};\n\nexport function createBullMQTelemetry(\n options: BullMQTelemetryOptions,\n): BullMQOtel {\n return new BullMQOtel({\n tracerName: options.serviceName,\n meterName: options.serviceName,\n version: options.version ?? \"unknown\",\n enableMetrics: options.enableMetrics ?? true,\n });\n}"],"mappings":";AAAA,SAAS,kBAAkB;AAQpB,SAAS,sBACd,SACY;AACZ,SAAO,IAAI,WAAW;AAAA,IACpB,YAAY,QAAQ;AAAA,IACpB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ,WAAW;AAAA,IAC5B,eAAe,QAAQ,iBAAiB;AAAA,EAC1C,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type AgentObservation = {
|
|
2
|
+
agentName: string;
|
|
3
|
+
provider?: string;
|
|
4
|
+
model?: string;
|
|
5
|
+
};
|
|
6
|
+
declare function observeConversationTurn<T>(channel: "whatsapp" | "other", work: () => Promise<T>): Promise<T>;
|
|
7
|
+
declare function observeAgentInvocation<T>(observation: AgentObservation, work: () => Promise<T>): Promise<T>;
|
|
8
|
+
declare function observeAgentTool<T>(toolName: string, work: () => Promise<T>): Promise<T>;
|
|
9
|
+
|
|
10
|
+
export { type AgentObservation, observeAgentInvocation, observeAgentTool, observeConversationTurn };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withObservedSpan
|
|
3
|
+
} from "../chunk-XH6XHKXC.js";
|
|
4
|
+
|
|
5
|
+
// src/observability/genai.ts
|
|
6
|
+
import { metrics } from "@opentelemetry/api";
|
|
7
|
+
var MAX_ATTRIBUTE_LENGTH = 80;
|
|
8
|
+
var meter = metrics.getMeter(
|
|
9
|
+
"@modainteract/moda-interact-shared/observability/genai"
|
|
10
|
+
);
|
|
11
|
+
var agentDuration = meter.createHistogram(
|
|
12
|
+
"moda.agent.invocation.duration_ms",
|
|
13
|
+
{ unit: "ms" }
|
|
14
|
+
);
|
|
15
|
+
var agentOperations = meter.createCounter("moda.agent.invocation.operations");
|
|
16
|
+
var toolDuration = meter.createHistogram("moda.agent.tool.duration_ms", {
|
|
17
|
+
unit: "ms"
|
|
18
|
+
});
|
|
19
|
+
var toolOperations = meter.createCounter("moda.agent.tool.operations");
|
|
20
|
+
var turnDuration = meter.createHistogram(
|
|
21
|
+
"moda.conversation.turn.duration_ms",
|
|
22
|
+
{ unit: "ms" }
|
|
23
|
+
);
|
|
24
|
+
var turnOperations = meter.createCounter("moda.conversation.turn.operations");
|
|
25
|
+
async function observeConversationTurn(channel, work) {
|
|
26
|
+
return observeOperation(
|
|
27
|
+
turnDuration,
|
|
28
|
+
turnOperations,
|
|
29
|
+
{ channel },
|
|
30
|
+
() => withObservedSpan(
|
|
31
|
+
`conversation.turn ${channel}`,
|
|
32
|
+
{ "moda.messaging.channel": channel },
|
|
33
|
+
work
|
|
34
|
+
)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function observeAgentInvocation(observation, work) {
|
|
38
|
+
const agentName = boundedSpanValue(observation.agentName) ?? "unknown";
|
|
39
|
+
return observeOperation(
|
|
40
|
+
agentDuration,
|
|
41
|
+
agentOperations,
|
|
42
|
+
{},
|
|
43
|
+
() => withObservedSpan(
|
|
44
|
+
`invoke_agent ${agentName}`,
|
|
45
|
+
compact({
|
|
46
|
+
"gen_ai.operation.name": "invoke_agent",
|
|
47
|
+
"gen_ai.agent.name": agentName,
|
|
48
|
+
"gen_ai.provider.name": boundedSpanValue(observation.provider),
|
|
49
|
+
"gen_ai.request.model": boundedSpanValue(observation.model)
|
|
50
|
+
}),
|
|
51
|
+
work
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
async function observeAgentTool(toolName, work) {
|
|
56
|
+
const safeToolName = boundedSpanValue(toolName) ?? "unknown";
|
|
57
|
+
return observeOperation(
|
|
58
|
+
toolDuration,
|
|
59
|
+
toolOperations,
|
|
60
|
+
{},
|
|
61
|
+
() => withObservedSpan(
|
|
62
|
+
`execute_tool ${safeToolName}`,
|
|
63
|
+
{
|
|
64
|
+
"gen_ai.operation.name": "execute_tool",
|
|
65
|
+
"gen_ai.tool.name": safeToolName
|
|
66
|
+
},
|
|
67
|
+
work
|
|
68
|
+
)
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
async function observeOperation(duration, operations, attributes, work) {
|
|
72
|
+
const started = performance.now();
|
|
73
|
+
let outcome = "error";
|
|
74
|
+
try {
|
|
75
|
+
const result = await work();
|
|
76
|
+
outcome = "success";
|
|
77
|
+
return result;
|
|
78
|
+
} finally {
|
|
79
|
+
recordMetrics(duration, operations, performance.now() - started, {
|
|
80
|
+
...attributes,
|
|
81
|
+
outcome
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function recordMetrics(duration, operations, elapsedMilliseconds, attributes) {
|
|
86
|
+
try {
|
|
87
|
+
duration.record(elapsedMilliseconds, attributes);
|
|
88
|
+
operations.add(1, attributes);
|
|
89
|
+
} catch {
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function boundedSpanValue(value) {
|
|
93
|
+
if (value === void 0) return void 0;
|
|
94
|
+
const bounded = value.trim().slice(0, MAX_ATTRIBUTE_LENGTH);
|
|
95
|
+
return bounded || void 0;
|
|
96
|
+
}
|
|
97
|
+
function compact(attributes) {
|
|
98
|
+
return Object.fromEntries(
|
|
99
|
+
Object.entries(attributes).filter(
|
|
100
|
+
(entry) => entry[1] !== void 0
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
observeAgentInvocation,
|
|
106
|
+
observeAgentTool,
|
|
107
|
+
observeConversationTurn
|
|
108
|
+
};
|
|
109
|
+
//# sourceMappingURL=genai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/observability/genai.ts"],"sourcesContent":["import { metrics, type Attributes, type Counter, type Histogram } from \"@opentelemetry/api\";\nimport { withObservedSpan } from \"./index.js\";\n\nconst MAX_ATTRIBUTE_LENGTH = 80;\nconst meter = metrics.getMeter(\n \"@modainteract/moda-interact-shared/observability/genai\",\n);\nconst agentDuration = meter.createHistogram(\n \"moda.agent.invocation.duration_ms\",\n { unit: \"ms\" },\n);\nconst agentOperations = meter.createCounter(\"moda.agent.invocation.operations\");\nconst toolDuration = meter.createHistogram(\"moda.agent.tool.duration_ms\", {\n unit: \"ms\",\n});\nconst toolOperations = meter.createCounter(\"moda.agent.tool.operations\");\nconst turnDuration = meter.createHistogram(\n \"moda.conversation.turn.duration_ms\",\n { unit: \"ms\" },\n);\nconst turnOperations = meter.createCounter(\"moda.conversation.turn.operations\");\n\ntype Outcome = \"success\" | \"error\";\n\nexport type AgentObservation = {\n agentName: string;\n provider?: string;\n model?: string;\n};\n\nexport async function observeConversationTurn<T>(\n channel: \"whatsapp\" | \"other\",\n work: () => Promise<T>,\n): Promise<T> {\n return observeOperation(\n turnDuration,\n turnOperations,\n { channel },\n () => withObservedSpan(\n `conversation.turn ${channel}`,\n { \"moda.messaging.channel\": channel },\n work,\n ),\n );\n}\n\nexport async function observeAgentInvocation<T>(\n observation: AgentObservation,\n work: () => Promise<T>,\n): Promise<T> {\n const agentName = boundedSpanValue(observation.agentName) ?? \"unknown\";\n\n return observeOperation(\n agentDuration,\n agentOperations,\n {},\n () => withObservedSpan(\n `invoke_agent ${agentName}`,\n compact({\n \"gen_ai.operation.name\": \"invoke_agent\",\n \"gen_ai.agent.name\": agentName,\n \"gen_ai.provider.name\": boundedSpanValue(observation.provider),\n \"gen_ai.request.model\": boundedSpanValue(observation.model),\n }),\n work,\n ),\n );\n}\n\nexport async function observeAgentTool<T>(\n toolName: string,\n work: () => Promise<T>,\n): Promise<T> {\n const safeToolName = boundedSpanValue(toolName) ?? \"unknown\";\n\n return observeOperation(\n toolDuration,\n toolOperations,\n {},\n () => withObservedSpan(\n `execute_tool ${safeToolName}`,\n {\n \"gen_ai.operation.name\": \"execute_tool\",\n \"gen_ai.tool.name\": safeToolName,\n },\n work,\n ),\n );\n}\n\nasync function observeOperation<T>(\n duration: Histogram,\n operations: Counter,\n attributes: Attributes,\n work: () => Promise<T>,\n): Promise<T> {\n const started = performance.now();\n let outcome: Outcome = \"error\";\n\n try {\n const result = await work();\n outcome = \"success\";\n return result;\n } finally {\n recordMetrics(duration, operations, performance.now() - started, {\n ...attributes,\n outcome,\n });\n }\n}\n\nfunction recordMetrics(\n duration: Histogram,\n operations: Counter,\n elapsedMilliseconds: number,\n attributes: Attributes,\n): void {\n try {\n duration.record(elapsedMilliseconds, attributes);\n operations.add(1, attributes);\n } catch {\n // Telemetry must not replace an application result or error.\n }\n}\n\nfunction boundedSpanValue(value: string | undefined): string | undefined {\n if (value === undefined) return undefined;\n const bounded = value.trim().slice(0, MAX_ATTRIBUTE_LENGTH);\n return bounded || undefined;\n}\n\nfunction compact(\n attributes: Record<string, string | undefined>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(attributes).filter((entry): entry is [string, string] =>\n entry[1] !== undefined\n ),\n );\n}"],"mappings":";;;;;AAAA,SAAS,eAA8D;AAGvE,IAAM,uBAAuB;AAC7B,IAAM,QAAQ,QAAQ;AAAA,EACpB;AACF;AACA,IAAM,gBAAgB,MAAM;AAAA,EAC1B;AAAA,EACA,EAAE,MAAM,KAAK;AACf;AACA,IAAM,kBAAkB,MAAM,cAAc,kCAAkC;AAC9E,IAAM,eAAe,MAAM,gBAAgB,+BAA+B;AAAA,EACxE,MAAM;AACR,CAAC;AACD,IAAM,iBAAiB,MAAM,cAAc,4BAA4B;AACvE,IAAM,eAAe,MAAM;AAAA,EACzB;AAAA,EACA,EAAE,MAAM,KAAK;AACf;AACA,IAAM,iBAAiB,MAAM,cAAc,mCAAmC;AAU9E,eAAsB,wBACpB,SACA,MACY;AACZ,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,QAAQ;AAAA,IACV,MAAM;AAAA,MACJ,qBAAqB,OAAO;AAAA,MAC5B,EAAE,0BAA0B,QAAQ;AAAA,MACpC;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,uBACpB,aACA,MACY;AACZ,QAAM,YAAY,iBAAiB,YAAY,SAAS,KAAK;AAE7D,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,CAAC;AAAA,IACD,MAAM;AAAA,MACJ,gBAAgB,SAAS;AAAA,MACzB,QAAQ;AAAA,QACN,yBAAyB;AAAA,QACzB,qBAAqB;AAAA,QACrB,wBAAwB,iBAAiB,YAAY,QAAQ;AAAA,QAC7D,wBAAwB,iBAAiB,YAAY,KAAK;AAAA,MAC5D,CAAC;AAAA,MACD;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAsB,iBACpB,UACA,MACY;AACZ,QAAM,eAAe,iBAAiB,QAAQ,KAAK;AAEnD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,CAAC;AAAA,IACD,MAAM;AAAA,MACJ,gBAAgB,YAAY;AAAA,MAC5B;AAAA,QACE,yBAAyB;AAAA,QACzB,oBAAoB;AAAA,MACtB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,eAAe,iBACb,UACA,YACA,YACA,MACY;AACZ,QAAM,UAAU,YAAY,IAAI;AAChC,MAAI,UAAmB;AAEvB,MAAI;AACF,UAAM,SAAS,MAAM,KAAK;AAC1B,cAAU;AACV,WAAO;AAAA,EACT,UAAE;AACA,kBAAc,UAAU,YAAY,YAAY,IAAI,IAAI,SAAS;AAAA,MAC/D,GAAG;AAAA,MACH;AAAA,IACF,CAAC;AAAA,EACH;AACF;AAEA,SAAS,cACP,UACA,YACA,qBACA,YACM;AACN,MAAI;AACF,aAAS,OAAO,qBAAqB,UAAU;AAC/C,eAAW,IAAI,GAAG,UAAU;AAAA,EAC9B,QAAQ;AAAA,EAER;AACF;AAEA,SAAS,iBAAiB,OAA+C;AACvE,MAAI,UAAU,OAAW,QAAO;AAChC,QAAM,UAAU,MAAM,KAAK,EAAE,MAAM,GAAG,oBAAoB;AAC1D,SAAO,WAAW;AACpB;AAEA,SAAS,QACP,YACwB;AACxB,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,UAAU,EAAE;AAAA,MAAO,CAAC,UACjC,MAAM,CAAC,MAAM;AAAA,IACf;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Attributes } from '@opentelemetry/api';
|
|
2
|
+
|
|
3
|
+
declare function getActiveTraceId(): string | undefined;
|
|
4
|
+
declare function withObservedSpan<T>(name: string, attributes: Attributes, work: () => Promise<T>): Promise<T>;
|
|
5
|
+
|
|
6
|
+
export { getActiveTraceId, withObservedSpan };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Sampler } from '@opentelemetry/sdk-trace-base';
|
|
2
|
+
|
|
3
|
+
type NodeInstrumentProfile = {
|
|
4
|
+
http?: boolean;
|
|
5
|
+
fetch?: boolean;
|
|
6
|
+
prisma?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type NodeObservabilityOptions = {
|
|
9
|
+
serviceName: string;
|
|
10
|
+
environment?: string;
|
|
11
|
+
serviceNamespace?: string;
|
|
12
|
+
instrument?: NodeInstrumentProfile;
|
|
13
|
+
traceSampleRatio?: number;
|
|
14
|
+
forceEnable?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type NodeObservabilityRuntime = {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
serviceName: string;
|
|
19
|
+
environment: string;
|
|
20
|
+
error?: string;
|
|
21
|
+
forceFlush(): Promise<void>;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
23
|
+
};
|
|
24
|
+
declare function resolveDeploymentEnvironmentName(): string;
|
|
25
|
+
declare function initNodeObservability(options: NodeObservabilityOptions): NodeObservabilityRuntime;
|
|
26
|
+
declare function getNodeObservabilityRuntime(): NodeObservabilityRuntime | undefined;
|
|
27
|
+
declare function resolveSampler(explicitRatio: number | undefined, environment: string): Sampler;
|
|
28
|
+
|
|
29
|
+
export { type NodeInstrumentProfile, type NodeObservabilityOptions, type NodeObservabilityRuntime, getNodeObservabilityRuntime, initNodeObservability, resolveDeploymentEnvironmentName, resolveSampler };
|