@openclaw/diagnostics-otel 2026.10.5-beta.4 → 2026.10.10-beta.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.
@@ -1,4 +1,4 @@
1
- import { ROOT_CONTEXT, SpanKind, SpanStatusCode, TraceFlags, context, createContextKey, createNoopMeter, diag, isSpanContextValid, metrics, propagation, trace } from "@opentelemetry/api";
1
+ import { ROOT_CONTEXT, SpanKind, SpanStatusCode, TraceFlags, context, createNoopMeter, diag, isSpanContextValid, metrics, propagation, trace } from "@opentelemetry/api";
2
2
  import * as otelCore from "@opentelemetry/core";
3
3
  import { CompositePropagator, ExportResultCode, W3CBaggagePropagator, W3CTraceContextPropagator, getStringListFromEnv } from "@opentelemetry/core";
4
4
  import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
@@ -57,12 +57,6 @@ const BLOCKED_OTEL_LOG_ATTRIBUTE_KEYS = /* @__PURE__ */ new Set([
57
57
  "constructor"
58
58
  ]);
59
59
  const OTEL_EXPORTER_OTLP_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_ENDPOINT";
60
- const OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
61
- const OTEL_EXPORTER_OTLP_METRICS_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_METRICS_ENDPOINT";
62
- const OTEL_EXPORTER_OTLP_LOGS_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT";
63
- const OTEL_EXPORTER_OTLP_TRACES_PROTOCOL_ENV = "OTEL_EXPORTER_OTLP_TRACES_PROTOCOL";
64
- const OTEL_EXPORTER_OTLP_METRICS_PROTOCOL_ENV = "OTEL_EXPORTER_OTLP_METRICS_PROTOCOL";
65
- const OTEL_EXPORTER_OTLP_LOGS_PROTOCOL_ENV = "OTEL_EXPORTER_OTLP_LOGS_PROTOCOL";
66
60
  const OTEL_EXPORTER_OTLP_CERTIFICATE_ENV = "OTEL_EXPORTER_OTLP_CERTIFICATE";
67
61
  const OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE_ENV = "OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE";
68
62
  const OTEL_EXPORTER_OTLP_CLIENT_KEY_ENV = "OTEL_EXPORTER_OTLP_CLIENT_KEY";
@@ -467,22 +461,19 @@ function createExporterHealthEventEmitter(publish) {
467
461
  }
468
462
  const reason = event.reason ?? "unspecified";
469
463
  if (event.status === "failure") {
470
- const route = failures.get(key) ?? { active: /* @__PURE__ */ new Map() };
471
- failures.set(key, route);
472
- if (route.active.has(reason)) return;
473
- route.active.set(reason, event);
474
- if (route.reported === void 0) {
475
- route.reported = reason;
476
- publish(event);
477
- }
464
+ const active = failures.get(key) ?? /* @__PURE__ */ new Map();
465
+ if (active.has(reason)) return;
466
+ active.set(reason, event);
467
+ failures.set(key, active);
468
+ if (active.size === 1) publish(event);
478
469
  return;
479
470
  }
480
- const route = failures.get(key);
481
- if (!route?.active.delete(reason) || route.reported !== reason) return;
482
- const next = route.active.entries().next().value;
471
+ const active = failures.get(key);
472
+ const reported = active?.keys().next().value;
473
+ if (!active?.delete(reason) || reported !== reason) return;
474
+ const next = active.values().next().value;
483
475
  if (next) {
484
- route.reported = next[0];
485
- publish(next[1]);
476
+ publish(next);
486
477
  return;
487
478
  }
488
479
  failures.delete(key);
@@ -855,16 +846,17 @@ function createDiagnosticsMetrics(meter, metricNamePrefix = DEFAULT_METRIC_NAME_
855
846
  description,
856
847
  ...explicitBucketBoundaries ? { advice: { explicitBucketBoundaries } } : {}
857
848
  });
