health

package
v0.0.0-...-afd77eb Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2018 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeAllHealthChecksEndpoint

func MakeAllHealthChecksEndpoint(hc HealthChecker) endpoint.Endpoint

MakeAllHealthChecksEndpoint makes an endpoint that does all health checks.

func MakeComponentLoggingMW

func MakeComponentLoggingMW(logger log.Logger) func(HealthChecker) HealthChecker

MakeComponentLoggingMW makes a logging middleware at component level.

func MakeElasticsearchModuleLoggingMW

func MakeElasticsearchModuleLoggingMW(logger log.Logger) func(IElasticsearchHealthChecker) IElasticsearchHealthChecker

MakeElasticsearchModuleLoggingMW makes a logging middleware at module level.

func MakeEndpointCorrelationIDMW

func MakeEndpointCorrelationIDMW(flaki fb.FlakiClient, tracer opentracing.Tracer) endpoint.Middleware

MakeEndpointCorrelationIDMW makes a middleware that adds a correlation ID in the context if there is not already one.

func MakeEndpointLoggingMW

func MakeEndpointLoggingMW(logger log.Logger) endpoint.Middleware

MakeEndpointLoggingMW makes a logging middleware.

func MakeExecElasticsearchHealthCheckEndpoint

func MakeExecElasticsearchHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecElasticsearchHealthCheckEndpoint makes the ElasticsearchHealthCheck endpoint that forces the execution of the health checks.

func MakeExecFlakiHealthCheckEndpoint

func MakeExecFlakiHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecFlakiHealthCheckEndpoint makes the FlakiHealthCheck endpoint that forces the execution of the health checks.

func MakeExecInfluxHealthCheckEndpoint

func MakeExecInfluxHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecInfluxHealthCheckEndpoint makes the InfluxHealthCheck endpoint that forces the execution of the health checks.

func MakeExecJaegerHealthCheckEndpoint

func MakeExecJaegerHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecJaegerHealthCheckEndpoint makes the JaegerHealthCheck endpoint that forces the execution of the health checks.

func MakeExecRedisHealthCheckEndpoint

func MakeExecRedisHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecRedisHealthCheckEndpoint makes the RedisHealthCheck endpoint that forces the execution of the health checks.

func MakeExecSentryHealthCheckEndpoint

func MakeExecSentryHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeExecSentryHealthCheckEndpoint makes the SentryHealthCheck endpoint that forces the execution of the health checks.

func MakeHealthCheckHandler

func MakeHealthCheckHandler(e endpoint.Endpoint) *http_transport.Server

MakeHealthCheckHandler make an HTTP handler for an HealthCheck endpoint.

func MakeReadElasticsearchHealthCheckEndpoint

func MakeReadElasticsearchHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadElasticsearchHealthCheckEndpoint makes the ElasticsearchHealthCheck endpoint that read the last health check status in DB.

func MakeReadFlakiHealthCheckEndpoint

func MakeReadFlakiHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadFlakiHealthCheckEndpoint makes the SentryHealthCheck endpoint that read the last health check status in DB.

func MakeReadInfluxHealthCheckEndpoint

func MakeReadInfluxHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadInfluxHealthCheckEndpoint makes the InfluxHealthCheck endpoint that read the last health check status in DB.

func MakeReadJaegerHealthCheckEndpoint

func MakeReadJaegerHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadJaegerHealthCheckEndpoint makes the JaegerHealthCheck endpoint that read the last health check status in DB.

func MakeReadRedisHealthCheckEndpoint

func MakeReadRedisHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadRedisHealthCheckEndpoint makes the RedisHealthCheck endpoint that read the last health check status in DB.

func MakeReadSentryHealthCheckEndpoint

func MakeReadSentryHealthCheckEndpoint(hc HealthChecker) endpoint.Endpoint

MakeReadSentryHealthCheckEndpoint makes the SentryHealthCheck endpoint that read the last health check status in DB.

Types

type Component

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

Component is the Health component.

func NewComponent

func NewComponent(influx InfluxHealthChecker, jaeger JaegerHealthChecker, redis RedisHealthChecker,
	sentry SentryHealthChecker, flaki FlakiHealthChecker, elasticsearch ElasticsearchHealthChecker,
	storage StoreModule, healthCheckValidity map[string]time.Duration) *Component

NewComponent returns the health component.

func (*Component) AllHealthChecks

func (c *Component) AllHealthChecks(ctx context.Context) json.RawMessage

