logz

package
v19.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 20 Imported by: 0

README

The logz package

The logz package should be used to re-use existing log attributes (slog.Attr) and helpers. Fields that GitLab standardizes across services take their name from LabKit's fields package, through the helpers in LabKit's log package where one exists. New log fields can be added in case they don't drag in any new dependency. In case the log field requires a new dependency, you should define the log field name in fields.go and define the slog.Attr helper in the module where it's used.

Log field names

Log field names must be in snake_case.

Documentation

Index

Constants

View Source
const (
	AgentConfig = "agent_config"
	ApplyEvent  = "apply_event"

	VertexID     = "vid"
	FromVertexID = "from_vid"
	ToVertexID   = "to_vid"
	ArcType      = "arc_type"
	VidRoot      = "vid_root"
	VidWasRoot   = "vid_was_root"
)
View Source
const (
	AttributesFieldName = "attrs"
)

Variables

This section is empty.

Functions

func AbortCause

func AbortCause[T ~string](cause T) slog.Attr

func AbortRetryAttempt

func AbortRetryAttempt(n int32) slog.Attr

func ActionResultSizeInBytes added in v19.3.0

func ActionResultSizeInBytes(size int) slog.Attr

ActionResultSizeInBytes is the marshaled size of the value an action returned.

func ActivityName

func ActivityName(name string) slog.Attr

func ActivityTaskID

func ActivityTaskID(id fmt.Stringer) slog.Attr

func AgentKey

func AgentKey(agentKey api.AgentKey) slog.Attr

func AgentName added in v19.4.0

func AgentName(name string) slog.Attr

func AnyJSONValue

func AnyJSONValue(key string, value any) slog.Attr

func Attempt

func Attempt[T ~int | ~int32](attempt T) slog.Attr

func AutoFlowAction added in v19.4.0

func AutoFlowAction(name string) slog.Attr

AutoFlowAction names an AutoFlow module action.

func AutoFlowModule added in v19.4.0

func AutoFlowModule(name string) slog.Attr

AutoFlowModule names the AutoFlow module an action belongs to.

func Backoff

func Backoff(d time.Duration) slog.Attr

func CIJobID

func CIJobID(id int64) slog.Attr

func CommitID

func CommitID(commitID string) slog.Attr

func ConsumerGroup

func ConsumerGroup(consumerGroup string) slog.Attr

func ConsumerName

func ConsumerName(consumerName string) slog.Attr

func CorrelationID added in v19.4.0

func CorrelationID(id string) slog.Attr

CorrelationID is the GitLab correlation ID, carried in the X-Request-Id header.

func DBID added in v19.1.0

func DBID[T ~int16](id T) slog.Attr

func DeletedCount added in v19.4.0

func DeletedCount(n int64) slog.Attr

func Disposition

func Disposition[T ~string](disposition T) slog.Attr

func DurationS added in v19.3.0

func DurationS(duration time.Duration) slog.Attr

func Error

func Error(err error) slog.Attr

func ExecutionResult

func ExecutionResult[T ~string](result T) slog.Attr

func ExternalNamespaceID added in v19.4.0

func ExternalNamespaceID[T ~int64](id T) slog.Attr

ExternalNamespaceID is the caller's id of the namespace a workflow runs in.

func FenceID

func FenceID[T ~int64](id T) slog.Attr

func FireAtDB

func FireAtDB(t time.Time) slog.Attr

func FullReconciliationInterval

func FullReconciliationInterval(interval time.Duration) slog.Attr

func GRPCCode added in v19.4.0

func GRPCCode(code string) slog.Attr

func GRPCMethod

func GRPCMethod(method string) slog.Attr

func GRPCService

func GRPCService(service string) slog.Attr

func GV

func GV(gvr schema.GroupVersion) slog.Attr

func GVR

func GitRepositoryURL

func GitRepositoryURL(url string) slog.Attr

func HTTPStatusCode added in v19.3.0

func HTTPStatusCode(code int32) slog.Attr

func HeldFenceID added in v19.4.0

func HeldFenceID[T ~int64](id T) slog.Attr

func IdempotencyKey added in v19.3.0

func IdempotencyKey(key string) slog.Attr

func InFlightTasks added in v19.4.0

func InFlightTasks(n int) slog.Attr

func InstanceIndex added in v19.4.0

func InstanceIndex(i int) slog.Attr

func Interval added in v19.2.0

func Interval(duration time.Duration) slog.Attr

