openclaw-grafana-lens
Version:
OpenClaw plugin that gives AI agents full Grafana access — 18 composable tools for PromQL/LogQL/TraceQL queries, dashboard creation, alerting, SRE investigation, security monitoring, data collection pipeline management via Grafana Alloy (29 recipes), and
31 lines (30 loc) • 1.15 kB
TypeScript
/**
* OTLP Traces Provider
*
* Central TracerProvider lifecycle module. Creates an OpenTelemetry
* BasicTracerProvider that pushes trace spans via OTLP HTTP/JSON
* to the configured collector (LGTM stack, Grafana Cloud, etc.).
*
* Mirrors the otel-metrics.ts pattern exactly:
* - Local provider only (NO global registration — avoids conflict with diagnostics-otel)
* - Fire-and-forget emission via BatchSpanProcessor
* - Same shared resource identity (service.name=openclaw, service.namespace=grafana-lens)
*
* Data flow:
* Diagnostic events / tool calls → OTel Span → OTLP exporter → Collector → Tempo → Grafana
*/
import type { Tracer } from "@opentelemetry/api";
import { SpanKind, SpanStatusCode } from "@opentelemetry/api";
export { SpanKind, SpanStatusCode };
export type OtelTracesConfig = {
endpoint: string;
headers?: Record<string, string>;
serviceVersion?: string;
serviceInstanceId?: string;
};
export type OtelTraces = {
tracer: Tracer;
forceFlush(): Promise<void>;
shutdown(): Promise<void>;
};
export declare function createOtelTraces(config: OtelTracesConfig): OtelTraces;