metrics

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CPUParamsMatcher added in v0.2.1

func CPUParamsMatcher(expectedResource string, expectedResolution *float32, expectedAggregation *metricstypes.ApplicationMetricAggregationMethod) interface{}

func HTTPLatencyParamsMatcher added in v0.2.1

func HTTPLatencyParamsMatcher(expectedResource string, expectedQuantile *metricstypes.Quantile, expectedHost *metricstypes.HostQueryParam, expectedPath *metricstypes.PathQueryParam) interface{}

func HTTPRequestsParamsMatcher added in v0.2.1

func HTTPRequestsParamsMatcher(expectedResource string, expectedAggregation *metricstypes.HttpAggregateBy, expectedResolution *float32, expectedHost *metricstypes.HostQueryParam, expectedPath *metricstypes.PathQueryParam) interface{}

func NewMockActiveConnectionsResponse added in v0.2.1

func NewMockActiveConnectionsResponse(value float32) *client.GetActiveConnectionsResponse

func NewMockBandwidthResponse added in v0.2.2

func NewMockBandwidthResponse(value float32) *client.GetBandwidthResponse

func NewMockCPULimitResponse added in v0.2.1

func NewMockCPULimitResponse(value float32) *client.GetCpuLimitResponse

func NewMockCPUResponse added in v0.2.1

func NewMockCPUResponse(value float32) *client.GetCpuResponse

func NewMockCPUTargetResponse added in v0.2.1

func NewMockCPUTargetResponse(value float32) *client.GetCpuTargetResponse

func NewMockErrorResponse added in v0.2.1

func NewMockErrorResponse(statusCode int) *http.Response

func NewMockHTTPLatencyResponse added in v0.2.1

func NewMockHTTPLatencyResponse(value float32, path string) *client.GetHttpLatencyResponse

func NewMockHTTPRequestsResponse added in v0.2.1

func NewMockHTTPRequestsResponse(value float32, statusCode string) *client.GetHttpRequestsResponse

func NewMockInstanceCountResponse added in v0.2.1

func NewMockInstanceCountResponse(value float32) *client.GetInstanceCountResponse

func NewMockMemoryLimitResponse added in v0.2.1

func NewMockMemoryLimitResponse(value float32) *client.GetMemoryLimitResponse

func NewMockMemoryResponse added in v0.2.1

func NewMockMemoryResponse(value float32) *client.GetMemoryResponse

func NewMockMemoryTargetResponse added in v0.2.1

func NewMockMemoryTargetResponse(value float32) *client.GetMemoryTargetResponse

Types

type MetricData

type MetricData struct {
	Type MetricType                        `json:"type"`
	Data metricstypes.TimeSeriesCollection `json:"data"`
}

type MetricType

type MetricType string
const (
	MetricTypeCPUUsage          MetricType = "cpu_usage"
	MetricTypeMemoryUsage       MetricType = "memory_usage"
	MetricTypeHTTPRequestCount  MetricType = "http_request_count"
	MetricTypeActiveConnections MetricType = "active_connections"
	MetricTypeInstanceCount     MetricType = "instance_count"
	MetricTypeHTTPLatency       MetricType = "http_latency"
	MetricTypeCPULimit          MetricType = "cpu_limit"
	MetricTypeCPUTarget         MetricType = "cpu_target"
	MetricTypeMemoryLimit       MetricType = "memory_limit"
	MetricTypeMemoryTarget      MetricType = "memory_target"
	MetricTypeBandwidthUsage    MetricType = "bandwidth_usage"
)

type MetricsClient added in v0.2.1

type MetricsClient interface {
	GetCpuWithResponse(ctx context.Context, params *client.GetCpuParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuResponse, error)
	GetMemoryWithResponse(ctx context.Context, params *client.GetMemoryParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryResponse, error)
	GetHttpRequestsWithResponse(ctx context.Context, params *client.GetHttpRequestsParams, reqEditors ...client.RequestEditorFn) (*client.GetHttpRequestsResponse, error)
	GetHttpLatencyWithResponse(ctx context.Context, params *client.GetHttpLatencyParams, reqEditors ...client.RequestEditorFn) (*client.GetHttpLatencyResponse, error)
	GetActiveConnectionsWithResponse(ctx context.Context, params *client.GetActiveConnectionsParams, reqEditors ...client.RequestEditorFn) (*client.GetActiveConnectionsResponse, error)
	GetInstanceCountWithResponse(ctx context.Context, params *client.GetInstanceCountParams, reqEditors ...client.RequestEditorFn) (*client.GetInstanceCountResponse, error)
	GetCpuLimitWithResponse(ctx context.Context, params *client.GetCpuLimitParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuLimitResponse, error)
	GetCpuTargetWithResponse(ctx context.Context, params *client.GetCpuTargetParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuTargetResponse, error)
	GetMemoryLimitWithResponse(ctx context.Context, params *client.GetMemoryLimitParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryLimitResponse, error)
	GetMemoryTargetWithResponse(ctx context.Context, params *client.GetMemoryTargetParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryTargetResponse, error)
	GetBandwidthWithResponse(ctx context.Context, params *client.GetBandwidthParams, reqEditors ...client.RequestEditorFn) (*client.GetBandwidthResponse, error)
}

