stacktrace

package
v1.65.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: Apache-2.0, BSD-3-Clause, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToSpan

func AddToSpan(span ddtrace.Span, events ...*Event)

AddToSpan adds the event to the given span's root span as a tag if stacktrace collection is enabled

func Enabled

func Enabled() bool

Enabled returns whether stacktrace should be collected

Types

type Event

type Event struct {
	// Category is a well-known type of the event, not optional
	Category EventCategory `msg:"-"`
	// Type is a value event category specific, optional
	Type string `msg:"type,omitempty"`
	// Language is the language of the code that generated the event (set to "go" anyway here)
	Language string `msg:"language,omitempty"`
	// ID is the id of the event, optional for exceptions but mandatory for vulnerabilities and exploits to correlate with more data
	ID string `msg:"id,omitempty"`
	// Message is a generic message for the event
	Message string `msg:"message,omitempty"`
	// Frames is the stack trace of the event
	Frames StackTrace `msg:"frames"`
}

Event is the toplevel structure to contain a stacktrace and the additional information needed to correlate it with other data

func NewEvent

func NewEvent(eventCat EventCategory, options ...Options) *Event

NewEvent creates a new stacktrace event with the given category, type and message

func (*Event) DecodeMsg

func (z *Event) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Event) EncodeMsg

func (z *Event) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Event) MarshalMsg

func (z *Event) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Event) Msgsize

func (z *Event) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Event) UnmarshalMsg

func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type EventCategory

type EventCategory string
const (
	// ExceptionEvent is the event type for exception events
	ExceptionEvent EventCategory = "exception"
	// VulnerabilityEvent is the event type for vulnerability events
	VulnerabilityEvent EventCategory = "vulnerability"
	// ExploitEvent is the event type for exploit events
	ExploitEvent EventCategory = "exploit"
)

func (*EventCategory) DecodeMsg

func (z *EventCategory) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (EventCategory) EncodeMsg

func (z EventCategory) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (EventCategory) MarshalMsg

func (z EventCategory) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (EventCategory) Msgsize

func (z EventCategory) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*EventCategory) UnmarshalMsg

func (z *EventCategory) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Options added in v1.65.0

type Options func(*Event)

Options is a function type to set optional parameters for the event

func WithID added in v1.65.0

func WithID(id string) Options

WithID sets the id of the event

func WithMessage added in v1.65.0

func WithMessage(message string) Options

WithMessage sets the message of the event

func WithType added in v1.65.0

func WithType(eventType string) Options

WithType sets the type of the event

type StackFrame

type StackFrame struct {
	Index     uint32 `msg:"id"`                   // Index of the frame (0 = top of the stack)
	Text      string `msg:"text,omitempty"`       // Text version of the stackframe as a string
	File      string `msg:"file,omitempty"`       // File name where the code line is
	Line      uint32 `msg:"line,omitempty"`       // Line number in the context of the file where the code is
	Column    uint32 `msg:"column,omitempty"`     // Column where the code ran is
	Namespace string `msg:"namespace,omitempty"`  // Namespace is the fully qualified name of the package where the code is
	ClassName string `msg:"class_name,omitempty"` // ClassName is the fully qualified name of the class where the line of code is
	Function  string `msg:"function,omitempty"`   // Function is the fully qualified name of the function where the line of code is
}

StackFrame represents a single frame in the stack trace

func (*StackFrame) DecodeMsg

func (z *StackFrame) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*StackFrame) EncodeMsg

func (z *StackFrame) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*StackFrame) MarshalMsg

func (z *StackFrame) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*StackFrame) Msgsize

func (z *StackFrame) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*StackFrame) UnmarshalMsg

func (z *StackFrame) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type StackTrace

type StackTrace []StackFrame

StackTrace is intended to be sent over the span tag `_dd.stack`, the first frame is the current frame

func Capture

func Capture() StackTrace

Capture create a new stack trace from the current call stack

func SkipAndCapture

func SkipAndCapture(skip int) StackTrace

SkipAndCapture creates a new stack trace from the current call stack, skipping the first `skip` frames

func (*StackTrace) DecodeMsg

func (z *StackTrace) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (StackTrace) EncodeMsg

func (z StackTrace) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (StackTrace) MarshalMsg

func (z StackTrace) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (StackTrace) Msgsize

func (z StackTrace) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*StackTrace) UnmarshalMsg

func (z *StackTrace) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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