tm

package
v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: LGPL-3.0 Imports: 21 Imported by: 4

Documentation

Overview

Package tm enables (or not) Open Telemetry at the package level.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enabled

func Enabled() bool

Enabled indicates that Open Telemetry global provider is enabled at the package level.

func MapVerboseLevel

func MapVerboseLevel(l VerboseLevel) logrus.Level

MapVerboseLevel maps a verbose level to a given logrus.Level

func MapVerboseLevelList

func MapVerboseLevelList(l VerboseLevel) []logrus.Level

MapVerboseLevelLiss maps a verbose level to a given list of logrus.Level that should be enabled.

func NewLogger

func NewLogger(domain string) *logrus.Entry

NewLogger returns a *logrus.Entry associated with a domain.

func SetUpLocal

func SetUpLocal(l VerboseLevel)

Sets up the package to only log locally at a given level. Open Telemetry global provider will not be enabled. You should call this at the very beginning of your program, before instantiating any log.

func SetUpTelemetry

func SetUpTelemetry(args OtelProviderArgs)

Sets up the package telemetry to use a given OpenTelemetry Endpoint. You should call this at the very beginning of your program, before instantiating any log.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown shutdowns the telemetry package. It is always safe to call it even if the Open Telemetry was not previously enabled at the package level. In this case, it will do nothing.

Types

type OtelProviderArgs

type OtelProviderArgs struct {
	// The Collector URL
	CollectorURL string
	// The Service Name
	ServiceName string
	// Its deployed version
	ServiceVersion string
	// Its verbose level for logs
	Level VerboseLevel
	// Force a Flush before Shutdown
	ForceFlushOnShutdown bool
}

Arguments needed for Open Telemetry

type Provider

type Provider interface {
	// Shutdown the telemetry engine
	Shutdown(context.Context) error
	// Creates a new logger associated with domain.
	NewLogger(domain string) *logrus.Entry
	// Indicates if telemetry is enabled. If not, do not
	// instrumentalize thrid party libs.
	Enabled() bool
}

A Provider provides Logger in regards to a given telemetry scheme

type VerboseLevel

type VerboseLevel int

Indicate the wanted verbose level for logs

Jump to

Keyboard shortcuts

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