trail

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: GPL-3.0 Imports: 19 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsError

func AsError(err error, target interface{}) bool

AsError finds first error in chain matching target.

func Debug

func Debug(v interface{})

Debug prints a message at debug level

func Debugf

func Debugf(format string, args ...interface{})

Debugf prints a formatted message at debug level

func Error

func Error(v interface{})

Error prints a message at error level

func ErrorBadRequest

func ErrorBadRequest(err error) error

ErrorBadRequest creates a bad request error

func ErrorConflict

func ErrorConflict(err error) error

ErrorConflict creates a conflict error

func ErrorNoContent

func ErrorNoContent(err error) error

ErrorNoContent creates a no content error

func ErrorNotAuthorized added in v0.1.4

func ErrorNotAuthorized(err error) error

ErrorNotAuthorized creates an unauthorized error

func ErrorNotFound

func ErrorNotFound(err error) error

ErrorNotFound creates a not found error

func ErrorTooManyRequests

func ErrorTooManyRequests(err error) error

ErrorTooManyRequests creates a too many requests error

func Errorf

func Errorf(format string, args ...interface{})

Errorf prints a formatted message at error level

func Fatal

func Fatal(v interface{})

Fatal prints a message at fatal level

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf prints a formatted message at fatal level

func Info

func Info(v interface{})

Info prints a message at info level

func Infof

func Infof(format string, args ...interface{})

Infof prints a formatted message at info level

func IsBadRequest

func IsBadRequest(err error) bool

IsBadRequest checks if an error is a bad request application error

func IsConflict

func IsConflict(err error) bool

IsConflict checks if an error is a conflict application error

func IsError

func IsError(err error, target error) bool

IsError finds first error in chain matching target.

func IsFatal

func IsFatal(err error) bool

IsFatal checks if an error is a fatal application error

func IsNoContent

func IsNoContent(err error) bool

IsNoContent checks if an error is a no content application error

func IsNotAuthorized added in v0.1.4

func IsNotAuthorized(err error) bool

IsNotAuthorized checks if an error is an unauthorized application error

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a not found application error

func IsTooManyRequests

func IsTooManyRequests(err error) bool

IsTooManyRequests checks if an error is a too many requests application error

func NewError

func NewError(msg string) error

NewError creates an internal error from an error message

func NewErrorBadRequest

func NewErrorBadRequest(msg string) error

NewErrorBadRequest creates a bad request error from a msg

func NewErrorConflict

func NewErrorConflict(msg string) error

NewErrorConflict creates a conflict error from a msg

func NewErrorNoContent

func NewErrorNoContent(msg string) error

NewErrorNoContent creates a no content error from a msg

func NewErrorNotAuthorized added in v0.1.4

func NewErrorNotAuthorized(msg string) error

NewErrorNotAuthorized creates an unauthorized error from a msg

func NewErrorNotFound

func NewErrorNotFound(msg string) error

NewErrorNotFound creates a not found error from a msg

func NewErrorTooManyRequests

func NewErrorTooManyRequests(msg string) error

NewErrorTooManyRequests creates a too many requests error from a msg

func NewErrorWithCode

func NewErrorWithCode(msg string, code int) error

NewErrorWithCode creates an error with code from a msg

func NewErrorf

func NewErrorf(format string, v ...interface{}) error

NewErrorf creates an internal error from a formatted error message

func NewTraceMiddleware

func NewTraceMiddleware(version string, withTrailHeader bool) func(next http.Handler) http.Handler

NewTraceMiddleware constructs a new middleware that handles tracing

func OneOff

func OneOff(v interface{})

OneOff prints a message at fatal level

func SetVerbosity

func SetVerbosity(level string)

SetVerbosity sets the global log level

func Stacktrace

func Stacktrace(err error) error

Stacktrace adds stacktrace to an error

func StatusCode

func StatusCode(err error) int

StatusCode gets an HTTP status code from an error

func Testing

func Testing()

Testing configures logging for testing

func Warn

func Warn(v interface{})

Warn prints a message at warn level

func Warnf

func Warnf(format string, args ...interface{})

Warnf prints a formatted message at warn level

Types

type Location added in v0.1.16

type Location struct {
	CountryCode     string  `json:"countryCode,omitempty"`
	CountryCode3    string  `json:"countryCode3,omitempty"`
	CountryName     string  `json:"countryName,omitempty"`
	CityName        string  `json:"cityName,omitempty"`
	Latitude        float64 `json:"latitude,omitempty"`
	Longitude       float64 `json:"longitude,omitempty"`
	TimeZone        string  `json:"timeZone,omitempty"`
	ContinentCode   string  `json:"continentCode,omitempty"`
	SubdivisionCode string  `json:"subdivisionCode,omitempty"`
}

Location of the origin request

type Request added in v0.1.16

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

Request represents a request with trail trace support enabled

func NewRequest added in v0.1.16

func NewRequest(w http.ResponseWriter, r *http.Request, version string) (*Request, error)

NewRequest creates a new trail request instance (or continues from a prev one)

func (*Request) AddGroups added in v0.2.3

func (r *Request) AddGroups(groupIds ...string)

AddGroups adds custom group information to the request

func (*Request) AddResponseHeaders added in v0.1.20

func (r *Request) AddResponseHeaders(headers http.Header)

AddResponseHeaders decodes the trail request from a response header

func (*Request) Context added in v0.1.16

func (r *Request) Context() context.Context

Context gets original the request context

func (*Request) Duration added in v0.1.16

func (r *Request) Duration() time.Duration

Duration gets the duration of the request

func (*Request) Finish added in v0.1.16

func (r *Request) Finish()

Finish ends the current request and sends a response

func (*Request) Groups added in v0.2.3

func (r *Request) Groups() []string

Groups gets the groups of the request

func (*Request) IP added in v0.1.16

func (r *Request) IP() net.IP

IP gets the ip of the request

func (*Request) Location added in v0.1.16

func (r *Request) Location() *Location

Location gets the request location

func (*Request) Method added in v0.1.31

func (r *Request) Method() string

Method gets the request method

func (*Request) Operations added in v0.1.16

func (r *Request) Operations() []Span

Operations gets the request operations

func (*Request) Origin added in v0.1.16

func (r *Request) Origin() *http.Request

Origin gets the origin http request

func (*Request) Profile added in v0.1.16

func (r *Request) Profile(v interface{}) error

Profile decodes the profile into the value

func (*Request) Recover added in v0.1.16

func (r *Request) Recover(v interface{})

Recover from a panic

func (*Request) Referrer added in v0.1.16

func (r *Request) Referrer() string

Referrer gets the referrer of the request

func (*Request) RequestId added in v0.1.16

func (r *Request) RequestId() string

RequestId gets the request id

func (*Request) Response added in v0.1.16

func (r *Request) Response(withTrailHeader bool) http.ResponseWriter

Response gets the underlying response writer

func (*Request) SetLocation added in v0.1.16

func (r *Request) SetLocation(location *Location)

SetLocation sets a custom location of the request

func (*Request) SetProfile added in v0.1.16

func (r *Request) SetProfile(profile interface{})

SetProfile sets a custom profile for the request

func (*Request) SetStatus added in v0.1.16

func (r *Request) SetStatus(status int)

SetStatus sets a custom response status code

func (*Request) SetUserId added in v0.1.16

func (r *Request) SetUserId(userId string)

SetUserId sets a custom user for the request

func (*Request) Status added in v0.1.16

func (r *Request) Status() int

Status gets the response status code

func (*Request) Trail added in v0.1.16

func (r *Request) Trail() string

Trail gets the encoded request trail

func (*Request) URL added in v0.1.16

func (r *Request) URL() *url.URL

URL gets the original url of the request

func (*Request) UserAgent added in v0.1.16

func (r *Request) UserAgent() string

UserAgent gets the user agent

func (*Request) UserId added in v0.1.16

func (r *Request) UserId() string

UserId gets the user id

func (*Request) Version added in v0.1.16

func (r *Request) Version() string

Version gets the version of the request

type Span

type Span struct {
	SpanId    uuid.UUID  `json:"spanId"`
	ParentId  *uuid.UUID `json:"parentId,omitempty"`
	Operation string     `json:"operation"`
	StartTime time.Time  `json:"startTime"`
	EndTime   time.Time  `json:"endTime"`
	Tags      Tags       `json:"tags,omitempty"`

	*Request `json:"-"`
	// contains filtered or unexported fields
}

Span for tracing instrumentation

func StartSpan

func StartSpan(ctx context.Context, operation string) *Span

StartSpan starts a new span instance (or continues from a parent)

func (*Span) AddResponseHeaders added in v0.1.20

func (s *Span) AddResponseHeaders(headers http.Header)

func (*Span) Capture

func (s *Span) Capture(err error)

Capture sets an error for the span

func (*Span) Context

func (s *Span) Context() context.Context

Context gets the original context of the span

func (*Span) Finish

func (s *Span) Finish()

Finish the span

func (*Span) Recover

func (s *Span) Recover(err interface{})

Recover from panics and fatal errors

func (*Span) SetRequest added in v0.1.16

func (s *Span) SetRequest(r *Request)

type Tags added in v0.1.9

type Tags map[string]string

Tags for custom data

func (Tags) Get added in v0.1.9

func (t Tags) Get(key string) string

Get a field by key

func (*Tags) Set added in v0.1.9

func (t *Tags) Set(key, value string)

Set a tag

func (*Tags) SetJSON added in v0.1.9

func (t *Tags) SetJSON(key string, value interface{})

SetJSON sets a json value

Jump to

Keyboard shortcuts

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