tracer

package
v0.0.0-...-2096857 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const AwsServiceKey = "aws.service"
View Source
const DefaultLambdaTimeoutThresholdMs = 200

threshold in milliseconds to send the trace before a Lambda timeout occurs

View Source
const DefaultMaxTraceSize = DefaultMaxTraceSizeKB * 1024

DefaultMaxTraceSize is the default maximum trace size (in bytes)

View Source
const DefaultMaxTraceSizeKB = 64

DefaultMaxTraceSizeKB is the default maximum trace size (in KB)

View Source
const EpsagonHTTPTraceIDKey = "http_trace_id"
View Source
const EpsagonRequestTraceIDKey = "request_trace_id"
View Source
const IsTrimmedKey = "is_trimmed"
View Source
const LabelsKey = "labels"

LabelsKey is the key for labels in resource metadata

View Source
const MaxLabelsSize = 10 * 1024

MaxLabelsSize is the maximum allowed total labels size (in bytes)

View Source
const MaxTraceSize = MaxTraceSizeKB * 1024

MaxTraceSize is the maximum allowed trace size (in bytes)

View Source
const MaxTraceSizeEnvVar = "EPSAGON_MAX_TRACE_SIZE"

MaxTraceSizeEnvVar max trace size environment variable

View Source
const MaxTraceSizeKB = 512

MaxTraceSizeKB is the maximum allowed trace size (in KB)

View Source
const VERSION = "1.39.0"

VERSION is Epsagon tracer version

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(event *protocol.Event)

AddEvent adds an event to the tracer

func AddException

func AddException(exception *protocol.Exception)

AddException adds an exception to the tracer

func AddLabel

func AddLabel(key string, value interface{})

AddLabel adds a label to the tracer

func GetLambdaTimeoutThresholdMs

func GetLambdaTimeoutThresholdMs() int

func GetTimestamp

func GetTimestamp() float64

GetTimestamp returns the current time in miliseconds

func HandleSendTracesResponse

func HandleSendTracesResponse(resp *http.Response, err error)

HandleSendTracesResponse handles responses from the trace collector

func StopGlobalTracer

func StopGlobalTracer()

StopTracer will close the tracer and send all the data to the collector

Types

type Config

type Config struct {
	ApplicationName string   // Application name in Epsagon
	Token           string   // Epsgaon Token
	CollectorURL    string   // Epsagon collector url
	MetadataOnly    bool     // Only send metadata about the event
	Debug           bool     // Print Epsagon debug information
	SendTimeout     string   // Timeout for sending traces to Epsagon
	Disable         bool     // Disable sending traces
	TestMode        bool     // TestMode sending traces
	IgnoredKeys     []string // IgnoredKeys are keys that will be masked from events metadata
	MaxTraceSize    int      // MaxTraceSize is the maximum allowed trace size (in bytes)
}

Config is the configuration for Epsagon's tracer

func GetGlobalTracerConfig

func GetGlobalTracerConfig() *Config

GetGlobalTracerConfig returns the configuration of the global tracer

type MockedEpsagonTracer

type MockedEpsagonTracer struct {
	Exceptions      *[]*protocol.Exception
	Events          *[]*protocol.Event
	Labels          map[string]interface{}
	RunnerException *protocol.Exception
	Config          *Config

	PanicStart        bool
	PanicAddEvent     bool
	PanicAddException bool
	PanicStop         bool
	DelayAddEvent     bool
	DelayedEventsChan chan bool
	// contains filtered or unexported fields
}

MockedEpsagonTracer will not send traces if closed

func (*MockedEpsagonTracer) AddError

func (t *MockedEpsagonTracer) AddError(errorType string, value interface{})

AddError implements AddError

func (*MockedEpsagonTracer) AddEvent

func (t *MockedEpsagonTracer) AddEvent(e *protocol.Event)

AddEvent implementes mocked AddEvent

func (*MockedEpsagonTracer) AddException

func (t *MockedEpsagonTracer) AddException(e *protocol.Exception)

AddException implementes mocked AddEvent

func (*MockedEpsagonTracer) AddExceptionTypeAndMessage

func (t *MockedEpsagonTracer) AddExceptionTypeAndMessage(exceptionType, msg string)

AddExceptionTypeAndMessage implements AddExceptionTypeAndMessage

func (*MockedEpsagonTracer) AddLabel

func (t *MockedEpsagonTracer) AddLabel(key string, value interface{})

AddLabel implements AddLabel

func (*MockedEpsagonTracer) GetConfig

func (t *MockedEpsagonTracer) GetConfig() *Config

GetConfig implementes mocked AddEvent

func (*MockedEpsagonTracer) GetRunnerEvent

func (t *MockedEpsagonTracer) GetRunnerEvent() *protocol.Event

GetRunnerEvent implements AddError

func (*MockedEpsagonTracer) Running

func (t *MockedEpsagonTracer) Running() bool

Running implementes mocked Running

func (*MockedEpsagonTracer) SendStopSignal

func (t *MockedEpsagonTracer) SendStopSignal()

Stop implementes mocked Stop

func (*MockedEpsagonTracer) Start

func (t *MockedEpsagonTracer) Start()

Start implementes mocked Start

func (*MockedEpsagonTracer) Stop

func (t *MockedEpsagonTracer) Stop()

Stop implementes mocked Stop

func (*MockedEpsagonTracer) Stopped

func (t *MockedEpsagonTracer) Stopped() bool

Stopped implementes mocked Stopped

type Tracer

type Tracer interface {
	AddEvent(*protocol.Event)
	AddException(*protocol.Exception)
	AddExceptionTypeAndMessage(string, string)
	// AddLabel Adds a label to the trace that will be sent
	AddLabel(string, interface{})
	// AddError Set an error to the trace that will be sent on the runner event
	AddError(string, interface{})
	// GetRunnerEvent Returns the first event with "runner" as its Origin
	GetRunnerEvent() *protocol.Event
	// Starts the tracer event data collection
	Start()
	Running() bool
	// Stop the tracer collecting data and send trace
	SendStopSignal()
	// Stop the tracer collecting data and send trace, waiting
	// for the tracer to finish running
	Stop()
	Stopped() bool
	GetConfig() *Config
}

Tracer is what a general program tracer has to provide

var (

	// GlobalTracer A global Tracer for all internal uses
	GlobalTracer Tracer
)

func CreateGlobalTracer

func CreateGlobalTracer(config *Config) Tracer

CreateTracer will initiallize a global epsagon tracer

func CreateTracer

func CreateTracer(config *Config) Tracer

CreateTracer will initiallize a new epsagon tracer

Jump to

Keyboard shortcuts

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