mfctx

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 9 Imported by: 9

README

mfctx

Documentation

Index

Constants

View Source
const (
	MsgComplete = "complete"
	MsgError    = "error"
)
View Source
const (
	CtxValName string = "_Crumps"
)

Variables

This section is empty.

Functions

func GetAppID

func GetAppID() string

func GetAppIDUUID added in v1.0.1

func GetAppIDUUID() ints.Uuid

func GetAppName

func GetAppName() (name string)

func GetAppVersion

func GetAppVersion() (version string)

func GetDataCenter added in v0.0.3

func GetDataCenter() (name string)

func GetUnsecure added in v1.1.0

func GetUnsecure() (unsec bool)

func SetAppName

func SetAppName(name string)

func SetAppVersion

func SetAppVersion(version string)

func SetDataCenter added in v0.0.3

func SetDataCenter(name string)

func SetDefaultProvider

func SetDefaultProvider(p *Provider)

func SetUnsecure added in v1.1.0

func SetUnsecure(unsec bool)

func ToJson

func ToJson(sp JsonifyProvider, value any) json.RawMessage

func WriteLog

func WriteLog(lp LogProvider, c *Crumps, level LogLevel, message, segment, method, operationID, traceID string, steps []StepInfo, values map[string]Values)

func WriteMetricRequest

func WriteMetricRequest(mp MetricsProvider, c *Crumps, segment, method string)

func WriteMetricResponse

func WriteMetricResponse(mp MetricsProvider, c *Crumps, mRequest time.Time, segment, method string, resultResult string)

func WriteTrace

func WriteTrace(tp TraceProvider, span trace.Span, c *Crumps, segment, method, operationID string, steps []StepInfo, values map[string]Values)

Types

type Crumps

type Crumps struct {
	// contains filtered or unexported fields
}

func FromCtx

func FromCtx(ctx context.Context) *Crumps

func (*Crumps) Complete

func (c *Crumps) Complete(err error)

func (*Crumps) Copy

func (c *Crumps) Copy() *Crumps

func (*Crumps) Deadline

func (c *Crumps) Deadline() (deadline time.Time, ok bool)

func (*Crumps) Done

func (c *Crumps) Done() <-chan struct{}

func (*Crumps) Err

func (c *Crumps) Err() error

func (*Crumps) GetOperationID added in v0.0.2

func (c *Crumps) GetOperationID() string

func (*Crumps) Log

func (c *Crumps) Log(level LogLevel, message string)

func (*Crumps) LogUnsec added in v1.1.0

func (c *Crumps) LogUnsec(level LogLevel, message string)

LogUnsec logs when unsecure is true

func (*Crumps) Start

func (c *Crumps) Start(method string) *Crumps

func (*Crumps) StartSegment

func (c *Crumps) StartSegment(segment, method string) *Crumps

func (*Crumps) Value

func (c *Crumps) Value(key any) any

func (*Crumps) With

func (c *Crumps) With(name string, value any) *Crumps

With adds jsonify value and adds it

func (*Crumps) WithCancel added in v0.0.3

func (c *Crumps) WithCancel() (*Crumps, context.CancelFunc)

func (*Crumps) WithCancelCause added in v0.0.3

func (c *Crumps) WithCancelCause() (*Crumps, context.CancelCauseFunc)

func (*Crumps) WithDeadline added in v0.0.3

func (c *Crumps) WithDeadline(d time.Time) (*Crumps, context.CancelFunc)

func (*Crumps) WithDeadlineCause added in v0.0.3

func (c *Crumps) WithDeadlineCause(d time.Time, cause error) (*Crumps, context.CancelFunc)

func (*Crumps) WithTimeout added in v0.0.3

func (c *Crumps) WithTimeout(timeout time.Duration) (*Crumps, context.CancelFunc)

func (*Crumps) WithTimeoutCause added in v0.0.3

func (c *Crumps) WithTimeoutCause(timeout time.Duration, cause error) (*Crumps, context.CancelFunc)

func (*Crumps) WithUnsec added in v1.1.0

func (c *Crumps) WithUnsec(name string, value any) *Crumps

WithUnsec adds jsonify value and adds it when unsecure is true

func (*Crumps) WithValue added in v0.0.3

func (c *Crumps) WithValue(key any, val any) (*Crumps, context.CancelFunc)

func (*Crumps) WithoutCancel added in v0.0.3

func (c *Crumps) WithoutCancel(key any, val any) (*Crumps, context.CancelFunc)

type JsonifyProvider

type JsonifyProvider interface {
	ToJson(value any) json.RawMessage
}

type LogLevel

type LogLevel string
const (
	Trace       LogLevel = "trace"
	Debug       LogLevel = "debug"
	Start       LogLevel = "start"
	Finish      LogLevel = "finish"
	Info        LogLevel = "info"
	FinishError LogLevel = "finish_error"
	Warning     LogLevel = "warning"
	Error       LogLevel = "error"
	Fatal       LogLevel = "fatal"
)

type LogProvider

type LogProvider interface {
	WriteLog(c *Crumps, level LogLevel, message, segment, method, operationID, traceID string, steps []StepInfo, values map[string]Values)
}

type MetricsProvider

type MetricsProvider interface {
	WriteMetricRequest(c *Crumps, segment, method string)
	WriteMetricResponse(c *Crumps, mRequest time.Time, segment, method string, resultResult string)
}

type Provider

type Provider struct {
	LP LogProvider
	MP MetricsProvider
	SP JsonifyProvider
	TP TraceProvider
}
var DefaultProvider *Provider = nil

func (*Provider) MakeCrumps

func (p *Provider) MakeCrumps() (c *Crumps)

type StepInfo

type StepInfo struct {
	StepID  string    `json:"step_id"`
	StartTS time.Time `json:"start"`
	Segment string    `json:"segment"`
	Method  string    `json:"method"`
}

type TraceProvider

type TraceProvider interface {
	WriteTrace(span trace.Span, c *Crumps, segment, method, operationID string, steps []StepInfo, values map[string]Values)
}

type Values

type Values []json.RawMessage

Directories

Path Synopsis
examples
loggers
metrics
tracers

Jump to

Keyboard shortcuts

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