telemetry

package
v0.0.0-...-c46dd35 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

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

func Flush(logger *zap.Logger)

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

func Init(ctx context.Context, logger *zap.Logger, endpoint string)

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

func RecordOperation(op string, duration time.Duration, opErr error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL