goapm package - github.com/hedon954/goapm - Go Packages

goapm

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 14 Imported by: 3

README

goapm

Go Report Card codecov CI GitHub release (latest SemVer) Go Reference

goapm is a toolkit for monitoring and observability of golang applications. It provides a set of libraries that are wrapped around opentelemetry.

Example

Features

  • Components support opentelemetry
    • sql.DB
    • gorm.DB
    • RedisV6
    • RedisV9
    • HTTP
    • Gin
    • GRPC Server
    • GRPC Client
  • Metrics
  • AutoPProf
  • APM
  • RotateLog

Architecture

architecture

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Infra

type Infra struct {
	// Tracer is the tracer for the infra,
	Tracer trace.Tracer
	Name   string
	// contains filtered or unexported fields
}

Infra is an infrastructure manager for goapm. It is recommended to create a single instance of Infra and share it across the application.

func NewInfra

func NewInfra(name string, opts ...InfraOption) *Infra

NewInfra creates a new infra with the given options.

func (*Infra) AppendCloser added in v0.0.2

func (infra *Infra) AppendCloser(fn func())

AppendCloser appends a closer to the infra.

func (*Infra) Gorm

func (infra *Infra) Gorm(name string) *gorm.DB

Gorm returns the gorm db client with the given name.

func (*Infra) MySQL

func (infra *Infra) MySQL(name string) *sql.DB

MySQL returns the mysql db client with the given name.

func (*Infra) RedisV6

func (infra *Infra) RedisV6(name string) *apm.RedisV6

RedisV6 returns the redis v6 client with the given name.

func (*Infra) RedisV9

func (infra *Infra) RedisV9(name string) *redis.Client

RedisV9 returns the redis v9 client with the given name.

func (*Infra) Stop

func (infra *Infra) Stop()

Stop stops the infra.

type InfraOption

type InfraOption func(*Infra)

InfraOption is the option for Infra.

func WithAPM

func WithAPM(otelEndpoint string) InfraOption

WithAPM creates a new apm and adds it to the infra.

func WithAutoPProf

func WithAutoPProf(autoPProfOpts *apm.AutoPProfOpt, opts ...holmes.Option) InfraOption

WithAutoPProf starts a holmes dumper to automatically record the running state of the program.

func WithGorm

func WithGorm(name, addr string) InfraOption

WithGorm creates a new gorm db and adds it to the infra. name is the business name of the db, and addr is the address of the db.

func WithMetrics

func WithMetrics(collectors ...prometheus.Collector) InfraOption

WithMetrics registers the given collectors to the goapm metrics registry. It default provides some collectors defined in goapm/metric.go.

func WithMySQL

func WithMySQL(name, addr string) InfraOption

WithMySQL creates a new mysql db and adds it to the infra. name is the business name of the db, and addr is the address of the db.

func WithRedisV6

func WithRedisV6(name, addr, password string, db ...int) InfraOption

WithRedisV6 creates a new redis v6 client and adds it to the infra. name is the business name of the redis, and addr is the address of the redis.

func WithRedisV9

func WithRedisV9(name, addr, password string, db ...int) InfraOption

WithRedisV9 creates a new redis v9 client and adds it to the infra. name is the business name of the redis, and addr is the address of the redis.

func WithRotateLog

func WithRotateLog(path string, opts ...rotatelogs.Option) InfraOption

WithRotateLog creates a new rotate log and sets it to the logrus. It default rotates every 7 days and keeps 7 days' logs.

Directories

Path Synopsis
apm
examples
protos module

Jump to

Keyboard shortcuts

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