@openclaw/diagnostics-otel 2026.6.11 → 2026.7.1-beta.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/dist/index.js +48 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
|
13
13
|
import { ATTR_GEN_AI_INPUT_MESSAGES, ATTR_GEN_AI_OUTPUT_MESSAGES, ATTR_GEN_AI_SYSTEM_INSTRUCTIONS, ATTR_GEN_AI_TOOL_DEFINITIONS } from "@opentelemetry/semantic-conventions/incubating";
|
|
14
14
|
import { waitForDiagnosticEventsDrained } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
15
15
|
import { registerUnhandledRejectionHandler } from "openclaw/plugin-sdk/runtime-env";
|
|
16
|
+
import { isRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
16
17
|
//#region extensions/diagnostics-otel/src/service.ts
|
|
17
18
|
const DEFAULT_SERVICE_NAME = "openclaw";
|
|
18
19
|
const DROPPED_OTEL_ATTRIBUTE_KEYS = new Set([
|
|
@@ -265,6 +266,47 @@ function assignModelCallSizeTimingAttrs(attrs, evt) {
|
|
|
265
266
|
assignPositiveNumberAttr(attrs, "openclaw.model_call.response_bytes", evt.responseStreamBytes);
|
|
266
267
|
assignPositiveNumberAttr(attrs, "openclaw.model_call.time_to_first_byte_ms", evt.timeToFirstByteMs);
|
|
267
268
|
}
|
|
269
|
+
function assignNumberAttr(attrs, key, value) {
|
|
270
|
+
if (typeof value === "number" && Number.isFinite(value)) attrs[key] = value;
|
|
271
|
+
}
|
|
272
|
+
function modelCallPromptTokens(usage) {
|
|
273
|
+
if (typeof usage.promptTokens === "number" && Number.isFinite(usage.promptTokens)) return usage.promptTokens;
|
|
274
|
+
const input = usage.input ?? 0;
|
|
275
|
+
const cacheRead = usage.cacheRead ?? 0;
|
|
276
|
+
const cacheWrite = usage.cacheWrite ?? 0;
|
|
277
|
+
const total = input + cacheRead + cacheWrite;
|
|
278
|
+
return total > 0 ? total : void 0;
|
|
279
|
+
}
|
|
280
|
+
function assignModelCallPromptStatsAttrs(attrs, evt) {
|
|
281
|
+
const stats = evt.promptStats;
|
|
282
|
+
if (!stats) return;
|
|
283
|
+
for (const [key, value] of [
|
|
284
|
+
["openclaw.model_call.prompt.input_messages_count", stats.inputMessagesCount],
|
|
285
|
+
["openclaw.model_call.prompt.input_messages_chars", stats.inputMessagesChars],
|
|
286
|
+
["openclaw.model_call.prompt.system_prompt_chars", stats.systemPromptChars],
|
|
287
|
+
["openclaw.model_call.prompt.tool_definitions_count", stats.toolDefinitionsCount],
|
|
288
|
+
["openclaw.model_call.prompt.tool_definitions_chars", stats.toolDefinitionsChars],
|
|
289
|
+
["openclaw.model_call.prompt.total_chars", stats.totalChars]
|
|
290
|
+
]) assignNumberAttr(attrs, key, value);
|
|
291
|
+
}
|
|
292
|
+
function assignModelCallUsageAttrs(attrs, evt) {
|
|
293
|
+
const usage = evt.usage;
|
|
294
|
+
if (!usage) return;
|
|
295
|
+
const promptTokens = modelCallPromptTokens(usage);
|
|
296
|
+
for (const [key, value] of [
|
|
297
|
+
["openclaw.model_call.usage.input_tokens", usage.input],
|
|
298
|
+
["openclaw.model_call.usage.output_tokens", usage.output],
|
|
299
|
+
["openclaw.model_call.usage.cache_read_input_tokens", usage.cacheRead],
|
|
300
|
+
["openclaw.model_call.usage.cache_creation_input_tokens", usage.cacheWrite],
|
|
301
|
+
["openclaw.model_call.usage.reasoning_output_tokens", usage.reasoningTokens],
|
|
302
|
+
["openclaw.model_call.usage.prompt_tokens", promptTokens],
|
|
303
|
+
["openclaw.model_call.usage.total_tokens", usage.total],
|
|
304
|
+
["gen_ai.usage.input_tokens", promptTokens],
|
|
305
|
+
["gen_ai.usage.output_tokens", usage.output],
|
|
306
|
+
["gen_ai.usage.cache_read.input_tokens", usage.cacheRead],
|
|
307
|
+
["gen_ai.usage.cache_creation.input_tokens", usage.cacheWrite]
|
|
308
|
+
]) assignPositiveNumberAttr(attrs, key, value);
|
|
309
|
+
}
|
|
268
310
|
function assignGenAiSpanIdentityAttrs(attrs, input) {
|
|
269
311
|
if (emitLatestGenAiSemconv()) attrs["gen_ai.provider.name"] = lowCardinalityAttr(input.provider);
|
|
270
312
|
else attrs["gen_ai.system"] = lowCardinalityAttr(input.provider);
|
|
@@ -444,9 +486,6 @@ function describeJsonValue(value) {
|
|
|
444
486
|
if (value === null) return "null";
|
|
445
487
|
return typeof value;
|
|
446
488
|
}
|
|
447
|
-
function isRecord(value) {
|
|
448
|
-
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
449
|
-
}
|
|
450
489
|
function textPart(content) {
|
|
451
490
|
return {
|
|
452
491
|
type: "text",
|
|
@@ -1928,6 +1967,7 @@ function createDiagnosticsOtelService() {
|
|
|
1928
1967
|
assignGenAiModelCallAttrs(spanAttrs, evt);
|
|
1929
1968
|
if (evt.api) spanAttrs["openclaw.api"] = evt.api;
|
|
1930
1969
|
if (evt.transport) spanAttrs["openclaw.transport"] = evt.transport;
|
|
1970
|
+
assignModelCallPromptStatsAttrs(spanAttrs, evt);
|
|
1931
1971
|
trackTrustedSpan(evt, metadata, spanWithDuration(modelCallSpanName(evt), spanAttrs, void 0, {
|
|
1932
1972
|
kind: modelCallSpanKind(),
|
|
1933
1973
|
parentContext: activeTrustedParentContext(evt, metadata),
|
|
@@ -1948,6 +1988,8 @@ function createDiagnosticsOtelService() {
|
|
|
1948
1988
|
if (evt.api) spanAttrs["openclaw.api"] = evt.api;
|
|
1949
1989
|
if (evt.transport) spanAttrs["openclaw.transport"] = evt.transport;
|
|
1950
1990
|
assignModelCallSizeTimingAttrs(spanAttrs, evt);
|
|
1991
|
+
assignModelCallPromptStatsAttrs(spanAttrs, evt);
|
|
1992
|
+
assignModelCallUsageAttrs(spanAttrs, evt);
|
|
1951
1993
|
assignOtelModelContentAttributes(spanAttrs, modelContent, contentCapturePolicy);
|
|
1952
1994
|
const span = takeTrackedTrustedSpan(evt, metadata) ?? spanWithDuration(modelCallSpanName(evt), spanAttrs, evt.durationMs, {
|
|
1953
1995
|
kind: modelCallSpanKind(),
|
|
@@ -1980,6 +2022,8 @@ function createDiagnosticsOtelService() {
|
|
|
1980
2022
|
if (evt.api) spanAttrs["openclaw.api"] = evt.api;
|
|
1981
2023
|
if (evt.transport) spanAttrs["openclaw.transport"] = evt.transport;
|
|
1982
2024
|
assignModelCallSizeTimingAttrs(spanAttrs, evt);
|
|
2025
|
+
assignModelCallPromptStatsAttrs(spanAttrs, evt);
|
|
2026
|
+
assignModelCallUsageAttrs(spanAttrs, evt);
|
|
1983
2027
|
assignOtelModelContentAttributes(spanAttrs, modelContent, contentCapturePolicy);
|
|
1984
2028
|
const span = takeTrackedTrustedSpan(evt, metadata) ?? spanWithDuration(modelCallSpanName(evt), spanAttrs, evt.durationMs, {
|
|
1985
2029
|
kind: modelCallSpanKind(),
|
|
@@ -2305,6 +2349,7 @@ function createDiagnosticsOtelService() {
|
|
|
2305
2349
|
case "exec.process.completed":
|
|
2306
2350
|
recordExecProcessCompleted(evt);
|
|
2307
2351
|
return;
|
|
2352
|
+
case "exec.approval.followup_suppressed": return;
|
|
2308
2353
|
case "log.record":
|
|
2309
2354
|
recordLogRecord?.(evt, metadata);
|
|
2310
2355
|
return;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diagnostics-otel",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.7.1-beta.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/diagnostics-otel",
|
|
9
|
-
"version": "2026.
|
|
9
|
+
"version": "2026.7.1-beta.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@opentelemetry/api": "1.9.1",
|
|
12
12
|
"@opentelemetry/api-logs": "0.219.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/diagnostics-otel",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.7.1-beta.2",
|
|
4
4
|
"description": "OpenClaw diagnostics OpenTelemetry exporter for metrics, traces, and logs.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"minHostVersion": ">=2026.4.25"
|
|
32
32
|
},
|
|
33
33
|
"compat": {
|
|
34
|
-
"pluginApi": ">=2026.
|
|
34
|
+
"pluginApi": ">=2026.7.1-beta.2"
|
|
35
35
|
},
|
|
36
36
|
"build": {
|
|
37
|
-
"openclawVersion": "2026.
|
|
37
|
+
"openclawVersion": "2026.7.1-beta.2"
|
|
38
38
|
},
|
|
39
39
|
"release": {
|
|
40
40
|
"publishToClawHub": true,
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"README.md"
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"openclaw": ">=2026.
|
|
54
|
+
"openclaw": ">=2026.7.1-beta.2"
|
|
55
55
|
},
|
|
56
56
|
"peerDependenciesMeta": {
|
|
57
57
|
"openclaw": {
|