observability

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package observability provides a tracer and a set of perdefined metrics to measure critical system stats.

Introduction

Observability is crucial to the stability of the system. The three pillars of the observabilities consist of logging, tracing and metrics. Since logging is provided in Package logging, this package mainly focus on tracing and metrics.

Integration

Add the observabilities to core:

var c *core.C = core.New()
c.provide(observability.Providers())

See example for usage.

Example
c := core.New()
c.ProvideEssentials()
c.Provide(observability.Providers())
c.Invoke(func(tracer opentracing.Tracer, metrics *srvhttp.RequestDurationSeconds) {
	start := time.Now()
	span := tracer.StartSpan("test")
	time.Sleep(time.Second)
	span.Finish()
	metrics.
		Module("module").
		Service("service").
		Route("route").
		Observe(time.Since(start))
})
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvideCronJobMetrics added in v0.11.0

func ProvideCronJobMetrics(in MetricsIn) *cron.CronJobMetrics

ProvideCronJobMetrics returns a *cron.CronJobMetrics that is designed to measure cron job metrics. The returned metrics can be used like this:

 metrics := cron.NewCronJobMetrics(...)
 job := cron.NewChain(
 	cron.Recover(logger),
 	cron.Measure(metrics),
	).Then(job)

func ProvideGORMMetrics added in v0.5.0

func ProvideGORMMetrics(in MetricsIn) *otgorm.Gauges

ProvideGORMMetrics returns a *otgorm.Gauges that measures the connection info in databases. It is meant to be consumed by the otgorm.Providers.

func ProvideGRPCRequestDurationSeconds added in v0.9.0

func ProvideGRPCRequestDurationSeconds(in MetricsIn) *srvgrpc.RequestDurationSeconds

ProvideGRPCRequestDurationSeconds returns a *srvgrpc.RequestDurationSeconds that is designed to measure incoming GRPC requests to the system. Note it has three labels: "module", "service", "route".

func ProvideHTTPRequestDurationSeconds added in v0.9.0

func ProvideHTTPRequestDurationSeconds(in MetricsIn) *srvhttp.RequestDurationSeconds

ProvideHTTPRequestDurationSeconds returns a *srvhttp.RequestDurationSeconds that is designed to measure incoming HTTP requests to the system. Note it has three labels: "module", "service", "route".

func ProvideJaegerLogAdapter

func ProvideJaegerLogAdapter(l log.Logger) jaeger.Logger

ProvideJaegerLogAdapter returns a valid jaeger.Logger.

func ProvideKafkaReaderMetrics added in v0.6.0

func ProvideKafkaReaderMetrics(in MetricsIn) *otkafka.ReaderStats

ProvideKafkaReaderMetrics returns a *otkafka.ReaderStats that measures the reader info in kafka. It is meant to be consumed by the otkafka.Providers.

func ProvideKafkaWriterMetrics added in v0.6.0

func ProvideKafkaWriterMetrics(in MetricsIn) *otkafka.WriterStats

ProvideKafkaWriterMetrics returns a *otkafka.WriterStats that measures the writer info in kafka. It is meant to be consumed by the otkafka.Providers.

func ProvideOpentracing

func ProvideOpentracing(
	appName contract.AppName,
	env contract.Env,
	log jaeger.Logger,
	conf contract.ConfigAccessor,
) (opentracing.Tracer, func(), error)

ProvideOpentracing provides a opentracing.Tracer.

func ProvideRedisMetrics added in v0.5.0

func ProvideRedisMetrics(in MetricsIn) *otredis.Gauges

ProvideRedisMetrics returns a RedisMetrics that measures the connection info in redis. It is meant to be consumed by the otredis.Providers.

func Providers added in v0.2.0

func Providers() di.Deps

Providers returns a set of providers available in package observability

Depends On:
	log.Logger
	contract.ConfigAccessor
	contract.AppName
	contract.Env
Provides:
	opentracing.Tracer
	*srvhttp.RequestDurationSeconds

Types

type JaegerLogAdapter

type JaegerLogAdapter struct {
	Logging log.Logger
}

JaegerLogAdapter is an adapter that bridges kitlog and Jaeger.

func (JaegerLogAdapter) Error

func (l JaegerLogAdapter) Error(msg string)

Error implements jaeger's logger

func (JaegerLogAdapter) Infof

func (l JaegerLogAdapter) Infof(msg string, args ...interface{})

Infof implements jaeger's logger

type MetricsIn added in v0.9.0

type MetricsIn struct {
	di.In

	Registerer stdprometheus.Registerer `optional:"true"`
}

MetricsIn is the injection parameter of most metrics constructors in the observability package.

Jump to

Keyboard shortcuts

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