Documentation ¶
Overview ¶
Package observability provides a tracer and a histogram to measure all incoming requests to the system.
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 metrics.Histogram) { start := time.Now() span := tracer.StartSpan("test") time.Sleep(time.Second) span.Finish() metrics.With("module", "service", "method").Observe(time.Since(start).Seconds()) })
Output:
Index ¶
- func ProvideGORMMetrics(appName contract.AppName, env contract.Env) *otgorm.Gauges
- func ProvideHistogramMetrics(appName contract.AppName, env contract.Env) metrics.Histogram
- func ProvideJaegerLogAdapter(l log.Logger) jaeger.Logger
- func ProvideKafkaReaderMetrics(appName contract.AppName, env contract.Env) *otkafka.ReaderStats
- func ProvideKafkaWriterMetrics(appName contract.AppName, env contract.Env) *otkafka.WriterStats
- func ProvideOpentracing(appName contract.AppName, env contract.Env, log jaeger.Logger, ...) (opentracing.Tracer, func(), error)
- func ProvideRedisMetrics(appName contract.AppName, env contract.Env) *otredis.Gauges
- func Providers() di.Deps
- type JaegerLogAdapter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProvideGORMMetrics ¶ added in v0.5.0
ProvideGORMMetrics returns a *otgorm.Gauges that measures the connection info in databases. It is meant to be consumed by the otgorm.Providers.
func ProvideHistogramMetrics ¶
ProvideHistogramMetrics returns a metrics.Histogram that is designed to measure incoming requests to the system. Note it has three labels: "module", "service", "method". If any label is missing, the system will panic.
func ProvideJaegerLogAdapter ¶
ProvideJaegerLogAdapter returns a valid jaeger.Logger.
func ProvideKafkaReaderMetrics ¶ added in v0.6.0
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
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
ProvideRedisMetrics returns a *otredis.Gauges that measures the connection info in redis. It is meant to be consumed by the otredis.Providers.
Types ¶
type JaegerLogAdapter ¶
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