frontendlogging

package
v0.0.0-testrgm4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyValAdd

func KeyValAdd(kv *KeyVal, key string, value string)

func KeyValToInterfaceMap

func KeyValToInterfaceMap(kv *KeyVal) map[string]interface{}

KeyValToInterfaceMap converts KeyVal to map[string]interface

func MergeKeyVal

func MergeKeyVal(target *KeyVal, source *KeyVal)

MergeKeyVal will merge source in target

func MergeKeyValWithPrefix

func MergeKeyValWithPrefix(target *KeyVal, source *KeyVal, prefix string)

MergeKeyValWithPrefix will merge source in target, adding a prefix to each key being merged in

func ReadSourceMapFromFS

func ReadSourceMapFromFS(dir string, path string) ([]byte, error)

Types

type App

type App struct {
	Name        string `json:"name,omitempty"`
	Release     string `json:"release,omitempty"`
	Version     string `json:"version,omitempty"`
	Environment string `json:"environment,omitempty"`
}

App holds metadata about the application event originates from

func (App) KeyVal

func (a App) KeyVal() *KeyVal

KeyVal produces key-> value representation of App metadata

type Browser

type Browser struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
	OS      string `json:"os,omitempty"`
	Mobile  bool   `json:"mobile,omitempty"`
}

Browser holds metadata about a client's browser

func (Browser) KeyVal

func (b Browser) KeyVal() *KeyVal

KeyVal produces key->value representation of the Browser metadata

type CtxVector

type CtxVector []interface{}

type Exception

type Exception struct {
	Type       string       `json:"type,omitempty"`
	Value      string       `json:"value,omitempty"`
	Stacktrace *Stacktrace  `json:"stacktrace,omitempty"`
	Timestamp  time.Time    `json:"timestamp"`
	Trace      TraceContext `json:"trace,omitempty"`
}

Exception struct controls all the data regarding an exception

func TransformException

func TransformException(ex *Exception, store *SourceMapStore) *Exception

TransformException will attempt to resolved all monified source locations in the stacktrace with original source locations

func (Exception) KeyVal

func (e Exception) KeyVal() *KeyVal

KeyVal representation of the exception object

func (Exception) Message

func (e Exception) Message() string

Message string is concatenating of the Exception.Type and Exception.Value

func (Exception) String

func (e Exception) String() string

String is the string representation of an Exception

type Frame

type Frame struct {
	Function string `json:"function,omitempty"`
	Module   string `json:"module,omitempty"`
	Filename string `json:"filename,omitempty"`
	Lineno   int    `json:"lineno,omitempty"`
	Colno    int    `json:"colno,omitempty"`
}

Frame struct represents a single stacktrace frame

func ResolveSourceLocation

func ResolveSourceLocation(store *SourceMapStore, frame *Frame) (*Frame, error)

ResolveSourceLocation resolves minified source location to original source location

func (Frame) String

func (frame Frame) String() string

String function converts a Frame into a human readable string

type FrontendGrafanaJavascriptAgentEvent

type FrontendGrafanaJavascriptAgentEvent struct {
	Exceptions   []Exception   `json:"exceptions,omitempty"`
	Logs         []Log         `json:"logs,omitempty"`
	Measurements []Measurement `json:"measurements,omitempty"`
	Meta         Meta          `json:"meta,omitempty"`
	Traces       *Traces       `json:"traces,omitempty"`
}

func (*FrontendGrafanaJavascriptAgentEvent) AddMetaToContext

func (event *FrontendGrafanaJavascriptAgentEvent) AddMetaToContext(ctx CtxVector) []interface{}

type FrontendSentryEvent

type FrontendSentryEvent struct {
	*sentry.Event
	Exception *FrontendSentryException `json:"exception,omitempty"`
}

func (*FrontendSentryEvent) MarshalJSON

func (event *FrontendSentryEvent) MarshalJSON() ([]byte, error)

func (*FrontendSentryEvent) ToLogContext

func (event *FrontendSentryEvent) ToLogContext(store *SourceMapStore) []interface{}

type FrontendSentryException

type FrontendSentryException struct {
	Values []FrontendSentryExceptionValue `json:"values,omitempty"`
}

func (*FrontendSentryException) FmtStacktraces

func (exception *FrontendSentryException) FmtStacktraces(store *SourceMapStore) string

type FrontendSentryExceptionValue

type FrontendSentryExceptionValue struct {
	Value      string            `json:"value,omitempty"`
	Type       string            `json:"type,omitempty"`
	Stacktrace sentry.Stacktrace `json:"stacktrace,omitempty"`
}

func (*FrontendSentryExceptionValue) FmtMessage

func (value *FrontendSentryExceptionValue) FmtMessage() string

func (*FrontendSentryExceptionValue) FmtStacktrace

func (value *FrontendSentryExceptionValue) FmtStacktrace(store *SourceMapStore) string

type KeyVal

type KeyVal = om.OrderedMap

KeyVal is an ordered map of string to interface

func KeyValFromMap

func KeyValFromMap(m map[string]string) *KeyVal

KeyValFromMap will instantiate KeyVal from a map[string]string

func NewKeyVal

func NewKeyVal() *KeyVal

NewKeyVal creates new empty KeyVal

func SpanToKeyVal

func SpanToKeyVal(s otelpdata.Span) *KeyVal

SpanToKeyVal returns KeyVal representation of a Span.

