metric

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 40 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller interface {
	internaltypes.Controller
	ServiceStartup(ctx context.Context, options application.ServiceOptions) error
	ServiceShutdown() error
	SetReferenceAdmitter(resource.ReferenceAdmitter)
	SetUIReferenceAdmitter(resource.ReferenceAdmitter)

	// Discovery
	GetProviders() []MetricProviderSummary
	GetProvidersForResource(resourceKey string) []MetricProviderSummary

	// Querying
	Query(ctx context.Context, pluginID, connectionID string, req metric.QueryRequest) (*metric.QueryResponse, error)
	QueryAll(ctx context.Context, connectionID string, req metric.QueryRequest) (map[string]*metric.QueryResponse, error)
	ReadResourceMetrics(ctx context.Context, pluginID string, req metric.QueryRequest) (*metric.QueryResponse, error)

	// Streaming
	Subscribe(ctx context.Context, pluginID, connectionID string, req SubscribeRequest) (string, error)
	Unsubscribe(subscriptionID string) error
	BeginConnectionChange(pluginID, connectionID string) func()

	// Finite metrics share one authority-partitioned coordinator.
	GetResourceMetricsCatalog(context.Context, ResourceMetricsCatalogRequest) (*metric.ResourceMetricsCatalog, error)
	ReadFiniteResourceMetrics(context.Context, MetricsObservationSpec) (*metric.ResourceMetricsResponse, error)
	OpenMetricsObservation(context.Context, OpenMetricsObservationRequest, func(MetricsObservationSnapshot)) (MetricsObservationSnapshot, error)
	AttachMetricsObservation(context.Context, string) error
	CloseMetricsObservation(context.Context, string) error
	RefreshMetricsObservation(context.Context, string) error
	RetireMetricsSession(context.Context)
	SetMetricPreferencesStore(*settingsstore.Store)
	GetMetricViewPreferences(string, string) (MetricViewPreferences, error)
	SaveMetricViewPreferences(string, string, MetricViewPreferences) error
	MetricConfigurationController
}

Controller manages metric providers across all plugins.

func NewController

func NewController(
	logger logging.Logger,
	sp pkgsettings.Provider,
	resourceClient resource.ConnectionReader,
) Controller

type MetricConfigurationController added in v0.31.0

type MetricConfigurationController interface {
	SetMetricStateRoot(*appstate.ScopedRoot)
	SetMetricResourceReader(MetricResourceReader)
	SetResourceIdentityGuard(ResourceIdentityGuard)
	GetMetricBindings(string, string) ([]sdk.MetricBinding, error)
	SaveMetricBinding(context.Context, sdk.MetricBinding) (*sdk.MetricBinding, error)
	DeleteMetricBinding(string, string, string) error
	GetMetricDefinitions() ([]sdk.MetricDefinition, error)
	GetMetricOwnerCatalog(context.Context, string, string) (*sdk.MetricOwnerCatalog, error)
	SaveMetricDefinition(context.Context, string, string, sdk.MetricDefinition) (*sdk.MetricDefinition, error)
	DeleteMetricDefinition(string) error
	GetMetricSourceDefaults() (sdk.MetricSourceDefaults, error)
	SaveMetricSourceDefaults(context.Context, sdk.MetricSourceDefaults) (sdk.MetricSourceDefaults, error)
	GetMetricViewSourceSelection(string, string, string) (sdk.MetricViewSourceSelection, error)
	SaveMetricViewSourceSelection(context.Context, sdk.MetricViewSourceSelection) (sdk.MetricViewSourceSelection, error)
	GetProviderConnections(string) ([]sdk.ProviderConnection, error)
	SaveProviderConnection(string, sdk.ProviderConnectionInput) (*sdk.ProviderConnection, error)
	DeleteProviderConnection(string, string) error
	GetDataSources(string, string) ([]sdk.MetricDataSource, error)
	TestProviderConnection(string, string) (*sdk.MetricValidationResult, error)
	ValidateMetricDefinition(string, string, string, sdk.MetricDefinition) (*sdk.MetricValidationResult, error)
	DiscoverMetricLabels(string, string, string, sdk.MetricDiscoveryRequest) (*sdk.MetricDiscoveryResult, error)
	PreviewMetricDefinition(context.Context, MetricsObservationSpec, sdk.MetricDefinition) (*sdk.ResourceMetricsResponse, error)
}