AllHealthChecks call all component checks and build a general health report.

func (*Component) ExecElasticsearchHealthChecks

func (c *Component) ExecElasticsearchHealthChecks(ctx context.Context) json.RawMessage

ExecElasticsearchHealthChecks executes the health checks for Flaki.

func (*Component) ExecFlakiHealthChecks

func (c *Component) ExecFlakiHealthChecks(ctx context.Context) json.RawMessage

ExecFlakiHealthChecks executes the health checks for Flaki.

func (*Component) ExecInfluxHealthChecks

func (c *Component) ExecInfluxHealthChecks(ctx context.Context) json.RawMessage

ExecInfluxHealthChecks executes the health checks for Influx.

func (*Component) ExecJaegerHealthChecks

func (c *Component) ExecJaegerHealthChecks(ctx context.Context) json.RawMessage

ExecJaegerHealthChecks executes the health checks for Jaeger.

func (*Component) ExecRedisHealthChecks

func (c *Component) ExecRedisHealthChecks(ctx context.Context) json.RawMessage

ExecRedisHealthChecks executes the health checks for Redis.

func (*Component) ExecSentryHealthChecks

func (c *Component) ExecSentryHealthChecks(ctx context.Context) json.RawMessage

ExecSentryHealthChecks executes the health checks for Sentry.

func (*Component) ReadElasticsearchHealthChecks

func (c *Component) ReadElasticsearchHealthChecks(ctx context.Context) json.RawMessage

ReadElasticsearchHealthChecks read the health checks status in DB.

func (*Component) ReadFlakiHealthChecks

func (c *Component) ReadFlakiHealthChecks(ctx context.Context) json.RawMessage

ReadFlakiHealthChecks read the health checks status in DB.

func (*Component) ReadInfluxHealthChecks

func (c *Component) ReadInfluxHealthChecks(ctx context.Context) json.RawMessage

ReadInfluxHealthChecks read the health checks status in DB.

func (*Component) ReadJaegerHealthChecks

func (c *Component) ReadJaegerHealthChecks(ctx context.Context) json.RawMessage

ReadJaegerHealthChecks read the health checks status in DB.

func (*Component) ReadRedisHealthChecks

func (c *Component) ReadRedisHealthChecks(ctx context.Context) json.RawMessage

ReadRedisHealthChecks read the health checks status in DB.

func (*Component) ReadSentryHealthChecks

func (c *Component) ReadSentryHealthChecks(ctx context.Context) json.RawMessage

ReadSentryHealthChecks read the health checks status in DB.

type ElasticsearchClient

type ElasticsearchClient interface {
	ListIndexes() ([]client.IndexRepresentation, error)
	GetIndex(indexName string) (client.IndexSettingsRepresentation, error)
	CreateIndex(indexName string) error
	DeleteIndex(indexName string) error
	Health() (client.HealthRepresentation, error)
}

ElasticsearchClient is the interface of Elasticsearch.

type ElasticsearchHealthChecker

type ElasticsearchHealthChecker interface {
	HealthChecks(context.Context) []ElasticsearchReport
}

ElasticsearchHealthChecker is the interface of the elasticsearch health check module.

type ElasticsearchModule

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

ElasticsearchModule is the health check module for Elasticsearch.

func NewElasticsearchModule

func NewElasticsearchModule(client ElasticsearchClient) *ElasticsearchModule

NewElasticsearchModule returns the Elasticsearch health module.

func (*ElasticsearchModule) HealthChecks

HealthChecks executes all health checks for Flaki.

type ElasticsearchReport

type ElasticsearchReport struct {
	Name     string
	Duration time.Duration
	Status   Status
	Error    error
	Infos    json.RawMessage
}

ElasticsearchReport is the health report returned by the Elasticsearch module.

func (*ElasticsearchReport) MarshalJSON

func (i *ElasticsearchReport) MarshalJSON() ([]byte, error)

type Endpoints

type Endpoints struct {
	InfluxExecHealthCheck        endpoint.Endpoint
	InfluxReadHealthCheck        endpoint.Endpoint
	JaegerExecHealthCheck        endpoint.Endpoint
	JaegerReadHealthCheck        endpoint.Endpoint
	RedisExecHealthCheck         endpoint.Endpoint
	RedisReadHealthCheck         endpoint.Endpoint
	SentryExecHealthCheck        endpoint.Endpoint
	SentryReadHealthCheck        endpoint.Endpoint
	FlakiExecHealthCheck         endpoint.Endpoint
	FlakiReadHealthCheck         endpoint.Endpoint
	ElasticsearchExecHealthCheck endpoint.Endpoint
	ElasticsearchReadHealthCheck endpoint.Endpoint
	AllHealthChecks              endpoint.Endpoint
}