func InventoryName

func InventoryName(name string) slog.Attr

func InventoryNamespace

func InventoryNamespace(namespace string) slog.Attr

func IsScriptPrint

func IsScriptPrint() slog.Attr

func IsWebSocket

func IsWebSocket(isWebSocket bool) slog.Attr

func JSONValue

func JSONValue(key string, value any) slog.Attr

func K8sObjectName

func K8sObjectName(name string) slog.Attr

func K8sObjectNamespace

func K8sObjectNamespace(name string) slog.Attr

func K8sObjectNsAndName

func K8sObjectNsAndName(o metav1.Object) slog.Attr

func LabelSelector

func LabelSelector(selector string) slog.Attr

func LastConnectedAt

func LastConnectedAt(timestamp time.Time) slog.Attr

func LastSeenSequenceID

func LastSeenSequenceID[T ~int64](id T) slog.Attr

func LazyValue

func LazyValue(key string, val func() slog.Value) slog.Attr

func ListenerAddr added in v19.1.0

func ListenerAddr(l net.Listener) slog.Attr

func ListenerName

func ListenerName(name string) slog.Attr

func LoadedEventCount

func LoadedEventCount(n int) slog.Attr

func MaxAttempts

func MaxAttempts[T ~int | ~int32](n T) slog.Attr

func ModuleName

func ModuleName(name string) slog.Attr

ModuleName defines the field for logging either NGitLab-kas or agentk module name.

func ModuleURI added in v19.4.0

func ModuleURI(uri string) slog.Attr

ModuleURI is the URI a flow's load() statement names a module by.

func NotAdmittedReason added in v19.3.0

func NotAdmittedReason(reason string) slog.Attr

NotAdmittedReason is the reason a runner controller did not admit a job.

func ObjectKey

func ObjectKey(objKey string) slog.Attr

func OwnedShards

func OwnedShards(n int) slog.Attr

func PartialReconciliationInterval

func PartialReconciliationInterval(interval time.Duration) slog.Attr

func PartitionName added in v19.2.0

func PartitionName(name string) slog.Attr

func PayloadSizeInBytes

func PayloadSizeInBytes(size int) slog.Attr

func PendingFutureCount

func PendingFutureCount(n int) slog.Attr

func PodName

func PodName(podName string) slog.Attr

func PodNamespace

func PodNamespace(podNamespace string) slog.Attr

func PodStatus

func PodStatus(podStatus string) slog.Attr

func PodWaitingMessage added in v19.3.0

func PodWaitingMessage(msg string) slog.Attr

PodWaitingMessage is the message from a container's waiting state.

func PodWaitingReason added in v19.3.0

func PodWaitingReason(reason string) slog.Attr

PodWaitingReason is the reason a container is in the waiting state.

func PolicyTrigger added in v19.4.0

func PolicyTrigger(trigger string) slog.Attr

func PoolMaxConns added in v19.4.0

func PoolMaxConns(n int) slog.Attr

func ProjectPath added in v19.4.0

func ProjectPath(path string) slog.Attr

ProjectPath is the human-readable GitLab project path (e.g. gitlab-org/gitlab).

func ProjectsToReconcile

func ProjectsToReconcile(p sets.Set[string]) slog.Attr

func ProtoJSONValue

func ProtoJSONValue(key string, value proto.Message) slog.Attr

func ReadyInstances added in v19.4.0

func ReadyInstances(n int) slog.Attr

func RecoveredCount

func RecoveredCount(n int64) slog.Attr

func RedisChannel added in v19.1.0

func RedisChannel(name string) slog.Attr

func RedisKey

func RedisKey(key []byte) slog.Attr

func RefSite added in v19.2.0

func RefSite[T ~string](site T) slog.Attr

func RejectedCount added in v19.4.0

func RejectedCount(n int64) slog.Attr

func RejectionReason added in v19.4.0

func RejectionReason[T ~string](reason T) slog.Attr

func RemovedHashKeys

func RemovedHashKeys(n int) slog.Attr

func RemovedHashKeysIn

func RemovedHashKeysIn(hashName string, n int) slog.Attr

func Replayed

func Replayed() slog.Attr

func ResponseHeaders

func ResponseHeaders(h http.Header) slog.Attr

func ScheduleCount

func ScheduleCount(n int) slog.Attr

func ScheduledTaskID

func ScheduledTaskID(id fmt.Stringer) slog.Attr