MetricConfigurationController manages private sources independently of presentation preferences.

type MetricProviderSummary

type MetricProviderSummary struct {
	PluginID            string           `json:"plugin_id"`
	ProviderID          string           `json:"provider_id"`
	Name                string           `json:"name"`
	Icon                string           `json:"icon"`
	Description         string           `json:"description"`
	Handlers            []metric.Handler `json:"handlers"`
	SupportsConnections bool             `json:"supports_connections"`
}

MetricProviderSummary is a lightweight summary of a metric provider, exposed to the frontend.

type MetricResourceReader added in v0.31.0

MetricResourceReader reads only retained owner observations. Paths must be approved against the observed representation's current schema before return. The guard reauthorizes the owner and fences source, schema and member revision.

type MetricViewPreferences added in v0.31.0

type MetricViewPreferences struct {
	Version    int               `json:"version"`
	Revision   uint64            `json:"revision"`
	MetricIDs  []string          `json:"metric_ids"`
	Displays   map[string]string `json:"displays"`
	Layout     string            `json:"layout"`
	TimeMode   string            `json:"time_mode"`
	DurationMs int64             `json:"duration_ms"`
	StartMs    int64             `json:"start_ms"`
	EndMs      int64             `json:"end_ms"`
	Details    map[string]bool   `json:"details"`
}

MetricViewPreferences is profile-durable presentation state shared by owner plugin and resource key, never source credentials or resource authority. Version is 1. Revision is a compare-and-swap token: load, edit, save the loaded revision, then reload. Stale saves return CONFLICT without changing any field. MetricIDs is the ordered visible selection; there is no second order array. Displays maps IDs to auto, value, capacity, gauge, area, line, or sample-bars. Layout is auto, grid, or stack. Capacity requires real owner request/limit data. TimeMode is relative (DurationMs, up to 31 days) or absolute (StartMs < EndMs, epoch milliseconds, at most 31 days). Details and Displays may retain settings for temporarily unselected metrics, bounded to 128 IDs each. Unpersisted defaults (Revision 0) contain no selected metric IDs, auto layout, and relative one hour. Owning views may supply domain defaults only while Revision is 0. A persisted empty selection (Revision > 0) stays empty.

type MetricsObservationSnapshot added in v0.31.0

type MetricsObservationSnapshot struct {
	ClientToken string                       `json:"client_token"`
	Generation  uint64                       `json:"generation"`
	Sequence    uint64                       `json:"sequence"`
	Data        *sdk.ResourceMetricsResponse `json:"data"`
	Catalog     *sdk.ResourceMetricsCatalog  `json:"catalog"`
	Fetching    bool                         `json:"fetching"`
	Error       string                       `json:"error"`
	DomainStart *time.Time                   `json:"domain_start"`
	DomainEnd   *time.Time                   `json:"domain_end"`
	Invalidated bool                         `json:"invalidated"`
}

MetricsObservationSnapshot is immutable publication state. Generation fences reused tokens; Sequence strictly increases within a generation. Data is absent while initially pending, and remains visible while compatible refreshes run. Source timestamps and units are unchanged (CPU cores, memory bytes); missing samples are not zero. Invalidated clears Data on retirement or lost authority. DomainStart/DomainEnd describe the evaluation window that produced Data. Data may cover a subset while Complete is false. Relative observations leave the domain absent until data arrives and retain it during compatible refreshes. Progress frames do not replace a retained complete snapshot; final success replaces it atomically, while operational failures retain it and report Error. Catalog is admitted metadata for the delivered sample lanes, not full metric discovery. Consumers derive units/source identity from this snapshot and use GetResourceMetricsCatalog independently for available metric choices.

type MetricsObservationSpec added in v0.31.0

