telemetry

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrNilRestConfig occurs when a nil *rest.Config is provided.
	ErrNilRestConfig = err("provided nil *rest.Config")
	// ErrNilDynClientProvided occurs when a nil dynamic.Interface is provided.
	ErrNilDynClientProvided = err("provided nil dynamic.Interface")
	// ErrNilKubernetesInterfaceProvided occurs when a nil kubernetes.Interface is provided.
	ErrNilKubernetesInterfaceProvided = err("provided nil kubernetes.Interface")
	// ErrNilControllerRuntimeClientProvided occurs when a nil controller-runtime client is provided.
	ErrNilControllerRuntimeClientProvided = err("provided nil controller-runtime client")
)
View Source
const (
	// ErrManagerAlreadyStarted occurs when a manager has been already started
	// and it's attempted to be started again.
	ErrManagerAlreadyStarted = managerErr("manager already started")
	// ErrCantAddConsumersAfterStart occurs when consumers are tried to be added
	// after the manager has been already started.
	ErrCantAddConsumersAfterStart = managerErr("can't add consumers after start")
	// ErrManagerAlreadyStopped occurs when manager has already been stopped.
	ErrManagerAlreadyStopped = managerErr("manager stopped")
)
View Source
const (
	// ClusterStateWorkflowName is the name assigned to cluster state workflow.
	ClusterStateWorkflowName = "cluster-state"
)
View Source
const (
	// DefaultWorkflowTickPeriod is the default tick period with which the manager
	// will trigger configured workflows execution.
	DefaultWorkflowTickPeriod = 5 * time.Second
)
View Source
const (
	// IdentifyPlatformWorkflowName is the name assigned to identify platform
	// workflow.
	IdentifyPlatformWorkflowName = "identify-platform"
)
View Source
const (
	// MeshDetectWorkflowName is the name assigned to mesh detect workflow.
	MeshDetectWorkflowName = "mesh-detect"
)
View Source
const (
	// StateWorkflowName is the name assigned to state workflow.
	StateWorkflowName = "state"
)

Variables

This section is empty.

Functions

func NewConsumer

func NewConsumer(s Serializer, f Forwarder) *consumer

NewConsumer creates a new consumer which will use the provided serializer to serialize the data and then forward it using the provided forwarder.

func NewRawConsumer

func NewRawConsumer(f RawForwarder) *rawConsumer

NewRawConsumer creates a new rawconsumer that will use the provided raw forwarder to forward received reports.

Types

type Consumer

type Consumer interface {
	Intake() chan<- types.SignalReport
	Close()
}

Consumer is an entity that can consume telemetry reports on a channel returned by Intake().

type Forwarder

type Forwarder interface {
	Name() string
	Forward(context.Context, []byte) error
}

Forwarder is used to forward telemetry reports to configured destination(s).

type Manager

type Manager interface {
	// Start starts the manager. This in turn starts an internal ticker which
	// periodically triggers the configured workflows to get the telemetry data
	// via the configured providers and to forward that data to consumers.
	Start() error
	// Stop stops the manager the internal loops.
	Stop()
	// AddConsumer adds a consumer of telemetry data provided by configured
	// workflows' providers.
	// AddConsumer(ch chan<- Report) error
	AddConsumer(c Consumer) error
	// AddWorkflow adds a workflow with providers which will provide telemetry data.
	AddWorkflow(Workflow)
	// TriggerExecute triggers an execution of all configured workflows, which will gather
	// all telemetry data, push it downstream to configured serializers and then
	// forward it using the configured forwarders.
	// It will use the provided signal name overriding what's configured in the
	// Manager.
	TriggerExecute(context.Context, types.Signal) error
	// Report executes all workflows and returns an aggregated report from those
	// workflows.
	Report(context.Context) (types.Report, error)
}

Manager controls and runs workflows which provide telemetry data. This telemetry is then send over to consumers. Owners of consumers are responsible that they consume the data in a timely manner.

The reports produced by Manager are maps of workflows names - that produced their respective reports - to those reports. This way reports from independent workflows are enclosed in separate map objects in manager's report.

func NewManager

func NewManager(signal types.Signal, opts ...OptManager) (Manager, error)

NewManager creates a new manager configured via the provided options.

type OptManager

type OptManager func(*manager) error

OptManager is the option function type that can configure the manager.

func OptManagerLogger

func OptManagerLogger(l logr.Logger) OptManager

OptManagerLogger returns an option that will set manager's logger.

func OptManagerPeriod

func OptManagerPeriod(period time.Duration) OptManager

OptManagerPeriod returns an option that will set manager's workflows period.

type RawForwarder

type RawForwarder interface {
	Name() string
	Forward(context.Context, types.SignalReport) error
}

RawForwarder is used to forward raw, unserialized telemetry reports to configured destination(s).

type Serializer

type Serializer interface {
	Serialize(report types.Report, signal types.Signal) ([]byte, error)
}

Serializer serializes telemetry reports into byte slices.

type Workflow

type Workflow interface {
	// Name returns workflow's name.
	Name() string
	// AddProvider adds a provider.
	AddProvider(provider.Provider)
	// Execute executes the workflow.
	Execute(context.Context) (types.ProviderReport, error)
}

Workflow defines the workflow interface which will be used either for manual interaction or in programmed manner in manager.

func NewClusterStateWorkflow

func NewClusterStateWorkflow(d dynamic.Interface, rm meta.RESTMapper) (Workflow, error)

NewClusterStateWorkflow creates a new 'cluster-state' workflow, based on a predefined set of providers that will deliver telemetry data about the cluster state. When a non-builtin CRD (like Gateway from Gateway API) is not available then the provider for this resource's telemetry data is not added to the workflow.

Exemplar report produced:

{
  "k8s_pods_count": 21,
  "k8s_services_count": 3,
  "k8s_nodes_count": 1
  "k8s_gatewayclasses_count": 1,
  "k8s_gateways_count": 1,
  "k8s_httproutes_count": 1,
  "k8s_grpcroutes_count": 1,
  "k8s_tlsroutes_count": 1,
  "k8s_tcproutes_count": 1,
  "k8s_udproutes_count": 1,
  "k8s_referencegrants_count": 1
}

func NewIdentifyPlatformWorkflow

func NewIdentifyPlatformWorkflow(kc kubernetes.Interface) (Workflow, error)

NewIdentifyPlatformWorkflow creates a new 'identify-platform' workflow, based on a predefined set of providers that will deliver telemetry data from a cluster.

Exemplar report produced:

{
  "k8sv": "linux/amd64",
  "k8sv": "v1.24.1-gke.1400",
  "k8sv_semver": "v1.24.1",
  "k8s_provider": "GKE"
  "openshift_version": "4.13.0"
}

func NewMeshDetectWorkflow

func NewMeshDetectWorkflow(cl client.Client, pod, publishService apitypes.NamespacedName) (Workflow, error)

NewMeshDetectWorkflow returns a mesh detection workflow.

Exemplar report produced:

{
	"mdist": "all8,a2,c2",
	"mdep": "a3,c3"
}

func NewStateWorkflow

func NewStateWorkflow() (Workflow, error)

NewStateWorkflow creates a new 'state' workflow, based on a predefined set of providers that will deliver telemetry date about the state of the system.

func NewWorkflow

func NewWorkflow(name string) Workflow

NewWorkflow creates a new empty workflow.

Jump to

Keyboard shortcuts

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