app

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: Apache-2.0 Imports: 30 Imported by: 12

Documentation

Overview

Package app implements OTEL, prometheus, graceful shutdown and other common application features for go-faster projects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Resource

func Resource(ctx context.Context) (*resource.Resource, error)

Resource returns new resource for application.

Combines following detectors: - ProcessRuntimeDescription - ProcessRuntimeVersion - ProcessRuntimeName And merges it with default resource.

func Run

func Run(f func(ctx context.Context, lg *zap.Logger, m *Metrics) error, op ...Option)

Run f until interrupt.

If errors.Is(err, ctx.Err()) is valid for returned error, shutdown is considered graceful. Context is cancelled on SIGINT. After watchdogTimeout application is forcefully terminated with exitCodeWatchdog.

Types

type Metrics

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

Metrics implement common basic metrics and infrastructure to it.

func (*Metrics) MeterProvider

func (m *Metrics) MeterProvider() metric.MeterProvider

func (*Metrics) String

func (m *Metrics) String() string

func (*Metrics) TextMapPropagator

func (m *Metrics) TextMapPropagator() propagation.TextMapPropagator

func (*Metrics) TracerProvider

func (m *Metrics) TracerProvider() trace.TracerProvider

type Option added in v0.8.2

type Option interface {
	// contains filtered or unexported methods
}

Option is a functional option for the application.

func WithContext added in v0.10.0

func WithContext(ctx context.Context) Option

WithContext sets the base context for the application. Background context is used by default.

func WithMeterOptions added in v0.8.2

func WithMeterOptions(opts ...autometer.Option) Option

WithMeterOptions sets the default autometer options for the application.

func WithResource added in v0.12.0

func WithResource(fn func(ctx context.Context) (*resource.Resource, error)) Option

WithResource sets the function that will be called to retrieve telemetry resource for application.

Defaults to Resource function.

func WithTracerOptions added in v0.8.2

func WithTracerOptions(opts ...autotracer.Option) Option

WithTracerOptions sets the default autotracer options for the application.

func WithZapConfig added in v0.8.2

func WithZapConfig(cfg zap.Config) Option

WithZapConfig sets the default zap config for the application.

func WithZapOptions added in v0.11.0

func WithZapOptions(opts ...zap.Option) Option

WithZapOptions sets additional zap logger options for the application.

Jump to

Keyboard shortcuts

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