observability

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OTLP_HTTP_MODE = "otlp/http" // HTTP mode for OTLP communication
	OTLP_GRPC_MODE = "otlp/grpc" // gRPC mode for OTLP communication
	CONSOLE_MODE   = "console"   // Console mode, possibly for debugging
)

OTLP communication modes

Variables

This section is empty.

Functions

func InitMeterProvider

func InitMeterProvider(config config.Config) (*sdkmetric.MeterProvider, error)

InitMeterProvider initializes and returns an OpenTelemetry MeterProvider based on the provided configuration. The function sets up a metric exporter based on the observability mode specified in the configuration and creates a MeterProvider with the specified interval for exporting metrics.

Parameters: - config: Configuration containing observability mode and application details.

Returns: - A pointer to an OpenTelemetry MeterProvider. - An error if any occurs during initialization or setting up the provider.

func InitTracerProvider

func InitTracerProvider(config config.Config) (*sdktrace.TracerProvider, error)

initializeTracerProvider initializes and configures a tracer provider based on the observability mode from the configuration. It supports OTLP gRPC, OTLP HTTP, and stdout (default) exporters for trace data. Returns a tracer provider instance or an error if initialization fails.

Types

type Logger

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

Logger: A utility structure containing both a standard Go logger and a zerolog logger. It also provides methods to retrieve each logger instance and to set the log level dynamically.

func NewZeroLog

func NewZeroLog(ctx context.Context, c ...io.Writer) *Logger

NewZeroLog: Creates a new logger with tracing information extracted from the provided context.

func NewZeroLogHook

func NewZeroLogHook() *Logger

NewZeroLogHook: Creates a new logger with a zerolog hook for tracing.

func (*Logger) Level

func (x *Logger) Level(level string) *Logger

Level: Sets the log level for the zerolog logger and updates the standard logger accordingly.

func (*Logger) S

func (x *Logger) S() *log.Logger

S: Returns the standard Go logger from the Logger structure.

func (*Logger) Z

func (x *Logger) Z() *zerolog.Logger

Z: Returns the zerolog logger from the Logger structure.

type TracingHook

type TracingHook struct{}

TracingHook: Custom hook for zerolog that extracts tracing information from the context and adds it to the log entry.

func (TracingHook) Run

func (h TracingHook) Run(e *zerolog.Event, level zerolog.Level, msg string)

Run: Implements the Run method of the zerolog.Hook interface to customize log events with tracing information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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