func ScheduledTaskType added in v19.4.0

func ScheduledTaskType(t string) slog.Attr

func SecondsAgo

func SecondsAgo(duration time.Duration) slog.Attr

func ShardCount added in v19.4.0

func ShardCount(n int) slog.Attr

func ShardEntitlement added in v19.4.0

func ShardEntitlement(n int) slog.Attr

func ShardEntitlementTotal added in v19.4.0

func ShardEntitlementTotal(n int) slog.Attr

func ShardID

func ShardID[T ~int32](id T) slog.Attr

func ShardIDs added in v19.4.0

func ShardIDs[T ~int32](ids []T) slog.Attr

func ShardsConfiguredTotal added in v19.4.0

func ShardsConfiguredTotal(n int) slog.Attr

func SignalID

func SignalID(id fmt.Stringer) slog.Attr

func SignalName

func SignalName(name string) slog.Attr

func SignalType

func SignalType(st fmt.Stringer) slog.Attr

func StarlarkPosition added in v19.4.0

func StarlarkPosition(pos fmt.Stringer) slog.Attr

StarlarkPosition is the file:line:col a flow was stopped at.

func StarlarkThread added in v19.4.0

func StarlarkThread(name string) slog.Attr

StarlarkThread names the interpreter thread a flow was running on.

func StateTransition added in v19.4.0

func StateTransition[T ~string](transition T) slog.Attr

func StringSet

func StringSet(key string, val sets.Set[string]) slog.Attr

func Strings

func Strings(key string, val []string) slog.Attr

func TargetNamespace

func TargetNamespace(namespace string) slog.Attr

func TemplateName added in v19.4.0

func TemplateName(name string) slog.Attr

func TerminalCause

func TerminalCause[T ~string](cause T) slog.Attr

func TokenLimit

func TokenLimit(limit uint64) slog.Attr

func Topic

func Topic(topic string) slog.Attr

func TraceID

func TraceID(traceID trace.TraceID) slog.Attr

func TraceIDFromContext

func TraceIDFromContext(ctx context.Context) slog.Attr

func TransformName added in v19.3.0

func TransformName(name string) slog.Attr

func TransformResultSizeInBytes added in v19.3.0

func TransformResultSizeInBytes(size int) slog.Attr

TransformResultSizeInBytes is the marshaled size of the value a transform returned in place of the action's own.

func TrimSourceFilePath

func TrimSourceFilePath(attr slog.Attr) slog.Attr

func TunnelsByAgent

func TunnelsByAgent(numTunnels int) slog.Attr

func U64Count

func U64Count(count uint64) slog.Attr

U64Count defines a counter field Use for any integer counters.

func URL

func URL(url string) slog.Attr

func URLPath

func URLPath(url string) slog.Attr

func URLPathPrefix

func URLPathPrefix(urlPrefix string) slog.Attr

func VulnerabilitiesCount

func VulnerabilitiesCount(n int) slog.Attr

func WatchID

func WatchID(id string) slog.Attr

func WorkerStage added in v19.4.0

func WorkerStage[T ~string](stage T) slog.Attr

func WorkflowAlreadyExists

func WorkflowAlreadyExists(v bool) slog.Attr

func WorkflowExecutionState

func WorkflowExecutionState(state fmt.Stringer) slog.Attr

func WorkflowID

func WorkflowID(id fmt.Stringer) slog.Attr

func WorkflowKey added in v19.3.0

func WorkflowKey(key string) slog.Attr

func WorkflowName added in v19.1.0

func WorkflowName(name string) slog.Attr

func WorkflowPoolSize added in v19.4.0

func WorkflowPoolSize(n int) slog.Attr

func WorkflowTaskID

func WorkflowTaskID(id fmt.Stringer) slog.Attr

func WorkspaceDataCount

func WorkspaceDataCount(count int) slog.Attr

func WorkspaceName

func WorkspaceName(name string) slog.Attr

func WorkspaceNamespace

func WorkspaceNamespace(namespace string) slog.Attr

Types

type LockedWriter

type LockedWriter struct {
	io.Writer
	// contains filtered or unexported fields
}

LockedWriter serializes Write calls.

func (*LockedWriter) Write

func (w *LockedWriter) Write(data []byte) (int, error)

type LogValuerFunc

type LogValuerFunc func() slog.Value

func (LogValuerFunc) LogValue

func (f LogValuerFunc) LogValue() slog.Value

Jump to

Keyboard shortcuts

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