type MetricsObservationSpec struct {
	OwnerPluginID     string                     `json:"owner_plugin_id"`
	OwnerConnectionID string                     `json:"owner_connection_id"`
	ResourceKey       string                     `json:"resource_key"`
	BindingID         string                     `json:"binding_id"`
	Source            *sdk.MetricSourceRef       `json:"source,omitempty"`
	Targets           []sdk.ResourceMetricTarget `json:"targets"`
	MetricIDs         []string                   `json:"metric_ids"`
	Shape             string                     `json:"shape"`
	DurationMs        int64                      `json:"duration_ms"`
	StartTime         time.Time                  `json:"start_time"`
	EndTime           time.Time                  `json:"end_time"`
	StepMs            int                        `json:"step_ms"`
	IntervalMs        int                        `json:"interval_ms"`
}

MetricsObservationSpec describes a finite, reference-bound interest, not a grant. OwnerPluginID/OwnerConnectionID select an admitted owner. Source selection is independent of resource authority and never grants access to resource data. Shape is current or range. Range uses fixed UTC bounds or positive DurationMs, never both. The host resolves relative bounds anew for each collection. IntervalMs is zero for initial/manual reads, otherwise 1000..3600000 milliseconds. At most 256 targets and 32 metric IDs are accepted. Unsupported selections fail before collection without retrying through another source.

type OpenMetricsObservationRequest added in v0.31.0

type OpenMetricsObservationRequest struct {
	ClientToken string                 `json:"client_token"`
	Spec        MetricsObservationSpec `json:"spec"`
}

OpenMetricsObservationRequest reserves a session-owned correlation token. Use a fresh opaque token (for example a UUID) for each logical observation. Open does not collect: install the event listener, await Open, then Attach.

type Provider added in v0.4.0

type Provider interface {
	GetSupportedResources(ctx *types.PluginContext) (*metric.ProviderInfo, []metric.Handler)
}

Provider exposes common discovery only. Finite queries and genuine legacy query/stream operations are independently negotiated SDK capabilities.

type ResourceIdentityGuard added in v0.31.0

ResourceIdentityGuard pins an observed identity without resource.Get access.

type ResourceMetricsCatalogRequest added in v0.31.0

type ResourceMetricsCatalogRequest struct {
	OwnerPluginID     string               `json:"owner_plugin_id"`
	OwnerConnectionID string               `json:"owner_connection_id"`
	ResourceKey       string               `json:"resource_key"`
	BindingID         string               `json:"binding_id"`
	Source            *sdk.MetricSourceRef `json:"source,omitempty"`
}

ResourceMetricsCatalogRequest selects a source without accepting resource data.

type ServiceWrapper added in v0.4.0

type ServiceWrapper struct {
	Ctrl  Controller
	Realm *invocation.WindowRealm
	// contains filtered or unexported fields
}

ServiceWrapper is an explicit delegation wrapper around metric.Controller. Excluded: OnPluginInit, OnPluginStart, OnPluginStop, OnPluginShutdown,

OnPluginDestroy

func (*ServiceWrapper) AttachMetricsObservation added in v0.31.0

func (s *ServiceWrapper) AttachMetricsObservation(ctx context.Context, token string) (retErr error)

AttachMetricsObservation activates an acknowledged window-owned reservation.

func (*ServiceWrapper) CloseMetricsObservation added in v0.31.0

func (s *ServiceWrapper) CloseMetricsObservation(ctx context.Context, token string) (retErr error)

CloseMetricsObservation is idempotent and covers close-before-registration.

func (*ServiceWrapper) DeleteMetricBinding added in v0.31.0

func (s *ServiceWrapper) DeleteMetricBinding(
	ctx context.Context, ownerPlugin, ownerConnection, id string,
) (retErr error)

func (*ServiceWrapper) DeleteMetricDefinition added in v0.31.0

func (s *ServiceWrapper) DeleteMetricDefinition(ctx context.Context, id string) (retErr error)

func (*ServiceWrapper) DeleteProviderConnection added in v0.31.0

func (s *ServiceWrapper) DeleteProviderConnection(ctx context.Context, plugin, connection string) (retErr error)

func (*ServiceWrapper) DiscoverMetricLabels added in v0.31.0

func (s *ServiceWrapper) DiscoverMetricLabels(
	ctx context.Context, plugin, connection, datasourceUID string, request sdk.MetricDiscoveryRequest,
) (_ *sdk.MetricDiscoveryResult, retErr error)

