Documentation
¶
Overview ¶
Package telemetry provides opt-in OTel tracing and metrics for the short-lived CNI plugin binary. Unlike the agent and registrar (which configure telemetry via flags on a long-running manager), the plugin is exec'd by the container runtime per CNI operation, so:
- the OTLP endpoint arrives in the CNI netconf (written by cni-install), with the standard OTEL_EXPORTER_OTLP_* environment variables as a fallback — the plugin's environment is the runtime's, not a pod's;
- initialization is lazy (Init is called once the netconf is parsed, inside the CNI command handlers);
- everything batched must be force-flushed before the process exits (Flush), on success and failure paths alike.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Flush ¶
Flush exports any buffered spans and metrics and stops the providers. Must run before the process exits on every path; a no-op when Init never ran.
func Init ¶
Init initializes tracing and metrics once per process. endpoint is the OTLP gRPC collector from the CNI netconf; when empty, the standard OTEL_EXPORTER_OTLP_ENDPOINT environment variable is honored instead (the exporters parse it natively, including the scheme's insecure semantics). When neither is set — the default — telemetry stays a no-op.
Safe to call from every CNI command handler; only the first call wins.
func RecordOperation ¶
RecordOperation records the outcome and duration of one CNI operation (add/del/check/gc/status). A no-op unless Init enabled telemetry. The instruments are created per call: the plugin process handles exactly one operation before exiting, so there is nothing to cache.
Types ¶
This section is empty.