serviceability

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Metrics names.
	MetricNameErrors                         = "doublezero_monitor_serviceability_errors_total"
	MetricNameProgramBuildInfo               = "doublezero_monitor_serviceability_program_build_info"
	MetricNameUnlinkedInterfaceErrors        = "doublezero_monitor_unlinked_interface_errors_total"
	MetricNameExchangeBGPCommunityDuplicates = "doublezero_monitor_exchange_bgp_community_duplicates"
	MetricNameExchangeBGPCommunityOutOfRange = "doublezero_monitor_exchange_bgp_community_out_of_range"

	// Labels.
	MetricLabelErrorType      = "error_type"
	MetricLabelProgramVersion = "program_version"

	// Error types.
	MetricErrorTypeGetProgramData = "get_program_data"
)

Variables

View Source
var (
	MetricErrors = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: MetricNameErrors,
			Help: "Number of errors encountered",
		},
		[]string{MetricLabelErrorType},
	)

	MetricProgramBuildInfo = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Name: MetricNameProgramBuildInfo,
			Help: "Program build info",
		},
		[]string{MetricLabelProgramVersion},
	)

	MetricUnlinkedInterfaceErrors = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: MetricNameUnlinkedInterfaceErrors,
			Help: "Onchain error when a device interface is unlinked but participating in an activated link",
		},
		[]string{"device_pubkey", "device_code", "interface_name", "link_pubkey"},
	)

	MetricExchangeBGPCommunityDuplicates = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: MetricNameExchangeBGPCommunityDuplicates,
			Help: "Onchain error when exchanges have duplicate BGP community values",
		},
		[]string{"exchange_pubkey", "exchange_code", "bgp_community"},
	)

	MetricExchangeBGPCommunityOutOfRange = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Name: MetricNameExchangeBGPCommunityOutOfRange,
			Help: "Onchain error when exchange BGP community value is outside valid range (10000-10999)",
		},
		[]string{"exchange_pubkey", "exchange_code", "bgp_community"},
	)
)

Functions

func CalculateEpochTimes added in v0.7.2

func CalculateEpochTimes(slotIndex, slotsInEpoch uint64) (currentEpochStartTime, nextEpochTime time.Time)

CalculateEpochTimes calculates the estimated start time of the previous and next epochs.

func Compare added in v0.7.2

func Compare[T any, E ServiceabilityEventer](
	a, b []T,
	getPubKey func(T) string,
	newEvent func(eventType EventType, entity T, diff string) E,
	diff func(T, T) string,
) []E

Compare is a generic that is able to compare two slices of common serviceability types (device, links, etc).

func GenerateSlackTableMessage added in v0.7.2

func GenerateSlackTableMessage(headerText string, tableRows [][]string, columnSettings []ColumnSetting, footerText string) (string, error)

GenerateSlackTableMessage creates a Slack message payload with a header and a table.

Parameters:

  • headerText: The text for the header block.
  • tableRows: A slice of rows, where each row is a slice of strings for the cells. The first row is typically the table header.
  • columnSettings: An optional slice of column setting objects. If nil, default settings are used.
  • footerText: An optional string to display after the table. If empty, it's omitted.

Returns:

  • A JSON string representing the Slack message payload.
  • An error if the payload cannot be marshaled to JSON.

Types

type Block added in v0.7.2

type Block struct {
	Type           string          `json:"type"`
	Text           *TextObject     `json:"text,omitempty"`
	ColumnSettings []ColumnSetting `json:"column_settings,omitempty"`
	Rows           [][]TableCell   `json:"rows,omitempty"`
}

Block represents a generic component in a Slack message's blocks. We use omitempty for fields that are not present in all block types.

type ColumnSetting added in v0.7.2

type ColumnSetting struct {
	IsWrapped bool   `json:"is_wrapped,omitempty"`
	Align     string `json:"align,omitempty"`
}

ColumnSetting defines settings for a table column. https://api.slack.com/reference/block-kit/blocks#table_column_settings

type Config

type Config struct {
	Logger          *slog.Logger
	Serviceability  ServiceabilityClient
	Interval        time.Duration
	SlackWebhookURL string
	InfluxWriter    InfluxWriter
	Env             string
	LedgerRPCClient LedgerRPCClient
	SolanaRPCClient LedgerRPCClient
}

func (*Config) Validate

func (c *Config) Validate() error

type EntityType added in v0.7.2