Endpoints wraps a service behind a set of endpoints.

type FlakiHealthChecker

type FlakiHealthChecker interface {
	HealthChecks(context.Context) []common.FlakiReport
}

FlakiHealthChecker is the interface of the flaki health check module.

type HealthChecker

type HealthChecker interface {
	ExecInfluxHealthChecks(context.Context) json.RawMessage
	ReadInfluxHealthChecks(context.Context) json.RawMessage
	ExecJaegerHealthChecks(context.Context) json.RawMessage
	ReadJaegerHealthChecks(context.Context) json.RawMessage
	ExecRedisHealthChecks(context.Context) json.RawMessage
	ReadRedisHealthChecks(context.Context) json.RawMessage
	ExecSentryHealthChecks(context.Context) json.RawMessage
	ReadSentryHealthChecks(context.Context) json.RawMessage
	ExecFlakiHealthChecks(context.Context) json.RawMessage
	ReadFlakiHealthChecks(context.Context) json.RawMessage
	ExecElasticsearchHealthChecks(context.Context) json.RawMessage
	ReadElasticsearchHealthChecks(context.Context) json.RawMessage
	AllHealthChecks(context.Context) json.RawMessage
}

HealthChecker is the health component interface.

type IDGenerator

type IDGenerator interface {
	NextValidID(context.Context) string
}

IDGenerator is the interface of the distributed unique IDs generator.

type IElasticsearchHealthChecker

type IElasticsearchHealthChecker interface {
	HealthChecks(context.Context) []ElasticsearchReport
}

IElasticsearchHealthChecker is the interface of the elasticsearch health check module.

type InfluxHealthChecker

type InfluxHealthChecker interface {
	HealthChecks(context.Context) []common.InfluxReport
}

InfluxHealthChecker is the interface of the influx health check module.

type JaegerHealthChecker

type JaegerHealthChecker interface {
	HealthChecks(context.Context) []common.JaegerReport
}

JaegerHealthChecker is the interface of the jaeger health check module.

type RedisHealthChecker

type RedisHealthChecker interface {
	HealthChecks(context.Context) []common.RedisReport
}

RedisHealthChecker is the interface of the redis health check module.

type SentryHealthChecker

type SentryHealthChecker interface {
	HealthChecks(context.Context) []common.SentryReport
}

SentryHealthChecker is the interface of the sentry health check module.

type Status

type Status int

Status is the status of the health check.

const (
	// OK is the status for a successful health check.
	OK Status = iota
	// KO is the status for an unsuccessful health check.
	KO
	// Degraded is the status for a degraded service, e.g. the service still works, but the metrics DB is KO.
	Degraded
	// Deactivated is the status for a service that is deactivated, e.g. we can disable error tracking, instrumenting, tracing,...
	Deactivated
	// Unknown is the status set when there is unexpected errors, e.g. parsing status from DB.
	Unknown
)

func (Status) String

func (s Status) String() string

type Storage

type Storage interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
}

type StorageModule

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

StorageModule is the module that save health checks results in Storage DB.

func NewStorageModule

func NewStorageModule(componentName, componentID string, db Storage) *StorageModule

NewStorageModule returns the cockroach storage module.

func (*StorageModule) Clean

func (c *StorageModule) Clean() error

Clean deletes the old test reports that are no longer valid from the health DB table.

func (*StorageModule) Read

func (c *StorageModule) Read(unit string) (StoredReport, error)

Read reads the reports in DB.

func (*StorageModule) Update

func (c *StorageModule) Update(unit string, validity time.Duration, jsonReports json.RawMessage) error

Update updates the health checks reports stored in DB with the values 'jsonReports'.

type StoreModule

type StoreModule interface {
	Read(name string) (StoredReport, error)
	Update(unit string, validity time.Duration, reports json.RawMessage) error
}

StoreModule is the interface of the module that stores the health reports in the DB.

type StoredReport

type StoredReport struct {
	ComponentName   string
	ComponentID     string
	HealthcheckUnit string
	Reports         json.RawMessage
	LastUpdated     time.Time
	ValidUntil      time.Time
}

Directories

Path Synopsis
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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