telemetry

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package telemetry provides functionality for telemetry logging.

Package telemetry provides functionality for telemetry logging.

Package telemetry provides functionality for telemetry logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadEnv

func LoadEnv(v interface{}) (err error)

LoadEnv is a function that loads environment variables from a .env file into a given struct. It uses the "env" tag in the struct to match the environment variables. If the .env file cannot be loaded or the environment variables cannot be parsed, it returns an error.

Types

type Fields added in v1.0.1

type Fields map[string]interface{}

type Lib

type Lib struct {
	Level    string `env:"TELEMETRY_LOG_LEVEL" envDefault:"debug" json:"level"`
	Host     string `env:"TELEMETRY_HOST" envDefault:"127.0.0.1" json:"host"`
	Port     string `env:"TELEMETRY_PORT" envDefault:"27017" json:"port"`
	Username string `env:"TELEMETRY_USERNAME" envDefault:"username" json:"username"`
	Password string `env:"TELEMETRY_PASSWORD" envDefault:"password" json:"password"`

	Log log.Logger
	// contains filtered or unexported fields
}

Lib is a struct that holds the necessary information for telemetry logging.

func New

func New(opts ...OptFunc) (li *Lib, err error)

New is a function that creates a new Lib instance. It applies the provided options to the Lib instance and then attempts to initialize the environment and command.

type MongoHook

type MongoHook struct {
	Client   *mongo.Mongo  // Client is a pointer to a Mongo instance.
	Timeout  time.Duration // Timeout is the duration before the hook times out.
	WithHook bool          // WithHook is a boolean that determines whether the hook is active.
}

MongoHook is a struct that holds the necessary information for a MongoDB hook.

func (*MongoHook) Fire

func (m *MongoHook) Fire(e *logrus.Entry) error

Fire is a method that logs an entry to a MongoDB collection. If the entry level is "error" and the hook is active, it logs the entry to the "application_trace" collection. Otherwise, it logs a sample entry to the "application_log" collection.

func (*MongoHook) Levels

func (m *MongoHook) Levels() []logrus.Level

Levels is a method that returns all logrus levels.

type OptFunc

type OptFunc func(*Lib) error

OptFunc is a type that defines a function that modifies a Lib instance.

func WithHook

func WithHook(status bool) OptFunc

WithHook is a function that returns an OptFunc which sets the hook for a Lib instance.

func WithJSONFormatter

func WithJSONFormatter() OptFunc

WithJSONFormatter is a function that returns an OptFunc which sets the JSON formatter for a Lib instance.

Directories

Path Synopsis
Package log provides an interface and functions for logging.
Package log provides an interface and functions for logging.
Package mongo provides a wrapper around the mongo-driver package, simplifying the process of connecting to a MongoDB instance and performing operations on it.
Package mongo provides a wrapper around the mongo-driver package, simplifying the process of connecting to a MongoDB instance and performing operations on it.

Jump to

Keyboard shortcuts

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