type EntityType uint8
const (
	EntityTypeUnknown EntityType = iota
	EntityTypeDevice
	EntityTypeLink
	EntityTypeUser
)

func (EntityType) String added in v0.7.2

func (e EntityType) String() string

type EventType added in v0.7.2

type EventType uint8
const (
	EventTypeUnknown EventType = iota
	EventTypeAdded
	EventTypeRemoved
	EventTypeModified
)

func (EventType) String added in v0.7.2

func (e EventType) String() string

type InfluxClient added in v0.7.2

type InfluxClient struct {
}

type InfluxWriter added in v0.7.2

type InfluxWriter interface {
	Errors() <-chan error
	WriteRecord(string)
	Flush()
}

type LedgerRPCClient added in v0.7.2

type LedgerRPCClient interface {
	GetEpochInfo(ctx context.Context, commitment solanarpc.CommitmentType) (*solanarpc.GetEpochInfoResult, error)
}

type ServiceabilityClient

type ServiceabilityClient interface {
	GetProgramData(context.Context) (*serviceability.ProgramData, error)
}

type ServiceabilityDeviceEvent added in v0.7.2

type ServiceabilityDeviceEvent struct {
	Device serviceability.Device
	// contains filtered or unexported fields
}

func CompareDevice added in v0.7.2

func CompareDevice(a, b []serviceability.Device) []ServiceabilityDeviceEvent

func (ServiceabilityDeviceEvent) Diff added in v0.7.2

func (ServiceabilityDeviceEvent) EntityType added in v0.7.2

func (e ServiceabilityDeviceEvent) EntityType() EntityType

func (ServiceabilityDeviceEvent) Id added in v0.7.2

func (ServiceabilityDeviceEvent) PubKey added in v0.7.2

func (e ServiceabilityDeviceEvent) PubKey() string

func (ServiceabilityDeviceEvent) Type added in v0.7.2

type ServiceabilityEventer added in v0.7.2

type ServiceabilityEventer interface {
	Diff() string
	Id() string
	PubKey() string
	Type() EventType
	EntityType() EntityType
}

type ServiceabilityLinkEvent added in v0.7.2

type ServiceabilityLinkEvent struct {
	Link serviceability.Link
	// contains filtered or unexported fields
}
func CompareLink(a, b []serviceability.Link) []ServiceabilityLinkEvent

func (ServiceabilityLinkEvent) Diff added in v0.7.2

func (ServiceabilityLinkEvent) EntityType added in v0.7.2

func (e ServiceabilityLinkEvent) EntityType() EntityType

func (ServiceabilityLinkEvent) Id added in v0.7.2

func (ServiceabilityLinkEvent) PubKey added in v0.7.2

func (e ServiceabilityLinkEvent) PubKey() string

func (ServiceabilityLinkEvent) Type added in v0.7.2

type ServiceabilityUserEvent added in v0.7.2

type ServiceabilityUserEvent struct {
	User serviceability.User
	// contains filtered or unexported fields
}

func CompareUser added in v0.7.2

func CompareUser(a, b []serviceability.User) []ServiceabilityUserEvent

func (ServiceabilityUserEvent) Diff added in v0.7.2

func (ServiceabilityUserEvent) EntityType added in v0.7.2

func (e ServiceabilityUserEvent) EntityType() EntityType

func (ServiceabilityUserEvent) Id added in v0.7.2

func (ServiceabilityUserEvent) PubKey added in v0.7.2

func (e ServiceabilityUserEvent) PubKey() string

func (ServiceabilityUserEvent) Type added in v0.7.2

type ServiceabilityWatcher

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

func NewServiceabilityWatcher

func NewServiceabilityWatcher(cfg *Config) (*ServiceabilityWatcher, error)

func (*ServiceabilityWatcher) Name

func (w *ServiceabilityWatcher) Name() string

func (*ServiceabilityWatcher) Run

func (*ServiceabilityWatcher) Tick

type SlackMessage added in v0.7.2

type SlackMessage struct {
	Blocks []Block `json:"blocks"`
}

SlackMessage is the top-level structure for a Slack message payload.

type TableCell added in v0.7.2

type TableCell struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

TableCell represents a cell in a Slack table.

type TextObject added in v0.7.2

type TextObject struct {
	Type  string `json:"type"`
	Text  string `json:"text"`
	Emoji bool   `json:"emoji,omitempty"`
}

TextObject represents a Slack text object. https://api.slack.com/reference/block-kit/composition-objects#text

Jump to

Keyboard shortcuts

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