func (*ServiceWrapper) GetDataSources added in v0.31.0

func (s *ServiceWrapper) GetDataSources(
	ctx context.Context, plugin, connection string,
) (_ []sdk.MetricDataSource, retErr error)

func (*ServiceWrapper) GetMetricBindings added in v0.31.0

func (s *ServiceWrapper) GetMetricBindings(
	ctx context.Context, ownerPlugin, ownerConnection string,
) (_ []sdk.MetricBinding, retErr error)

func (*ServiceWrapper) GetMetricDefinitions added in v0.31.0

func (s *ServiceWrapper) GetMetricDefinitions(ctx context.Context) (_ []sdk.MetricDefinition, retErr error)

func (*ServiceWrapper) GetMetricOwnerCatalog added in v0.31.0

func (s *ServiceWrapper) GetMetricOwnerCatalog(
	ctx context.Context, ownerPlugin, ownerConnection string,
) (_ *sdk.MetricOwnerCatalog, retErr error)

func (*ServiceWrapper) GetMetricSourceDefaults added in v0.31.0

func (s *ServiceWrapper) GetMetricSourceDefaults(ctx context.Context) (_ sdk.MetricSourceDefaults, retErr error)

func (*ServiceWrapper) GetMetricViewPreferences added in v0.31.0

func (s *ServiceWrapper) GetMetricViewPreferences(
	ctx context.Context, plugin, resourceKey string,
) (_ MetricViewPreferences, retErr error)

GetMetricViewPreferences reads profile-durable presentation state. Revision is required when saving; durable store failures are returned, never hidden.

func (*ServiceWrapper) GetMetricViewSourceSelection added in v0.31.0

func (s *ServiceWrapper) GetMetricViewSourceSelection(
	ctx context.Context, ownerPlugin, ownerConnection, resourceKey string,
) (_ sdk.MetricViewSourceSelection, retErr error)

func (*ServiceWrapper) GetProviderConnections added in v0.31.0

func (s *ServiceWrapper) GetProviderConnections(
	ctx context.Context, plugin string,
) (_ []sdk.ProviderConnection, retErr error)

func (*ServiceWrapper) GetProviders added in v0.4.0

func (s *ServiceWrapper) GetProviders() []MetricProviderSummary

func (*ServiceWrapper) GetProvidersForResource added in v0.4.0

func (s *ServiceWrapper) GetProvidersForResource(resourceKey string) []MetricProviderSummary

func (*ServiceWrapper) GetResourceMetricsCatalog added in v0.31.0

func (s *ServiceWrapper) GetResourceMetricsCatalog(
	ctx context.Context, request ResourceMetricsCatalogRequest,
) (_ *sdk.ResourceMetricsCatalog, retErr error)

GetResourceMetricsCatalog resolves the selected source for an authenticated owner.

func (*ServiceWrapper) HasPlugin added in v0.4.0

func (s *ServiceWrapper) HasPlugin(pluginID string) bool

func (*ServiceWrapper) ListPlugins added in v0.4.0

func (s *ServiceWrapper) ListPlugins() ([]string, error)

func (*ServiceWrapper) OpenMetricsObservation added in v0.31.0

func (s *ServiceWrapper) OpenMetricsObservation(
	ctx context.Context, request OpenMetricsObservationRequest,
) (_ MetricsObservationSnapshot, retErr error)

OpenMetricsObservation reserves a window-owned observation without collection. The caller installs metric/observation routing before Open, processes the returned snapshot, then calls Attach. Events are sent only to this Wails window; no application-global metrics payload is broadcast.

func (*ServiceWrapper) PreviewMetricDefinition added in v0.31.0

func (s *ServiceWrapper) PreviewMetricDefinition(
	ctx context.Context, spec MetricsObservationSpec, definition sdk.MetricDefinition,
) (_ *sdk.ResourceMetricsResponse, retErr error)

func (*ServiceWrapper) Query added in v0.4.0

func (s *ServiceWrapper) Query(
	ctx context.Context,
	pluginID, connectionID string,
	encoded string,
) (*metricsdk.QueryResponse, error)

func (*ServiceWrapper) QueryAll added in v0.4.0

