clotel

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Base = fx.Module(moduleName,

	fx.Decorate(func(l *zap.Logger) *zap.Logger { return l.Named(moduleName) }),

	fx.Provide(fx.Annotate(
		func(o env.Options) (c Config, err error) {
			o.Prefix = strings.ToUpper(moduleName) + "_"
			return c, env.Parse(&c, o)
		},
		fx.ParamTags(`optional:"true"`))),

	fx.Provide(fx.Annotate(xray.NewIDGenerator, fx.As(new(sdktrace.IDGenerator)))),

	fx.Provide(func() propagation.TextMapPropagator { xp := xray.Propagator{}; return xp }),

	fx.Provide(fx.Annotate(NewTracerProvider,
		fx.OnStop(func(ctx context.Context, tp *sdktrace.TracerProvider) error { return tp.Shutdown(ctx) }),
	)),

	fx.Provide(func(tp *sdktrace.TracerProvider) trace.TracerProvider { return tp }),

	fx.Provide(fx.Annotate(NewMeterProvider)),

	fx.Provide(func(mp *sdkmetric.MeterProvider) metric.MeterProvider { return mp }),
)

Base module with di setup Base between test and prod environment

Service provides otel dependencies for container services

Test configures the DI for a test environment

Functions

func NewMeterProvider added in v0.6.0

func NewMeterProvider(cfg Config, det resource.Detector, mr metric.Reader) (*metric.MeterProvider, error)

NewMeterProvider initiales otel provider for metrics throughout the application

func NewMetricExporter added in v0.6.0

func NewMetricExporter(cfg Config) (metric.Exporter, error)

NewMetricExporter inits a metric exporter

func NewTracerProvider added in v0.6.0

NewTracerProvider inits a tracer provider

func WithExtraEcsAttributes added in v0.5.3

func WithExtraEcsAttributes(d resource.Detector) resource.Detector

WithExtraEcsAttributes decorates the detector with extra ecs attributess to fix log tracing

Types

type Config

type Config struct {
	// DetectorDetectTimeout bound the time it may take to init a trace provider
	DetectorDetectTimeout time.Duration `env:"DETECTOR_DETECT_TIMEOUT" envDefault:"1s"`
	// ExporterTimeout overwrites the timeout for exporting spans. This can be usefull in tests to speed
	// them up
	ExporterTimeout time.Duration `env:"EXPORTER_TIMEOUT" envDefault:"10s"`
	// ExporterEndpoint configures where otel span exporter will send data to
	ExporterEndpoint string `env:"EXPORTER_ENDPOINT" envDefault:"localhost:4317"`
	// MetricExporterConnectTimeout configures how long we'll wait for het metric exporter to connect to the collector
	MetricExporterConnectTimeout time.Duration `env:"METRIC_EXPORTER_CONNECT_TIMEOUT" envDefault:"1s"`
}

Config configures the code in this package.

Jump to

Keyboard shortcuts

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