app

package
v1.90.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 7 Imported by: 14

Documentation

Overview

Package app has the static app info

Index

Constants

This section is empty.

Variables

View Source
var Version = defaultVersion

Version needs to be set at build time using -ldflags "-X github.com/getoutreach/gobox/pkg/app.Version=something"

Functions

func LogHook added in v1.88.0

func LogHook(ctx context.Context, r slog.Record) ([]slog.Attr, error)

LogHook provides an olog compatible hook func which extracts and returns the app Data as a nested attribute on log record. nolint:gocritic // Why: this signature is inline with the olog pkg hook type

func SetName

func SetName(name string)

SetName sets the app name

Should only be called from tests and app initialization

Types

type Data

type Data struct {
	Name    string
	Version string

	MainModule string

	Environment    string
	Namespace      string
	ServiceAccount string
	ClusterName    string
	Region         string
	PodID          string
	NodeID         string
	Deployment     string

	// ServiceID is a unique identifier for the service used primarily
	// within the `authn` framework.
	ServiceID string

	Bento string
	// contains filtered or unexported fields
}

Data provides the global app info

func Info

func Info() *Data

Info returns the static app info

This struct is used mainly to provide tags to append to logs. It's also used by a handful of infrastructure-y packages like Mint or orgservice that have special needs. Most services will never need to access it directly.

func (*Data) LogValue added in v1.88.0

func (d *Data) LogValue() slog.Value

LogValue implements the log/slog package's LogValuer interface (found here: https://pkg.go.dev/log/slog#LogValuer). Returns a subset of the App.Info data as a map.

func (*Data) MarshalLog

func (d *Data) MarshalLog(addField func(key string, v interface{}))

MarshalLog marshals the struct for logging

Jump to

Keyboard shortcuts

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