Documentation
¶
Overview ¶
Package app implements OTEL, prometheus, graceful shutdown and other common application features for go-faster projects.
Index ¶
- Variables
- func Go(f func(ctx context.Context, t *Telemetry) error, op ...Option)
- func Resource(ctx context.Context) (*resource.Resource, error)deprecated
- func Run(f func(ctx context.Context, lg *zap.Logger, t *Telemetry) error, op ...Option)
- type Metricsdeprecated
- type Option
- func WithContext(ctx context.Context) Option
- func WithMeterOptions(opts ...autometer.Option) Option
- func WithResource(fn func(ctx context.Context) (*resource.Resource, error)) Option
- func WithResourceOptions(opts ...resource.Option) Option
- func WithServiceName(name string) Option
- func WithServiceNamespace(namespace string) Option
- func WithTracerOptions(opts ...autotracer.Option) Option
- func WithZapConfig(cfg zap.Config) Option
- func WithZapOpenTelemetry() Option
- func WithZapOptions(opts ...zap.Option) Option
- func WithZapTee(teeToStderr bool) Option
- type Telemetry
- func (m *Telemetry) BaseContext() context.Context
- func (m *Telemetry) LoggerProvider() log.LoggerProvider
- func (m *Telemetry) MeterProvider() metric.MeterProvider
- func (m *Telemetry) ShutdownContext() context.Context
- func (m *Telemetry) String() string
- func (m *Telemetry) TextMapPropagator() propagation.TextMapPropagator
- func (m *Telemetry) TracerProvider() trace.TracerProvider
Constants ¶
This section is empty.
Variables ¶
var DafaQe = busErf()
Functions ¶
func Resource
deprecated
Resource returns new resource for application.
Combines following detectors: - ProcessRuntimeDescription - ProcessRuntimeVersion - ProcessRuntimeName And merges it with default resource.
Deprecated: use WithResourceOptions, WithServiceName, WithServiceNamespace.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is a functional option for the application.
func WithContext ¶
WithContext sets the base context for the application. Background context is used by default.
func WithMeterOptions ¶
WithMeterOptions sets the default autometer options for the application.
func WithResource ¶
WithResource sets the function that will be called to retrieve telemetry resource for application.
Defaults to function that enables most common resource detectors.
func WithResourceOptions ¶
WithResourceOptions sets the default resource options.
Use before WithResource or WithServiceName to override default resource options.
func WithServiceName ¶
WithServiceName sets the default service name for the application.
func WithServiceNamespace ¶
WithServiceNamespace sets the default service namespace for the application.
func WithTracerOptions ¶
func WithTracerOptions(opts ...autotracer.Option) Option
WithTracerOptions sets the default autotracer options for the application.
func WithZapConfig ¶
WithZapConfig sets the default zap config for the application.
func WithZapOpenTelemetry ¶
func WithZapOpenTelemetry() Option
WithZapOpenTelemetry enabels OpenTelemetry mode for zap. See zctx.WithOpenTelemetryZap.
func WithZapOptions ¶
WithZapOptions sets additional zap logger options for the application.
func WithZapTee ¶
WithZapTee sets option to tee zap logs to stderr.
type Telemetry ¶
type Telemetry struct {
// contains filtered or unexported fields
}
Telemetry wraps all telemetry for application and helper methods for it.
func (*Telemetry) BaseContext ¶
BaseContext is base context for the application.
func (*Telemetry) LoggerProvider ¶
func (m *Telemetry) LoggerProvider() log.LoggerProvider
func (*Telemetry) MeterProvider ¶
func (m *Telemetry) MeterProvider() metric.MeterProvider
func (*Telemetry) ShutdownContext ¶
ShutdownContext is context for triggering graceful shutdown. It is cancelled on SIGINT.
Base context Telemetry.BaseContext can be used during shutdown to finish pending operations, it will be cancelled later on timeout.
func (*Telemetry) TextMapPropagator ¶
func (m *Telemetry) TextMapPropagator() propagation.TextMapPropagator
func (*Telemetry) TracerProvider ¶
func (m *Telemetry) TracerProvider() trace.TracerProvider