opamp

package
v1.65.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package opamp contains configurations and protocol implementations to handle OpAmp communication.

Package opamp contains configurations and protocol implementations to handle OpAmp communication.

Index

Constants

View Source
const (
	// YAMLContentType content type for .yml or .yaml file
	YAMLContentType = "text/yaml"

	// JSONContentType content type for .json file
	JSONContentType = "text/json"
)

Variables

View Source
var EmptyAgentID = AgentID{}

EmptyAgentID represents an empty/unset agent ID.

Functions

func ComputeHash

func ComputeHash(data []byte) []byte

ComputeHash computes a sha256 hash of the passed in data

func DetermineContentType

func DetermineContentType(filePath string) string

DetermineContentType looks at the file extension for the given filepath and returns the content type

func NoopReloadFunc

func NoopReloadFunc([]byte) (bool, error)

NoopReloadFunc used as a noop reload function if unsure of how to reload

func StringKeyValue

func StringKeyValue(key, value string) *protobufs.KeyValue

StringKeyValue converts a string key-value pair into a protobuf.KeyValue struct

func Version

func Version() string

Version returns the internally set OpAMP version

Types

type AgentID added in v1.63.0

type AgentID struct {
	// contains filtered or unexported fields
}

AgentID represents the ID of the agent

func AgentIDFromUUID added in v1.63.0

func AgentIDFromUUID(u uuid.UUID) AgentID

AgentIDFromUUID creates an agent ID from a generated UUID. See ParseAgentID for parsing a UUID string.

func ParseAgentID added in v1.63.0

func ParseAgentID(s string) (AgentID, error)

ParseAgentID parses an agent ID from the given string

func (*AgentID) MarshalText added in v1.64.0

func (a *AgentID) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (AgentID) MarshalYAML added in v1.63.0

func (a AgentID) MarshalYAML() (any, error)

MarshalYAML implements the yaml.Marshaler interface

func (AgentID) OpAMPInstanceUID added in v1.63.0

func (a AgentID) OpAMPInstanceUID() types.InstanceUid

OpAMPInstanceUID returns the opamp representation of the agent ID

func (AgentID) String added in v1.63.0

func (a AgentID) String() string

String returns a string representation of the agent ID

func (AgentID) Type added in v1.63.0

func (a AgentID) Type() string

Type returns the string type of the agent ID (ULID, UUID) as it should be reported to BindPlane.

func (*AgentID) UnmarshalText added in v1.64.0

func (a *AgentID) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface

func (*AgentID) UnmarshalYAML added in v1.63.0

func (a *AgentID) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface

type Client

type Client interface {

	// Connect initiates a connection to the OpAmp server based on the supplied configuration
	Connect(ctx context.Context) error

	// Disconnect disconnects from the server
	Disconnect(ctx context.Context) error
}

Client implements a connection with OpAmp enabled server

type Config

type Config struct {
	Endpoint  string     `yaml:"endpoint" mapstructure:"endpoint"`
	SecretKey *string    `yaml:"secret_key,omitempty" mapstructure:"secret_key,omitempty"`
	AgentID   AgentID    `yaml:"agent_id" mapstructure:"agent_id"`
	TLS       *TLSConfig `yaml:"tls_config,omitempty" mapstructure:"tls_config,omitempty"`

	// Updatable fields
	Labels                      *string           `yaml:"labels,omitempty" mapstructure:"labels,omitempty"`
	AgentName                   *string           `yaml:"agent_name,omitempty" mapstructure:"agent_name,omitempty"`
	MeasurementsInterval        time.Duration     `yaml:"measurements_interval,omitempty" mapstructure:"measurements_interval,omitempty"`
	ExtraMeasurementsAttributes map[string]string `yaml:"extra_measurements_attributes,omitempty" mapstructure:"extra_measurements_attributes,omitempty"`
}

Config contains the configuration for the collector to communicate with an OpAmp enabled platform.

func ParseConfig

func ParseConfig(configLocation string) (*Config, error)

ParseConfig given a configuration file location will parse the config

func (Config) CmpUpdatableFields

func (c Config) CmpUpdatableFields(o Config) (equal bool)

CmpUpdatableFields compares updatable fields for equality

func (Config) Copy

func (c Config) Copy() *Config

Copy creates a deep copy of this config

func (Config) GetSecretKey

func (c Config) GetSecretKey() string

GetSecretKey returns secret key if set else returns empty string

func (Config) ToTLS

func (c Config) ToTLS(caCertPool *x509.CertPool) (*tls.Config, error)

ToTLS converts the config to a tls.Config

type ConfigManager

type ConfigManager interface {
	// AddConfig adds a config to be tracked by the config manager with it's corresponding validator function.
	AddConfig(configName string, reloader *ManagedConfig)

	// ComposeEffectiveConfig reads in all config files and calculates the effective config
	ComposeEffectiveConfig() (*protobufs.EffectiveConfig, error)

	// ApplyConfigChanges compares the remoteConfig to the existing and applies changes.
	// Calculates new effective config
	ApplyConfigChanges(remoteConfig *protobufs.AgentRemoteConfig) (changed bool, err error)
}

ConfigManager handles remote configuration of local configs

type DownloadableFileManager

type DownloadableFileManager interface {
	// FetchAndExtractArchive fetches the archive at the specified URL.
	// It then checks to see if it matches the expected sha256 sum of the file.
	// If it matches, the archive is extracted.
	// If the archive cannot be extracted, downloaded, or verified, then an error is returned.
	FetchAndExtractArchive(*protobufs.DownloadableFile) error
	// CleanupArtifacts removes temporary artifacts from previous download/installs
	CleanupArtifacts()
}

DownloadableFileManager handles DownloadableFile's from a PackagesAvailable message

type ManagedConfig

type ManagedConfig struct {
	// ConfigPath is the path on disk where the configuration lives
	ConfigPath string

	// Reload will be called when any changes to this config occur.
	Reload ReloadFunc
	// contains filtered or unexported fields
}

ManagedConfig is a structure that can manage an on disk config file

func NewManagedConfig

func NewManagedConfig(configPath string, reload ReloadFunc, required bool) (*ManagedConfig, error)

NewManagedConfig creates a new Managed config and computes its hash

func (*ManagedConfig) ComputeConfigHash

func (m *ManagedConfig) ComputeConfigHash() error

ComputeConfigHash reads in the config file, computes the hash for the contents, and saves it on the ManagedConfig.

func (*ManagedConfig) GetCurrentConfigHash

func (m *ManagedConfig) GetCurrentConfigHash() []byte

GetCurrentConfigHash retrieves the current config hash

type ReloadFunc

type ReloadFunc func([]byte) (changed bool, err error)

ReloadFunc is a function that handles reloading a config given the new contents Reload function should return true for changed is the in memory or on disk copy of the config was changed in any way. If neither was altered the changed return value should be false.

type TLSConfig

type TLSConfig struct {
	InsecureSkipVerify bool    `yaml:"insecure_skip_verify" mapstructure:"insecure_skip_verify"`
	KeyFile            *string `yaml:"key_file" mapstructure:"key_file"`
	CertFile           *string `yaml:"cert_file" mapstructure:"cert_file"`
	CAFile             *string `yaml:"ca_file" mapstructure:"ca_file"`
}

TLSConfig represents the TLS config to connect to OpAmp server

Directories

Path Synopsis
Package observiq contains OpAmp structures compatible with the observiq client
Package observiq contains OpAmp structures compatible with the observiq client

Jump to

Keyboard shortcuts

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