849
+ const createDurationHistogram = (name, description) => createHistogram(name, description, "ms", AGENT_DURATION_MS_BUCKETS);
858
850
  return {
859
- gcDurationHistogram: createHistogram("gc.duration_ms", "Elapsed garbage collection duration for the hosting JavaScript isolate", "ms", AGENT_DURATION_MS_BUCKETS),
860
- gatewayEventLoopDelayMaxHistogram: createHistogram("gateway.event_loop.delay_max_ms", "Maximum event-loop delay per completed Gateway observation window", "ms", AGENT_DURATION_MS_BUCKETS),
851
+ gcDurationHistogram: createDurationHistogram("gc.duration_ms", "Elapsed garbage collection duration for the hosting JavaScript isolate"),
852
+ gatewayEventLoopDelayMaxHistogram: createDurationHistogram("gateway.event_loop.delay_max_ms", "Maximum event-loop delay per completed Gateway observation window"),
861
853
  gatewayEventLoopObservedCounter: createCounter("gateway.event_loop.observed_ms", "Elapsed time covered by completed Gateway event-loop observation windows", "ms"),
862
854
  gatewayRpcRequestsCounter: createCounter("gateway.rpc.requests", "Authenticated Gateway WebSocket requests received"),
863
855
  gatewayRpcOutcomesCounter: createCounter("gateway.rpc.outcomes", "Gateway RPC observations by phase and outcome"),
864
- gatewayRpcFirstResponseHistogram: createHistogram("gateway.rpc.first_response_ms", "Elapsed time until the first Gateway RPC response is sent", "ms", AGENT_DURATION_MS_BUCKETS),
865
- gatewayRpcHandlerHistogram: createHistogram("gateway.rpc.handler_ms", "Gateway RPC handler duration until return or throw", "ms", AGENT_DURATION_MS_BUCKETS),
866
- gatewayRpcAdmissionHistogram: createHistogram("gateway.rpc.admission_ms", "Elapsed time from Gateway RPC receipt until handler invocation", "ms", AGENT_DURATION_MS_BUCKETS),
867
- gatewayRpcQueueWaitHistogram: createHistogram("gateway.rpc.queue_wait_ms", "Gateway operator start queue or worker frame queue wait", "ms", AGENT_DURATION_MS_BUCKETS),
856
+ gatewayRpcFirstResponseHistogram: createDurationHistogram("gateway.rpc.first_response_ms", "Elapsed time until the first Gateway RPC response is sent"),
857
+ gatewayRpcHandlerHistogram: createDurationHistogram("gateway.rpc.handler_ms", "Gateway RPC handler duration until return or throw"),
858
+ gatewayRpcAdmissionHistogram: createDurationHistogram("gateway.rpc.admission_ms", "Elapsed time from Gateway RPC receipt until handler invocation"),
859
+ gatewayRpcQueueWaitHistogram: createDurationHistogram("gateway.rpc.queue_wait_ms", "Gateway operator start queue or worker frame queue wait"),
868
860
  tokensCounter: createCounter("tokens", "Token usage by type"),
869
861
  genAiTokenUsageHistogram: meter.createHistogram("gen_ai.client.token.usage", {
870
862
  unit: "{token}",
@@ -877,8 +869,8 @@ function createDiagnosticsMetrics(meter, metricNamePrefix = DEFAULT_METRIC_NAME_
877
869
  advice: { explicitBucketBoundaries: GEN_AI_OPERATION_DURATION_BUCKETS }
878
870
  }),
879
871
  costCounter: createCounter("cost.usd", "Estimated model cost (USD)"),
880
- durationHistogram: createHistogram("run.duration_ms", "Agent run duration", "ms", AGENT_DURATION_MS_BUCKETS),
881
- harnessDurationHistogram: createHistogram("harness.duration_ms", "Agent harness lifecycle duration", "ms", AGENT_DURATION_MS_BUCKETS),
872
+ durationHistogram: createDurationHistogram("run.duration_ms", "Agent run duration"),
873
+ harnessDurationHistogram: createDurationHistogram("harness.duration_ms", "Agent harness lifecycle duration"),
882
874
  contextHistogram: createHistogram("context.tokens", "Context window size and usage", "1", CONTEXT_TOKENS_BUCKETS),
883
875
  webhookReceivedCounter: createCounter("webhook.received", "Webhook requests received"),
884
876
  webhookErrorCounter: createCounter("webhook.error", "Webhook processing errors"),
@@ -937,49 +929,6 @@ function createDiagnosticsMetrics(meter, metricNamePrefix = DEFAULT_METRIC_NAME_
937
929
  //#endregion
938
930
  //#region extensions/diagnostics-otel/src/service-propagation.ts
939
931
  const DEFAULT_PROPAGATORS = ["tracecontext", "baggage"];
940
- const CONTEXT_OWNER_KEY = createContextKey("openclaw.owned-sdk.context-owner");
941
- const PROPAGATOR_OWNER_KEY = createContextKey("openclaw.owned-sdk.propagator-owner");
942
- var OwnedContextManager = class extends AsyncLocalStorageContextManager {
943
- constructor(owner) {
944
- super();
945
- this.owner = owner;
946
- }
947
- with(activeContext, fn, thisArg, ...args) {
948
- const probe = activeContext.getValue(CONTEXT_OWNER_KEY);
949
- if (probe && typeof probe === "object") probe.owner = this.owner;
950
- return super.with(activeContext, fn, thisArg, ...args);
951
- }
952
- };
953
- var OwnedPropagator = class {
954
- constructor(delegate, owner) {
955
- this.delegate = delegate;
956
- this.owner = owner;
957
- }
958
- inject(carrierContext, carrier, setter) {
959
- const probe = carrierContext.getValue(PROPAGATOR_OWNER_KEY);
960
- if (probe && typeof probe === "object") {
961
- probe.owner = this.owner;
962
- return;
963
- }
964
- this.delegate.inject(carrierContext, carrier, setter);
965
- }
966
- extract(carrierContext, carrier, getter) {
967
- return this.delegate.extract(carrierContext, carrier, getter);
968
- }
969
- fields() {
970
- return this.delegate.fields();
971
- }
972
- };
973
- function ownsGlobalPropagator(owner) {
974
- const probe = {};
975
- propagation.inject(ROOT_CONTEXT.setValue(PROPAGATOR_OWNER_KEY, probe), {}, { set() {} });
976
- return probe.owner === owner;
977
- }
978
- function ownsGlobalContextManager(owner) {
979
- const probe = {};
980
- context.with(ROOT_CONTEXT.setValue(CONTEXT_OWNER_KEY, probe), () => {});
981
- return probe.owner === owner;
982
- }
983
932
  function createConfiguredPropagator(warn) {
984
933
  const names = (getStringListFromEnv("OTEL_PROPAGATORS") ?? DEFAULT_PROPAGATORS).map((name) => name.toLowerCase());
985
934
  if (names.includes("none")) return null;
@@ -1001,17 +950,15 @@ function createConfiguredPropagator(warn) {
1001
950
  return propagators.length === 1 ? propagators[0] : new CompositePropagator({ propagators });
1002
951
  }
1003
952
  function registerOwnedSdkRuntime(warn) {
1004
- const owner = {};
1005
- const contextManager = new OwnedContextManager(owner).enable();
953
+ const contextManager = new AsyncLocalStorageContextManager().enable();
1006
954
  const ownsContext = context.setGlobalContextManager(contextManager);
1007
955
  if (!ownsContext) contextManager.disable();
1008
956
  const propagator = createConfiguredPropagator(warn);
1009
- const ownsPropagation = propagator ? propagation.setGlobalPropagator(new OwnedPropagator(propagator, owner)) : false;
957
+ const ownsPropagation = propagator ? propagation.setGlobalPropagator(propagator) : false;
1010
958
  if (!ownsContext && !ownsPropagation) return null;
1011
959
  return () => {
1012
- if (ownsPropagation && ownsGlobalPropagator(owner)) propagation.disable();
1013
- if (ownsContext && ownsGlobalContextManager(owner)) context.disable();
1014
- else if (ownsContext) contextManager.disable();
960
+ if (ownsPropagation) propagation.disable();
961
+ if (ownsContext) context.disable();
1015
962
  };
1016
963
  }
1017
964
  //#endregion
@@ -1247,10 +1194,12 @@ function createHarnessRecorders(runtime) {
1247
1194
  assignOtelModelContentAttributes(attrs, privateData.modelContent, runtime.captureContent);
1248
1195
  span.addEvent("openclaw.agent.commentary", redactOtelAttributes(attrs), evt.sourceTimestampMs);
1249
1196
  },
1250
- recordHarnessRunStarted(evt, metadata) {
1197
+ recordHarnessRunStarted(evt, metadata, privateData) {
1251
1198
  if (!runtime.tracesEnabled || !metadata.trusted) return;
1252
1199
  const spanAttrs = { ...harnessRunMetricAttrs(evt) };
1253
1200
  runtime.addRunAttrs(spanAttrs, evt);
1201
+ const inputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.harnessContent?.userPrompt) : void 0;
1202
+ if (inputValue) spanAttrs["input.value"] = inputValue;
1254
1203
  runtime.trackTrustedSpan(evt, metadata, runtime.spanWithDuration("openclaw.harness.run", spanAttrs, void 0, {
1255
1204
  parentContext: runtime.activeTrustedParentContext(evt, metadata),
1256
1205
  startTimeMs: evt.ts
@@ -1283,6 +1232,10 @@ function createHarnessRecorders(runtime) {
1283
1232
  }
1284
1233
  const redactedError = normalizeOtelErrorMessage(privateData.errorMessage);
1285
1234
  if (redactedError) spanAttrs["openclaw.error"] = redactedError;
1235
+ const inputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.harnessContent?.userPrompt) : void 0;
1236
+ if (inputValue) spanAttrs["input.value"] = inputValue;
1237
+ const outputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.harnessContent?.finalResponse) : void 0;
1238
+ if (outputValue) spanAttrs["output.value"] = outputValue;
1286
1239
  const trustedTrace = runtime.trustedTraceContext(evt, metadata);
1287
1240
  const trackedSpan = trustedTrace?.spanId ? runtime.activeTrustedSpans.get(trustedTrace.spanId) : void 0;
1288
1241
  const span = trackedSpan ?? runtime.spanWithDuration("openclaw.harness.run", spanAttrs, evt.durationMs, {
@@ -1704,6 +1657,10 @@ function createOperationsRecorders(runtime) {
1704
1657
  if (evt.errorCategory) spanAttrs["openclaw.errorCategory"] = normalizeDiagnosticValue(evt.errorCategory, "other");
1705
1658
  const redactedError = normalizeOtelErrorMessage(privateData.errorMessage);
1706
1659
  if (redactedError) spanAttrs["openclaw.error"] = redactedError;
1660
+ const inputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.messageContent?.userPrompt) : void 0;
1661
+ if (inputValue) spanAttrs["input.value"] = inputValue;
1662
+ const outputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.messageContent?.finalResponse) : void 0;
1663
+ if (outputValue) spanAttrs["output.value"] = outputValue;
1707
1664
  const trustedTrace = runtime.trustedTraceContext(evt, metadata);
1708
1665
  const trackedSpan = trustedTrace?.spanId ? runtime.activeTrustedSpans.get(trustedTrace.spanId) : void 0;
1709
1666
  const span = trackedSpan ?? runtime.spanWithDuration("openclaw.run", spanAttrs, evt.durationMs, {
@@ -1730,13 +1687,17 @@ function createToolAndSystemRecorders(runtime) {
1730
1687
  "openclaw.tool.source": normalizeDiagnosticValue(evt.toolSource, "core"),
1731
1688
  "gen_ai.tool.name": evt.toolName,
1732
1689
  ...evt.toolOwner ? { "openclaw.tool.owner": normalizeDiagnosticValue(evt.toolOwner) } : {},
1733
- ...runtime.paramsSummaryAttrs(evt.paramsSummary)
1690
+ ...evt.paramsSummary ? { "openclaw.tool.params.kind": evt.paramsSummary.kind } : {}
1734
1691
  });
1735
1692
  const toolTimestampMs = (evt) => evt.sourceTimestampMs ?? evt.ts;
1736
1693
  return {
1737
1694
  recordGcDuration(evt, metadata) {
1738
1695
  if (!metadata.trusted && !isInternalDiagnosticEventMetadata(metadata)) return;
1739
- runtime.gcDurationHistogram.record(evt.durationMs, void 0, ROOT_CONTEXT);
1696
+ runtime.gcDurationHistogram.record(evt.durationMs, {
1697
+ "openclaw.gc.kind": evt.kind ?? "unknown",
1698
+ "openclaw.gc.thread": evt.thread ?? "main",
1699
+ ...evt.workerSlot === void 0 ? {} : { "openclaw.gc.worker_slot": evt.workerSlot }
1700
+ }, ROOT_CONTEXT);
1740
1701
  },
1741
1702
  recordGatewayEventLoopSample(evt, metadata) {
1742
1703
  if (!metadata.trusted && !isInternalDiagnosticEventMetadata(metadata)) return;
@@ -1767,7 +1728,10 @@ function createToolAndSystemRecorders(runtime) {
1767
1728
  if (!runtime.tracesEnabled || !metadata.trusted) return;
1768
1729
  const trackedSpan = runtime.getTrackedInternalOrTrustedSpan(evt, metadata);
1769
1730
  if (trackedSpan) return trackedSpan.spanContext();
1770
- const spanAttrs = toolExecutionBaseAttrs(evt);
1731
+ const spanAttrs = {
1732
+ ...toolExecutionBaseAttrs(evt),
1733
+ ...runtime.paramsSummaryAttrs(evt.paramsSummary)
1734
+ };
1771
1735
  assignOtelToolIdentityAttributes(spanAttrs, evt);
1772
1736
  return runtime.trackTrustedSpan(evt, metadata, runtime.spanWithDuration("openclaw.tool.execution", spanAttrs, void 0, {
1773
1737
  parentContext: runtime.activeTrustedParentContext(evt, metadata),
@@ -1779,7 +1743,10 @@ function createToolAndSystemRecorders(runtime) {
1779
1743
  if (evt.type === "tool.execution.error") attrs["openclaw.errorCategory"] = normalizeDiagnosticValue(evt.errorCategory, "other");
1780
1744
  runtime.toolExecutionDurationHistogram.record(evt.durationMs, attrs);
1781
1745
  if (!runtime.tracesEnabled) return;
1782
- const spanAttrs = { ...attrs };
1746
+ const spanAttrs = {
1747
+ ...attrs,
1748
+ ...runtime.paramsSummaryAttrs(evt.paramsSummary)
1749
+ };
1783
1750
  runtime.addRunAttrs(spanAttrs, evt);
1784
1751
  assignOtelToolIdentityAttributes(spanAttrs, evt);
1785
1752
  if (evt.type === "tool.execution.error" && evt.errorCode) spanAttrs["openclaw.errorCode"] = normalizeDiagnosticValue(evt.errorCode, "other");
@@ -1803,6 +1770,7 @@ function createToolAndSystemRecorders(runtime) {
1803
1770
  if (!runtime.tracesEnabled) return;
1804
1771
  const spanAttrs = {
1805
1772
  ...toolExecutionBaseAttrs(evt),
1773
+ ...runtime.paramsSummaryAttrs(evt.paramsSummary),
1806
1774
  "openclaw.outcome": "blocked",
1807
1775
  "openclaw.deniedReason": normalizeDiagnosticValue(evt.deniedReason, "other")
1808
1776
  };
@@ -2063,7 +2031,7 @@ function createUsageRecorders(runtime) {
2063
2031
  runtime.messageDispatchCompletedCounter.add(1, attrs);
2064
2032
  runtime.messageDispatchDurationHistogram.record(evt.durationMs, attrs);
2065
2033
  },
2066
- recordMessageProcessed(evt, metadata) {
2034
+ recordMessageProcessed(evt, metadata, privateData) {
2067
2035
  const attrs = {
2068
2036
  "openclaw.channel": normalizeDiagnosticValue(evt.channel),
2069
2037
  "openclaw.outcome": evt.outcome ?? "unknown"
@@ -2074,6 +2042,10 @@ function createUsageRecorders(runtime) {
2074
2042
  const spanAttrs = { ...attrs };
2075
2043
  runtime.addRunAttrs(spanAttrs, evt);
2076
2044
  if (evt.reason) spanAttrs["openclaw.reason"] = normalizeDiagnosticValue(evt.reason, "unknown");
2045
+ const inputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.messageContent?.userPrompt) : void 0;
2046
+ if (inputValue) spanAttrs["input.value"] = inputValue;
2047
+ const outputValue = runtime.captureContent ? normalizeOtelContentValue(privateData.messageContent?.finalResponse) : void 0;
2048
+ if (outputValue) spanAttrs["output.value"] = outputValue;
2077
2049
  const trackedSpan = runtime.getTrackedInternalOrTrustedSpan(evt, metadata);
2078
2050
  const span = trackedSpan ?? runtime.spanWithDuration("openclaw.message.processed", spanAttrs, evt.durationMs, {
2079
2051
  parentContext: runtime.internalOrTrustedExplicitParentContext(evt, metadata),
@@ -2121,10 +2093,7 @@ function createUsageRecorders(runtime) {
2121
2093
  }));
2122
2094
  const parentSpanId = runtime.trustedTraceContext(evt, metadata)?.parentSpanId;
2123
2095
  if (parentSpanId && !runtime.activeTrustedSpans.has(parentSpanId)) {
2124
- const owner = {
2125
- kind: "run",
2126
- id: evt.runId
2127
- };
2096
+ const owner = evt.runId;
2128
2097
  runtime.activeTrustedSpanAliases.set(runtime.trustedSpanAliasKey(parentSpanId, owner), {
2129
2098
  span,
2130
2099
  spanId: parentSpanId,
@@ -2158,27 +2127,16 @@ function createDiagnosticsTraceRuntime(tracer) {
2158
2127
  };
2159
2128
  const trustedTraceContext = (evt, metadata) => metadata.trusted ? normalizeTraceContext(evt.trace) : void 0;
2160
2129
  const internalOrTrustedTraceContext = (evt, metadata) => metadata.internal ? normalizeTraceContext(evt.trace) : normalizedTrustedTraceContext(evt, metadata);
2161
- const trustedSpanAliasOwner = (evt) => {
2162
- if ("runId" in evt && evt.runId) return {
2163
- kind: "run",
2164
- id: evt.runId
2165
- };
2166
- };
2167
- const sameTrustedSpanAliasOwner = (left, right) => Boolean(left && right && left.kind === right.kind && left.id === right.id);
2168
- const trustedSpanAliasKey = (spanId, owner) => `${spanId}:${owner.kind}:${owner.id}`;
2130
+ const trustedSpanAliasOwner = (evt) => "runId" in evt ? evt.runId || void 0 : void 0;
2131
+ const trustedSpanAliasKey = (spanId, owner) => `${spanId}:run:${owner}`;
2169
2132
  const retainedTrustedSpanContextKey = (traceId, spanId, owner) => `${traceId}:${owner ? trustedSpanAliasKey(spanId, owner) : spanId}`;
2170
2133
  const retainedTrustedSpanContext = (traceContext, spanId, owner) => {
2171
2134
  if (!traceContext?.traceId || !spanId) return;
2172
- const retained = (owner ? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId, owner)) : void 0) ?? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId));
2173
- if (!retained) return;
2174
- if (retained.owner && !sameTrustedSpanAliasOwner(retained.owner, owner)) return;
2175
- return retained.spanContext;
2135
+ return (owner ? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId, owner)) : void 0) ?? retainedTrustedSpanContexts.get(retainedTrustedSpanContextKey(traceContext.traceId, spanId));
2176
2136
  };
2177
2137
  const activeTrustedSpanAlias = (spanId, owner) => {
2178
2138
  if (!owner) return;
2179
- const alias = activeTrustedSpanAliases.get(trustedSpanAliasKey(spanId, owner));
2180
- if (!alias || !sameTrustedSpanAliasOwner(alias.owner, owner)) return;
2181
- return alias.span;
2139
+ return activeTrustedSpanAliases.get(trustedSpanAliasKey(spanId, owner))?.span;
2182
2140
  };
2183
2141
  const internalOrTrustedParentContext = (evt, metadata) => {
2184
2142
  const traceContext = internalOrTrustedTraceContext(evt, metadata);
@@ -2247,10 +2205,7 @@ function createDiagnosticsTraceRuntime(tracer) {
2247
2205
  span.setAttributes?.(redactOtelAttributes(attributes));
2248
2206
  };
2249
2207
  const retainTrustedSpanContext = (traceId, spanId, spanContext, owner) => {
2250
- retainedTrustedSpanContexts.set(retainedTrustedSpanContextKey(traceId, spanId, owner), {
2251
- spanContext,
2252
- ...owner ? { owner } : {}
2253
- });
2208
+ retainedTrustedSpanContexts.set(retainedTrustedSpanContextKey(traceId, spanId, owner), spanContext);
2254
2209
  pruneMapToMaxSize(retainedTrustedSpanContexts, MAX_RETAINED_TRUSTED_SPAN_CONTEXTS);
2255
2210
  };
2256
2211
  const completeTrackedLifecycleSpan = (traceContext, span, endTimeMs) => {
@@ -2320,11 +2275,6 @@ const RESOURCE_DETECTORS = [
2320
2275
  ["process", resources.processDetector],
2321
2276
  ["env", resources.envDetector]
2322
2277
  ];
2323
- const OTEL_SIGNAL_PROTOCOL_ENV = {
2324
- traces: OTEL_EXPORTER_OTLP_TRACES_PROTOCOL_ENV,
2325
- metrics: OTEL_EXPORTER_OTLP_METRICS_PROTOCOL_ENV,
2326
- logs: OTEL_EXPORTER_OTLP_LOGS_PROTOCOL_ENV
2327
- };
2328
2278
  function isOtelSdkDisabled(logger) {
2329
2279
  const value = process.env.OTEL_SDK_DISABLED?.trim().toLowerCase();
2330
2280
  if (!value || value === "false") return false;
@@ -2470,7 +2420,7 @@ function createDiagnosticsOtelService() {
2470
2420
  ];
2471
2421
  const supportedOtlpSignals = /* @__PURE__ */ new Set();
2472
2422
  for (const signal of ownedOtlpSignals) {
2473
- const protocol = otel.protocol ?? readNonBlankString(process.env[OTEL_SIGNAL_PROTOCOL_ENV[signal]]) ?? readNonBlankString(process.env["OTEL_EXPORTER_OTLP_PROTOCOL"]) ?? OTLP_HTTP_PROTOBUF_PROTOCOL;
2423
+ const protocol = otel.protocol ?? readNonBlankString(process.env[`OTEL_EXPORTER_OTLP_${signal.toUpperCase()}_PROTOCOL`]) ?? readNonBlankString(process.env["OTEL_EXPORTER_OTLP_PROTOCOL"]) ?? OTLP_HTTP_PROTOBUF_PROTOCOL;
2474
2424
  if (protocol === OTLP_HTTP_PROTOBUF_PROTOCOL) {
2475
2425
  supportedOtlpSignals.add(signal);
2476
2426
  continue;
@@ -2502,39 +2452,31 @@ function createDiagnosticsOtelService() {
2502
2452
  });
2503
2453
  const captureContent = otel.captureContent === true;
2504
2454
  const resource = resources.resourceFromAttributes({ [ATTR_SERVICE_NAME]: serviceName });
2505
- const logUrl = logsToOtlp ? resolveSignalOtelUrl({
2506
- signalEndpoint: otel.logsEndpoint,
2507
- signalEnvEndpoint: process.env[OTEL_EXPORTER_OTLP_LOGS_ENDPOINT_ENV],
2508
- sharedEnvEndpoint,
2509
- endpoint,
2510
- path: "v1/logs"
2511
- }) : void 0;
2512
- const traceUrl = tracesToOtlp ? resolveSignalOtelUrl({
2513
- signalEndpoint: otel.tracesEndpoint,
2514
- signalEnvEndpoint: process.env[OTEL_EXPORTER_OTLP_TRACES_ENDPOINT_ENV],
2515
- sharedEnvEndpoint,
2516
- endpoint,
2517
- path: "v1/traces"
2518
- }) : void 0;
2519
- const metricUrl = metricsToOtlp ? resolveSignalOtelUrl({
2520
- signalEndpoint: otel.metricsEndpoint,
2521
- signalEnvEndpoint: process.env[OTEL_EXPORTER_OTLP_METRICS_ENDPOINT_ENV],
2522
- sharedEnvEndpoint,
2523
- endpoint,
2524
- path: "v1/metrics"
2525
- }) : void 0;
2526
- const logHttpAgentOptions = logsToOtlp ? resolveOtelHttpAgentOptions({
2527
- url: logUrl,
2528
- signalIdentifier: "LOGS"
2529
- }) : void 0;
2530
- const traceHttpAgentOptions = tracesToOtlp ? resolveOtelHttpAgentOptions({
2531
- url: traceUrl,
2532
- signalIdentifier: "TRACES"
2533
- }) : void 0;
2534
- const metricHttpAgentOptions = metricsToOtlp ? resolveOtelHttpAgentOptions({
2535
- url: metricUrl,
2536
- signalIdentifier: "METRICS"
2537
- }) : void 0;
2455
+ const resolveSignal = (signal, enabled) => {
2456
+ if (!enabled) return {};
2457
+ const signalIdentifier = {
2458
+ logs: "LOGS",
2459
+ traces: "TRACES",
2460
+ metrics: "METRICS"
2461
+ }[signal];
2462
+ const url = resolveSignalOtelUrl({
2463
+ signalEndpoint: otel[`${signal}Endpoint`],
2464
+ signalEnvEndpoint: process.env[`OTEL_EXPORTER_OTLP_${signalIdentifier}_ENDPOINT`],
2465
+ sharedEnvEndpoint,
2466
+ endpoint,
2467
+ path: `v1/${signal}`
2468
+ });
2469
+ return {
2470
+ url,
2471
+ httpAgentOptions: resolveOtelHttpAgentOptions({
2472
+ url,
2473
+ signalIdentifier
2474
+ })
2475
+ };
2476
+ };
2477
+ const { url: logUrl, httpAgentOptions: logHttpAgentOptions } = resolveSignal("logs", logsToOtlp);
2478
+ const { url: traceUrl, httpAgentOptions: traceHttpAgentOptions } = resolveSignal("traces", tracesToOtlp);
2479
+ const { url: metricUrl, httpAgentOptions: metricHttpAgentOptions } = resolveSignal("metrics", metricsToOtlp);
2538
2480
  if (tracesToOtlp || metricsToOtlp) try {
2539
2481
  const detectedResource = resources.detectResources({ detectors: resolveResourceDetectors() }).merge(resource);
2540
2482
  const sdkMetricsEnabled = otelCore.getBooleanFromEnv("OTEL_NODE_EXPERIMENTAL_SDK_METRICS");
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-CKLGMqUx.mjs";
1
+ import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-DNn_S1dw.mjs";
2
2
  import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
3
3
  //#region extensions/diagnostics-otel/index.ts
4
4
  var diagnostics_otel_default = definePluginEntry({
@@ -1,2 +1 @@
1
- import { t as createDiagnosticsOtelService } from "./.setup/runtime-api-CKLGMqUx.mjs";
2
- export { createDiagnosticsOtelService };
1
+ export { t as createDiagnosticsOtelService } from "./.setup/runtime-api-DNn_S1dw.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/diagnostics-otel",
3
- "version": "2026.10.5-beta.4",
3
+ "version": "2026.10.10-beta.1",
4
4
  "description": "OpenClaw diagnostics OpenTelemetry exporter for metrics, traces, and logs.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,10 +34,10 @@
34
34
  "minHostVersion": ">=2026.4.25"
35
35
  },
36
36
  "compat": {
37
- "pluginApi": ">=2026.10.5-beta.4"
37
+ "pluginApi": ">=2026.10.10-beta.1"
38
38
  },
39
39
  "build": {
40
- "openclawVersion": "2026.10.5-beta.4"
40
+ "openclawVersion": "2026.10.10-beta.1"
41
41
  },
42
42
  "release": {
43
43
  "publishToClawHub": true,
@@ -55,7 +55,7 @@
55
55
  "assets/activity.svg"
56
56
  ],
57
57
  "peerDependencies": {
58
- "openclaw": ">=2026.10.5-beta.4"
58
+ "openclaw": ">=2026.10.10-beta.1"
59
59
  },
60
60
  "peerDependenciesMeta": {
61
61
  "openclaw": {