func (s *ServiceWrapper) QueryAll(ctx context.Context, connectionID, encoded string) (map[string]*metricsdk.QueryResponse, error)

func (*ServiceWrapper) RefreshMetricsObservation added in v0.31.0

func (s *ServiceWrapper) RefreshMetricsObservation(ctx context.Context, token string) (retErr error)

RefreshMetricsObservation bypasses completed cache, not compatible in-flight work.

func (*ServiceWrapper) SaveMetricBinding added in v0.31.0

func (s *ServiceWrapper) SaveMetricBinding(
	ctx context.Context, binding sdk.MetricBinding,
) (_ *sdk.MetricBinding, retErr error)

func (*ServiceWrapper) SaveMetricDefinition added in v0.31.0

func (s *ServiceWrapper) SaveMetricDefinition(
	ctx context.Context, ownerPlugin, ownerConnection string, definition sdk.MetricDefinition,
) (_ *sdk.MetricDefinition, retErr error)

func (*ServiceWrapper) SaveMetricSourceDefaults added in v0.31.0

func (s *ServiceWrapper) SaveMetricSourceDefaults(
	ctx context.Context, defaults sdk.MetricSourceDefaults,
) (_ sdk.MetricSourceDefaults, retErr error)

func (*ServiceWrapper) SaveMetricViewPreferences added in v0.31.0

func (s *ServiceWrapper) SaveMetricViewPreferences(
	ctx context.Context, plugin, resourceKey string, preferences MetricViewPreferences,
) (retErr error)

SaveMetricViewPreferences requires the loaded Revision. A stale edit returns CONFLICT without overwriting other windows. Reload after a successful save.

func (*ServiceWrapper) SaveMetricViewSourceSelection added in v0.31.0

func (s *ServiceWrapper) SaveMetricViewSourceSelection(
	ctx context.Context, selection sdk.MetricViewSourceSelection,
) (_ sdk.MetricViewSourceSelection, retErr error)

func (*ServiceWrapper) SaveProviderConnection added in v0.31.0

func (s *ServiceWrapper) SaveProviderConnection(
	ctx context.Context, plugin string, input sdk.ProviderConnectionInput,
) (_ *sdk.ProviderConnection, retErr error)

func (*ServiceWrapper) ServiceShutdown added in v0.4.0

func (s *ServiceWrapper) ServiceShutdown() error

func (*ServiceWrapper) ServiceStartup added in v0.4.0

func (s *ServiceWrapper) ServiceStartup(ctx context.Context, options application.ServiceOptions) error

func (*ServiceWrapper) Subscribe added in v0.4.0

func (s *ServiceWrapper) Subscribe(ctx context.Context, pluginID, connectionID, encoded string) (string, error)

func (*ServiceWrapper) TestProviderConnection added in v0.31.0

func (s *ServiceWrapper) TestProviderConnection(
	ctx context.Context, plugin, connection string,
) (_ *sdk.MetricValidationResult, retErr error)

func (*ServiceWrapper) Unsubscribe added in v0.4.0

func (s *ServiceWrapper) Unsubscribe(subscriptionID string) error

func (*ServiceWrapper) ValidateMetricDefinition added in v0.31.0

func (s *ServiceWrapper) ValidateMetricDefinition(
	ctx context.Context, plugin, connection, datasourceUID string, definition sdk.MetricDefinition,
) (_ *sdk.MetricValidationResult, retErr error)

type SubscribeRequest

type SubscribeRequest struct {
	ResourceKey       string                        `json:"resource_key"`
	ResourceID        string                        `json:"resource_id"`
	ResourceNamespace string                        `json:"resource_namespace"`
	ResourceData      *resourcev2.Value             `json:"resource_data,omitempty"`
	Reference         *resourcev2.ResourceReference `json:"reference,omitempty"`
	Route             *resourcev2.AccessRoute       `json:"route,omitempty"`
	MetricIDs         []string                      `json:"metric_ids"`
	Interval          time.Duration                 `json:"interval"`
	Params            map[string]string             `json:"params,omitempty"`
}

SubscribeRequest contains parameters for subscribing to a metric stream.

Jump to

Keyboard shortcuts

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