observability

package
v0.412.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleNameAttribute          = "ftl.module.name"
	OutcomeStatusNameAttribute   = "ftl.outcome.status"
	RunnerDeploymentKeyAttribute = "ftl.deployment.key"

	SuccessStatus = "success"
	FailureStatus = "failure"
)

Variables

This section is empty.

Functions

func AddSpanContextToLogger

func AddSpanContextToLogger(ctx context.Context) context.Context

func AddSpanToLogger

func AddSpanToLogger(ctx context.Context, span trace.Span) (context.Context, trace.Span)

func FatalError

func FatalError(signalName string, err error)

func Init

func Init(ctx context.Context, isUserService bool, projectName, serviceName, serviceVersion string, config Config) error

func LogBucket

func LogBucket(base int, num int64, optMin, optMax optional.Option[int]) string

LogBucket returns a string bucket label for a given positive number bucketed into powers of some arbitrary base. For base 8, for example, we would have buckets:

<1, [1-8), [8-64), [64-512), etc.

The buckets are then demarcated by `min` and `max`, such that any `num` < `base`^`min` will be bucketed together into the min bucket, and similarly, any `num` >= `base`^`max` will go in the `max` bucket. This constrains output cardinality by chopping the long tails on both ends of the normal distribution and lumping them all into terminal buckets. When `min` and `max` are not provided, the effective `min` is 0, and there is no max.

Go only supports a few bases with math.Log*, so this func performs a change of base: log_b(x) = log_a(x) / log_a(b)

func NewOtelLogger

func NewOtelLogger(logger *log.Logger, level log.Level) logr.Logger

func OpenDBAndInstrument

func OpenDBAndInstrument(dsn string) (*sql.DB, error)

func SuccessOrFailureStatusAttr

func SuccessOrFailureStatusAttr(succeeded bool) attribute.KeyValue

func TimeSinceMS

func TimeSinceMS(start time.Time) int64

Types

type Config

type Config struct {
	LogLevel   log.Level      `default:"error" help:"OTEL log level." env:"FTL_O11Y_LOG_LEVEL"`
	ExportOTEL ExportOTELFlag `help:"Export observability data to OTEL." env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
}

type ExportOTELFlag

type ExportOTELFlag bool

func (*ExportOTELFlag) UnmarshalText

func (e *ExportOTELFlag) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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