observability

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: MIT Imports: 16 Imported by: 0

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.Provide)

See example for usage.

Example
c := core.New()
c.ProvideEssentials()
c.Provide(observability.Provide)
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())
})

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ProvideHistogramMetrics

func ProvideHistogramMetrics(appName contract.AppName, env contract.Env) metrics.Histogram

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

func ProvideJaegerLogAdapter(l log.Logger) jaeger.Logger

ProvideJaegerLogAdapter returns a valid jaeger.Logger.

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.

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 ObservabilityIn

type ObservabilityIn struct {
	dig.In

	Logger  log.Logger
	Conf    contract.ConfigAccessor
	AppName contract.AppName
	Env     contract.Env
}

ObservabilityIn is the injection argument of Provide.

type ObservabilityOut

type ObservabilityOut struct {
	dig.Out

	Tracer         opentracing.Tracer
	Hist           metrics.Histogram
	ExportedConfig []config.ExportedConfig `group:"config,flatten"`
}

ObservabilityOut is the result of Provide

func Provide

func Provide(in ObservabilityIn) (ObservabilityOut, func(), error)

Provide provides the observability suite for the system. It contains a tracer and a histogram to measure all incoming request.

Jump to

Keyboard shortcuts

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