contextutils

package
v1.13.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2024 License: Apache-2.0 Imports: 4 Imported by: 26

Documentation

Overview

Package contextutils contains common flyte context utils.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLogFields

func GetLogFields(ctx context.Context) map[string]interface{}

GetLogFields gets a map of all known logKeys set on the context. logKeys are special and should be used in case, context fields are to be added to the log lines.

func Value

func Value(ctx context.Context, key Key) string

func Values

func Values(ctx context.Context, keys ...Key) map[string]string

func WithAppName

func WithAppName(ctx context.Context, appName string) context.Context

WithAppName gets a new context with AppName set.

func WithExecutionID

func WithExecutionID(ctx context.Context, execID string) context.Context

WithExecutionID gets a new context with ExecutionID set.

func WithGoroutineLabel

func WithGoroutineLabel(ctx context.Context, routineLabel string) context.Context

WithGoroutineLabel gets a new context with Go Routine label key set and a label assigned to the context using pprof.Labels. You can then call pprof.SetGoroutineLabels(ctx) to annotate the current go-routine and have that show up in pprof analysis.

func WithJobID

func WithJobID(ctx context.Context, jobID string) context.Context

WithJobID gets a new context with JobId set. If the existing context already has a job id, the new context will have <old_jobID>/<new_jobID> set as the job id.

func WithLaunchPlanID

func WithLaunchPlanID(ctx context.Context, launchPlan string) context.Context

WithLaunchPlanID gets a new context with a launch plan ID set.

func WithNamespace

func WithNamespace(ctx context.Context, namespace string) context.Context

WithNamespace gets a new context with namespace set.

func WithNodeID

func WithNodeID(ctx context.Context, nodeID string) context.Context

WithNodeID gets a new context with NodeID (nested) set.

func WithPhase

func WithPhase(ctx context.Context, phase string) context.Context

WithPhase gets a new context with Phase set.

func WithProjectDomain

func WithProjectDomain(ctx context.Context, project, domain string) context.Context

WithProjectDomain gets new context with Project and Domain values set

func WithRequestID

func WithRequestID(ctx context.Context, requestID string) context.Context

WithRequestID gets a new context with RequestID set.

func WithResourceVersion

func WithResourceVersion(ctx context.Context, resourceVersion string) context.Context

WithResourceVersion gets a new context with the resource version set.

func WithSignalID

func WithSignalID(ctx context.Context, signalID string) context.Context

WithSignalID gets a new context with SignalID set.

func WithTaskID

func WithTaskID(ctx context.Context, taskID string) context.Context

WithTaskID gets a new context with WorkflowName set.

func WithTaskType

func WithTaskType(ctx context.Context, taskType string) context.Context

WithTaskType gets a new context with TaskType set.

func WithWorkflowID

func WithWorkflowID(ctx context.Context, workflow string) context.Context

WithWorkflowID gets a new context with WorkflowName set.

Types

type Key

type Key string
const (
	AppNameKey    Key = "app_name"
	NamespaceKey  Key = "ns"
	TaskTypeKey   Key = "tasktype"
	ProjectKey    Key = "project"
	DomainKey     Key = "domain"
	WorkflowIDKey Key = "wf"
	NodeIDKey     Key = "node"
	TaskIDKey     Key = "task"
	// Adding the ExecIDKey label to a metric will cause higher cardinality. Use with caution.
	ExecIDKey          Key = "exec_id"
	JobIDKey           Key = "job_id"
	PhaseKey           Key = "phase"
	RoutineLabelKey    Key = "routine"
	LaunchPlanIDKey    Key = "lp"
	ResourceVersionKey Key = "res_ver"
	SignalIDKey        Key = "signal"
	RequestIDKey       Key = "x-request-id"
)

func MetricKeysFromStrings

func MetricKeysFromStrings(keys []string) []Key

MetricKeysFromStrings is a convenience method to convert a slice of strings into a slice of Keys

func (Key) String

func (k Key) String() string

Jump to

Keyboard shortcuts

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