mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
refactor(diagnostics-otel): keep extracted helpers private
This commit is contained in:
@@ -38,7 +38,7 @@ export function lowCardinalityAttr(value: string | undefined, fallback = "unknow
|
||||
return LOW_CARDINALITY_VALUE_RE.test(redacted) ? redacted : fallback;
|
||||
}
|
||||
|
||||
export function securityTargetNameAttr(value: string | undefined, fallback = "unknown"): string {
|
||||
function securityTargetNameAttr(value: string | undefined, fallback = "unknown"): string {
|
||||
if (!value) {
|
||||
return fallback;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ export function shouldCaptureOtelLogBody(policy: OtelContentCapturePolicy): bool
|
||||
return policy.logBodies;
|
||||
}
|
||||
|
||||
export function otelLogTimestampIso(timestamp: LogRecord["timestamp"]): string {
|
||||
function otelLogTimestampIso(timestamp: LogRecord["timestamp"]): string {
|
||||
if (timestamp instanceof Date) {
|
||||
return timestamp.toISOString();
|
||||
}
|
||||
@@ -163,7 +163,7 @@ export function assignOtelLogEventAttributes(
|
||||
}
|
||||
}
|
||||
|
||||
export function assignOtelSecurityEventAttributes(
|
||||
function assignOtelSecurityEventAttributes(
|
||||
attributes: Record<string, string | number | boolean>,
|
||||
eventAttributes: Record<string, string | number | boolean> | undefined,
|
||||
): void {
|
||||
|
||||
@@ -47,7 +47,7 @@ export const GEN_AI_OPERATION_DURATION_BUCKETS = [
|
||||
];
|
||||
// Preserve the SDK's existing finite boundaries so upgrades do not remove
|
||||
// exported bucket series that dashboards or alerts may already reference.
|
||||
export const OTEL_DEFAULT_HISTOGRAM_BUCKETS = [
|
||||
const OTEL_DEFAULT_HISTOGRAM_BUCKETS = [
|
||||
0, 5, 10, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000,
|
||||
];
|
||||
// Agent run / harness durations routinely exceed the SDK default's 10s ceiling.
|
||||
|
||||
@@ -19,7 +19,7 @@ export function normalizeEndpoint(endpoint?: string): string | undefined {
|
||||
return trimmed ? trimmed.replace(/\/+$/, "") : undefined;
|
||||
}
|
||||
|
||||
export function resolveOtelUrl(endpoint: string | undefined, path: string): string | undefined {
|
||||
function resolveOtelUrl(endpoint: string | undefined, path: string): string | undefined {
|
||||
if (!endpoint) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ export function resolveSignalOtelUrl(params: {
|
||||
);
|
||||
}
|
||||
|
||||
export function readOtelEnvFile(params: {
|
||||
function readOtelEnvFile(params: {
|
||||
signalIdentifier: OtelSignalIdentifier;
|
||||
signalSuffix: "CERTIFICATE" | "CLIENT_CERTIFICATE" | "CLIENT_KEY";
|
||||
sharedEnvName: string;
|
||||
@@ -74,7 +74,7 @@ export function readOtelEnvFile(params: {
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeOtelEnvValue(value: string | undefined): string | undefined {
|
||||
function normalizeOtelEnvValue(value: string | undefined): string | undefined {
|
||||
const trimmed = value?.trim();
|
||||
return trimmed ? trimmed : undefined;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ export function errorCategory(err: unknown): string {
|
||||
}
|
||||
}
|
||||
|
||||
export function collectNestedErrorCandidates(err: unknown): unknown[] {
|
||||
function collectNestedErrorCandidates(err: unknown): unknown[] {
|
||||
const queue: unknown[] = [err];
|
||||
const seen = new Set<unknown>();
|
||||
const candidates: unknown[] = [];
|
||||
@@ -204,7 +204,7 @@ export function collectNestedErrorCandidates(err: unknown): unknown[] {
|
||||
return candidates;
|
||||
}
|
||||
|
||||
export function readErrorName(err: unknown): string | undefined {
|
||||
function readErrorName(err: unknown): string | undefined {
|
||||
if (!err || typeof err !== "object") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from "./service-constants.js";
|
||||
import type { ModelCallLifecycleDiagnosticEvent } from "./service-types.js";
|
||||
|
||||
export function hasOtelSemconvOptIn(value: string | undefined, optIn: string): boolean {
|
||||
function hasOtelSemconvOptIn(value: string | undefined, optIn: string): boolean {
|
||||
return (
|
||||
value
|
||||
?.split(",")
|
||||
@@ -17,7 +17,7 @@ export function hasOtelSemconvOptIn(value: string | undefined, optIn: string): b
|
||||
);
|
||||
}
|
||||
|
||||
export function emitLatestGenAiSemconv(): boolean {
|
||||
function emitLatestGenAiSemconv(): boolean {
|
||||
return hasOtelSemconvOptIn(
|
||||
process.env[OTEL_SEMCONV_STABILITY_OPT_IN_ENV],
|
||||
GEN_AI_LATEST_EXPERIMENTAL_OPT_IN,
|
||||
@@ -72,7 +72,7 @@ export function assignModelCallSizeTimingAttrs(
|
||||
);
|
||||
}
|
||||
|
||||
export function assignNumberAttr(
|
||||
function assignNumberAttr(
|
||||
attrs: Record<string, string | number | boolean>,
|
||||
key: string,
|
||||
value: number | undefined,
|
||||
@@ -82,7 +82,7 @@ export function assignNumberAttr(
|
||||
}
|
||||
}
|
||||
|
||||
export function modelCallPromptTokens(usage: {
|
||||
function modelCallPromptTokens(usage: {
|
||||
promptTokens?: number;
|
||||
input?: number;
|
||||
cacheRead?: number;
|
||||
|
||||
@@ -35,7 +35,7 @@ export function normalizeTraceContext(value: unknown): DiagnosticTraceContext |
|
||||
};
|
||||
}
|
||||
|
||||
export function traceFlagsToOtel(traceFlags: string | undefined): TraceFlags {
|
||||
function traceFlagsToOtel(traceFlags: string | undefined): TraceFlags {
|
||||
const parsed = Number.parseInt(traceFlags ?? "00", 16);
|
||||
return (parsed & TraceFlags.SAMPLED) !== 0 ? TraceFlags.SAMPLED : TraceFlags.NONE;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import type {
|
||||
} from "../api.js";
|
||||
|
||||
export type OtelLogsExporter = "otlp" | "stdout" | "both";
|
||||
export type OtelHttpAgent = HttpAgent | HttpsAgent;
|
||||
type OtelHttpAgent = HttpAgent | HttpsAgent;
|
||||
export type OtelHttpAgentFactory = (protocol: string) => OtelHttpAgent | Promise<OtelHttpAgent>;
|
||||
export type OtelSignalIdentifier = "TRACES" | "METRICS" | "LOGS";
|
||||
export type OtelHttpAgentOptions = HttpsAgentOptions & {
|
||||
|
||||
Reference in New Issue
Block a user