type Log

type Log struct {
	Message   string       `json:"message,omitempty"`
	LogLevel  LogLevel     `json:"level,omitempty"`
	Context   LogContext   `json:"context,omitempty"`
	Timestamp time.Time    `json:"timestamp"`
	Trace     TraceContext `json:"trace,omitempty"`
}

Log struct controls the data that come into a Log message

func (Log) KeyVal

func (l Log) KeyVal() *KeyVal

KeyVal representation of a Log object

func (Log) KeyValContext

func (l Log) KeyValContext() *KeyVal

type LogContext

type LogContext map[string]string

LogContext is a string to string map structure that represents the context of a log message

type LogLevel

type LogLevel string

LogLevel is log level enum for incoming app logs

const (
	// LogLevelTrace is "trace"
	LogLevelTrace LogLevel = "trace"
	// LogLevelDebug is "debug"
	LogLevelDebug LogLevel = "debug"
	// LogLevelInfo is "info"
	LogLevelInfo LogLevel = "info"
	// LogLevelWarning is "warning"
	LogLevelWarning LogLevel = "warn"
	// LogLevelError is "error"
	LogLevelError LogLevel = "error"
)

type Measurement

type Measurement struct {
	Values    map[string]float64 `json:"values,omitempty"`
	Timestamp time.Time          `json:"timestamp,omitempty"`
	Trace     TraceContext       `json:"trace,omitempty"`
	Type      string             `json:"type,omitempty"`
}

Measurement holds the data for user provided measurements

func (Measurement) KeyVal

func (m Measurement) KeyVal() *KeyVal

KeyVal representation of the Measurement object

type Meta

type Meta struct {
	SDK     SDK     `json:"sdk,omitempty"`
	App     App     `json:"app,omitempty"`
	User    User    `json:"user,omitempty"`
	Session Session `json:"session,omitempty"`
	Page    Page    `json:"page,omitempty"`
	Browser Browser `json:"browser,omitempty"`
}

Meta holds metadata about an app event

func (Meta) KeyVal

func (m Meta) KeyVal() *KeyVal

KeyVal produces key->value representation of the app event metadatga

type Page

type Page struct {
	ID         string            `json:"id,omitempty"`
	URL        string            `json:"url,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Page holds metadata about the web page event originates from

func (Page) KeyVal

func (p Page) KeyVal() *KeyVal

KeyVal produces key->val representation of Page metadata

type Payload

type Payload struct {
	Exceptions   []Exception   `json:"exceptions,omitempty"`
	Logs         []Log         `json:"logs,omitempty"`
	Measurements []Measurement `json:"measurements,omitempty"`
	Meta         Meta          `json:"meta,omitempty"`
	Traces       *Traces       `json:"traces,omitempty"`
}

Payload is the body of the receiver request

type ReadSourceMapFn

type ReadSourceMapFn func(dir string, path string) ([]byte, error)

type SDK

type SDK struct {
	Name         string           `json:"name,omitempty"`
	Version      string           `json:"version,omitempty"`
	Integrations []SDKIntegration `json:"integrations,omitempty"`
}

SDK holds metadata about the app agent that produced the event

func (SDK) KeyVal

func (sdk SDK) KeyVal() *KeyVal

KeyVal produces key->value representation of Sdk metadata

type SDKIntegration

type SDKIntegration struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

SDKIntegration holds metadata about a plugin/integration on the app agent that collected and sent the event

func (SDKIntegration) String

func (i SDKIntegration) String() string

type Session

type Session struct {
	ID         string            `json:"id,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

Session holds metadata about the browser session the event originates from

func (Session) KeyVal

func (s Session) KeyVal() *KeyVal

KeyVal produces key->value representation of the Session metadata

type SourceMapStore

type SourceMapStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSourceMapStore

func NewSourceMapStore(cfg *setting.Cfg, routeResolver plugins.StaticRouteResolver, readSourceMap ReadSourceMapFn) *SourceMapStore

type Stacktrace

type Stacktrace struct {
	Frames []Frame `json:"frames,omitempty"`
}

Stacktrace is a collection of Frames

type TraceContext

type TraceContext struct {
	TraceID string `json:"trace_id"`
	SpanID  string `json:"span_id"`
}

TraceContext holds trace id and span id associated to an entity (log, exception, measurement...).

func (TraceContext) KeyVal

func (tc TraceContext) KeyVal() *KeyVal

KeyVal representation of the trace context object.

type Traces

type Traces struct {
	otelpdata.Traces
}

Traces wraps the otel traces model.

func (Traces) MarshalJSON

func (t Traces) MarshalJSON() ([]byte, error)

MarshalJSON marshals Traces model to json.

func (Traces) SpanSlice

func (t Traces) SpanSlice() []otelpdata.Span

SpanSlice unpacks Traces entity into a slice of Spans.

func (*Traces) UnmarshalJSON

func (t *Traces) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals Traces model.

type User

type User struct {
	Email      string            `json:"email,omitempty"`
	ID         string            `json:"id,omitempty"`
	Username   string            `json:"username,omitempty"`
	Attributes map[string]string `json:"attributes,omitempty"`
}

User holds metadata about the user related to an app event

func (User) KeyVal

func (u User) KeyVal() *KeyVal

KeyVal produces a key->value representation User metadata

Jump to

Keyboard shortcuts

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