MetricsClient interface for dependency injection in testing

type MetricsRequest

type MetricsRequest struct {
	ResourceID                  string
	MetricTypes                 []MetricType
	StartTime                   *client.StartTimeParam
	EndTime                     *client.EndTimeParam
	Resolution                  *float32
	CpuUsageAggregationMethod   *metricstypes.ApplicationMetricAggregationMethod
	AggregateHttpRequestCountBy *metricstypes.HttpAggregateBy
	HttpLatencyQuantile         *metricstypes.Quantile
	HttpPath                    *metricstypes.PathQueryParam
	HttpHost                    *metricstypes.HostQueryParam
}

type MetricsResponse

type MetricsResponse struct {
	ResourceID string `json:"resourceId"`
	TimeRange  struct {
		Start *client.StartTimeParam `json:"start,omitempty"`
		End   *client.EndTimeParam   `json:"end,omitempty"`
	} `json:"timeRange"`
	Metrics []MetricData `json:"metrics"`
}

type MetricsTestSuite added in v0.2.1

type MetricsTestSuite struct {
	suite.Suite
	// contains filtered or unexported fields
}

MetricsTestSuite provides shared setup and utilities for metrics tests

func (*MetricsTestSuite) SetupTest added in v0.2.1

func (s *MetricsTestSuite) SetupTest()

func (*MetricsTestSuite) TearDownTest added in v0.2.1

func (s *MetricsTestSuite) TearDownTest()

type MockClientWithResponses added in v0.2.1

type MockClientWithResponses struct {
	mock.Mock
}

MockClientWithResponses implements MetricsClient interface for testing

func (*MockClientWithResponses) GetActiveConnectionsWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetActiveConnectionsWithResponse(ctx context.Context, params *client.GetActiveConnectionsParams, reqEditors ...client.RequestEditorFn) (*client.GetActiveConnectionsResponse, error)

func (*MockClientWithResponses) GetBandwidthWithResponse added in v0.2.2

func (m *MockClientWithResponses) GetBandwidthWithResponse(ctx context.Context, params *client.GetBandwidthParams, reqEditors ...client.RequestEditorFn) (*client.GetBandwidthResponse, error)

func (*MockClientWithResponses) GetCpuLimitWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetCpuLimitWithResponse(ctx context.Context, params *client.GetCpuLimitParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuLimitResponse, error)

func (*MockClientWithResponses) GetCpuTargetWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetCpuTargetWithResponse(ctx context.Context, params *client.GetCpuTargetParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuTargetResponse, error)

func (*MockClientWithResponses) GetCpuWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetCpuWithResponse(ctx context.Context, params *client.GetCpuParams, reqEditors ...client.RequestEditorFn) (*client.GetCpuResponse, error)

func (*MockClientWithResponses) GetHttpLatencyWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetHttpLatencyWithResponse(ctx context.Context, params *client.GetHttpLatencyParams, reqEditors ...client.RequestEditorFn) (*client.GetHttpLatencyResponse, error)

func (*MockClientWithResponses) GetHttpRequestsWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetHttpRequestsWithResponse(ctx context.Context, params *client.GetHttpRequestsParams, reqEditors ...client.RequestEditorFn) (*client.GetHttpRequestsResponse, error)

func (*MockClientWithResponses) GetInstanceCountWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetInstanceCountWithResponse(ctx context.Context, params *client.GetInstanceCountParams, reqEditors ...client.RequestEditorFn) (*client.GetInstanceCountResponse, error)

func (*MockClientWithResponses) GetMemoryLimitWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetMemoryLimitWithResponse(ctx context.Context, params *client.GetMemoryLimitParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryLimitResponse, error)

func (*MockClientWithResponses) GetMemoryTargetWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetMemoryTargetWithResponse(ctx context.Context, params *client.GetMemoryTargetParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryTargetResponse, error)

func (*MockClientWithResponses) GetMemoryWithResponse added in v0.2.1

func (m *MockClientWithResponses) GetMemoryWithResponse(ctx context.Context, params *client.GetMemoryParams, reqEditors ...client.RequestEditorFn) (*client.GetMemoryResponse, error)

type Repo

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

func NewRepo

func NewRepo(c MetricsClient) *Repo

func (*Repo) GetMetrics

func (r *Repo) GetMetrics(ctx context.Context, req MetricsRequest) (*MetricsResponse, error)

Jump to

Keyboard shortcuts

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