Documentation
¶
Index ¶
- type Infra
- type InfraOption
- func WithAPM(otelEndpoint string) InfraOption
- func WithAutoPProf(autoPProfOpts *apm.AutoPProfOpt, opts ...holmes.Option) InfraOption
- func WithGorm(name, addr string) InfraOption
- func WithMetrics(collectors ...prometheus.Collector) InfraOption
- func WithMySQL(name, addr string) InfraOption
- func WithRedisV6(name, addr, password string, db ...int) InfraOption
- func WithRedisV9(name, addr, password string, db ...int) InfraOption
- func WithRotateLog(path string, opts ...rotatelogs.Option) InfraOption
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.
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.
