Documentation
¶
Index ¶
- Constants
- type GlobalCtrlRuntimeMetricsRecorder
- func (r *GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationFailure(serverURL string, operationType KonnectEntityOperation, entityType string, ...)
- func (r *GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationSuccess(serverURL string, operationType KonnectEntityOperation, entityType string, ...)
- type KonnectEntityOperation
- type MockRecorder
- type Recorder
Constants ¶
const ( // KonnectServerURLKey is the key for the Konnect server URL which accepts the requests of entity opertions. KonnectServerURLKey = "server_url" // KonnectEntityOperationTypeKey is the key for the opertion type: `create`, `update`, or `delete`. KonnectEntityOperationTypeKey = "operation_type" KonnectEntityOperationCreate KonnectEntityOperation = "create" KonnectEntityOperationUpdate KonnectEntityOperation = "update" KonnectEntityOperationDelete KonnectEntityOperation = "delete" // KonnectEntityTypeKey indicates the type of the operated Konnect entity. KonnectEntityTypeKey = "entity_type" // SuccessKey indicates whether the operation is successfully done. SuccessKey = "success" // SuccessTrue means that the opertion succeeded. SuccessTrue = "true" // SuccessFalse means that the operation failed. SuccessFalse = "false" // StatusCodeKey is the HTTP status code in the response from the Konnect server for the entity opertion. // It is always `0` for successful operations. // When the opertion fails, it will be the actual status code if we can get it. Otherwise it will also be `0`. StatusCodeKey = "status_code" )
const ( // MetricNameKonnectEntityOperationCount is the metric of number of operations, grouped by server URL, entity type, successful status and status code. MetricNameKonnectEntityOperationCount = "gateway_operator_konnect_entity_operation_count" // MetricNameKonnectEntityOperationDuration is the metric of durations of the operations. MetricNameKonnectEntityOperationDuration = "gateway_operator_konnect_entity_operation_duration_milliseconds" )
metric names for konnect entity operations.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GlobalCtrlRuntimeMetricsRecorder ¶
type GlobalCtrlRuntimeMetricsRecorder struct{}
GlobalCtrlRuntimeMetricsRecorder is a metrics recorder that uses a global Prometheus registry provided by the controller-runtime. Any instance of it will record metrics to the same registry.
We want to expose Gateway operator's custom metrics on the same endpoint as controller-runtime's built-in ones. Because of that, we have to use its global registry as CR doesn't allow injecting a custom one. Upstream issue regarding this: https://github.com/kubernetes-sigs/controller-runtime/issues/210.
func NewGlobalCtrlRuntimeMetricsRecorder ¶
func NewGlobalCtrlRuntimeMetricsRecorder() *GlobalCtrlRuntimeMetricsRecorder
func (*GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationFailure ¶
func (r *GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationFailure( serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration, statusCode int, )
RecordKonnectEntityOperationFailure is called when an entity operation fails.
func (*GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationSuccess ¶
func (r *GlobalCtrlRuntimeMetricsRecorder) RecordKonnectEntityOperationSuccess( serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration, )
RecordKonnectEntityOperationSuccess is called when an entity opertion is successfully done.
type KonnectEntityOperation ¶
type KonnectEntityOperation string
KonnectEntityOperation specifies the type of Konnect entity operation, including `create`, `update`, and `delete`.
type MockRecorder ¶
type MockRecorder struct{}
MockRecorder records operations for testing purposes.
TODO: move all the mocks to a place inside `/test`: https://github.com/Kong/gateway-operator/issues/955
func (*MockRecorder) RecordKonnectEntityOperationFailure ¶
func (m *MockRecorder) RecordKonnectEntityOperationFailure( serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration, statusCode int)
func (*MockRecorder) RecordKonnectEntityOperationSuccess ¶
func (m *MockRecorder) RecordKonnectEntityOperationSuccess( serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration)
type Recorder ¶
type Recorder interface { RecordKonnectEntityOperationSuccess(serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration) RecordKonnectEntityOperationFailure(serverURL string, operationType KonnectEntityOperation, entityType string, duration time.Duration, statusCode int) }
Recorder is the interface for recording metrics for provided operation.