hcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package hcp handles the low level initialization and execution of the HCP client

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a TelemetryClient that lazily retrieves configuration from HCP. TelemtryConfiguration can be loaded on-demand using the ReloadConfig() function.

func New

func New(p *Params) (*Client, error)

New creates a new telemetry client for the provided resource using the credentials.

func (*Client) MetricAttributes

func (c *Client) MetricAttributes() (map[string]string, error)

MetricAttributes returns the labels we were told to include from the TelemetryConfig.

func (*Client) MetricFilters

func (c *Client) MetricFilters() ([]string, error)

MetricFilters returns the metric inclusion filters from the TelemetryConfig.

func (*Client) MetricsEndpoint

func (c *Client) MetricsEndpoint() (string, error)

MetricsEndpoint returns the metrics endpoint from the TelemetryConfig.

func (*Client) ReloadConfig

func (c *Client) ReloadConfig() error

ReloadConfig will retrieve the telemetry configuration from HCP using the initially configured runtime.

type ClientService

ClientService is a paired down interface for the global-network-manager-service that retrieves the AgentTelemetryConfig. Allows mocking.

type MockClient

type MockClient struct {
	MockMetricsEndpoint  string
	MockMetricFilters    []string
	MockMetricAttributes map[string]string
	Err                  error
}

MockClient fulfills the TelemetryClient interface and returns static values. Used for testing.

func (*MockClient) MetricAttributes

func (m *MockClient) MetricAttributes() (map[string]string, error)

MetricAttributes returns the provided metric inclusion filters. Will never error.

func (*MockClient) MetricFilters

func (m *MockClient) MetricFilters() ([]string, error)

MetricFilters returns the provided metric inclusion filters. Will never error.

func (*MockClient) MetricsEndpoint

func (m *MockClient) MetricsEndpoint() (string, error)

MetricsEndpoint returns the provided metrics endpoint. Will never error.

type MockClientService

type MockClientService struct {
	MockResponse *consul_telemetry_service.AgentTelemetryConfigOK
	Err          error
	// contains filtered or unexported fields
}

MockClientService fulfills the TelemetryClient interface and returns static values. Used for testing.

func (*MockClientService) AgentTelemetryConfig

AgentTelemetryConfig returns mocked responses.

type Params

type Params struct {
	ClientID, ClientSecret, ResourceURL string
}

Params is structure used to hold parameters to generate a new client.

type TelemetryClient

type TelemetryClient interface {
	MetricsEndpoint() (string, error)
	MetricFilters() ([]string, error)
	MetricAttributes() (map[string]string, error)
}

TelemetryClient is a high level client for the AgentTelemetryConfig. It abstracts the interaction with HCP to retrieve the AgentTelemetryConfig.

Jump to

Keyboard shortcuts

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