requestenvelopego

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

Build Status

request-envelope-go

Wrapper of request operations (ie logging, tracing)

usage

    import (
        "github.com/AccelByte/logger-go"
    )

    logger := loggergo.InitLogger("service-name", "realm")

    scope := NewRootScope(context.Background(), logger, "component-name", "trace-id")
    defer scope.Finish()

    scope.Logger.Errorf("err")
    // output: time="2020-04-03T16:37:45+07:00" level=error msg=err file="scope_test.go:21" func=logger-go.TestServiceNameLogged realm=realm service=service-name caller=component-name trace=xxxx span=yyyy

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scope

type Scope struct {
	Ctx     context.Context
	TraceID string
	Span    opentracing.Span
	Logger  *logrus.Entry
}

Scope used as the envelope to combine and transport request-related information by the chain of function calls

func ChildScopeFromRemoteScope

func ChildScopeFromRemoteScope(
	rootCtx context.Context,
	rootLogger *logrus.Entry,
	name string,
	spanContextStr string,
	traceID string,
) *Scope

func NewRootScope

func NewRootScope(rootCtx context.Context, rootLogger *logrus.Entry, name string, abTraceID string) *Scope

func (*Scope) AddBaggage

func (s *Scope) AddBaggage(key string, value string)

AddBaggage sends a baggage item into tracer

func (*Scope) Finish

func (s *Scope) Finish()

Finish finishes current scope

func (*Scope) GetSpanContextString

func (s *Scope) GetSpanContextString() string

GetSpanContextString gets scope span context string

func (*Scope) NewChildScope

func (s *Scope) NewChildScope(name string) *Scope

NewChildScope creates new child Scope

func (*Scope) TraceError

func (s *Scope) TraceError(err error)

TraceLog sends a log into tracer

func (*Scope) TraceLog

func (s *Scope) TraceLog(key, value string)

TraceLog sends a log into tracer

func (*Scope) TraceTag

func (s *Scope) TraceTag(key, value string)

TraceTag sends a tag into tracer

Jump to

Keyboard shortcuts

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