Version: v1.16.0 Latest Latest

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 15 Imported by: 0




View Source
const (
	CustomTransactionNamePrefix = "custom"
	OtherTransactionName        = "other"
	MetricIDSeparator           = "&"
	TagsKVSeparator             = ":"
	OtherMetricIDPrefix         = OtherTransactionName + MetricIDSeparator

Special transaction names

View Source
const (
	RequestCount               = "RequestCount"
	TraceCount                 = "TraceCount"
	TokenBucketExhaustionCount = "TokenBucketExhaustionCount"
	SampleCount                = "SampleCount"
	ThroughTraceCount          = "ThroughTraceCount"
	TriggeredTraceCount        = "TriggeredTraceCount"

Request counters definition

View Source
const (
	RCRegular             = "ReqCounterRegular"
	RCRelaxedTriggerTrace = "ReqCounterRelaxedTriggerTrace"
	RCStrictTriggerTrace  = "ReqCounterStrictTriggerTrace"

Request counters collection categories

View Source
const (

	// MaxTagsCount is the maximum number of tags allowed
	MaxTagsCount = 50


View Source
var (
	// ErrExceedsMetricsCountLimit indicates there are too many distinct metrics.
	ErrExceedsMetricsCountLimit = errors.New("exceeds metrics count limit per flush interval")
	// ErrExceedsTagsCountLimit indicates there are too many tags
	ErrExceedsTagsCountLimit = errors.New("exceeds tags count limit")
	// ErrMetricsWithNonPositiveCount indicates the count is negative or zero
	ErrMetricsWithNonPositiveCount = errors.New("metrics with non-positive count")


func BuildBuiltinMetricsMessage

func BuildBuiltinMetricsMessage(m *Measurements, qs *EventQueueStats,
	rcs map[string]*RateCounts, runtimeMetrics bool) []byte

BuildBuiltinMetricsMessage generates a metrics message in BSON format with all the currently available values metricsFlushInterval current metrics flush interval

return metrics message in BSON format

func BuildMessage

func BuildMessage(m *Measurements, serverless bool) []byte

BuildMessage creates and encodes the custom metrics message.

func BuildServerlessMessage

func BuildServerlessMessage(span HTTPSpanMessage, rcs map[string]*RateCounts, rate int, source int) []byte

func GetTransactionFromPath

func GetTransactionFromPath(path string) string

GetTransactionFromPath performs fingerprinting on a given escaped path to extract the transaction name We can get the path so there is no need to parse the full URL. e.g. Escaped Path path: /appoptics/appoptics-apm-go/blob/metrics becomes /appoptics/appoptics-apm-go


type BaseSpanMessage

type BaseSpanMessage struct {
	Duration time.Duration // duration of the span (nanoseconds)
	HasError bool          // boolean flag whether this transaction contains an error or not

BaseSpanMessage is the base span message with properties found in all types of span messages

type EventQueueStats

type EventQueueStats struct {
	// contains filtered or unexported fields

EventQueueStats is the counters of the event queue stats All the fields are supposed to be accessed through atomic operations

func (*EventQueueStats) CopyAndReset

func (s *EventQueueStats) CopyAndReset() *EventQueueStats

CopyAndReset returns a copy of its current values and reset itself.

func (*EventQueueStats) NumFailedAdd

func (s *EventQueueStats) NumFailedAdd(n int64)

func (*EventQueueStats) NumOverflowedAdd

func (s *EventQueueStats) NumOverflowedAdd(n int64)

func (*EventQueueStats) NumSentAdd

func (s *EventQueueStats) NumSentAdd(n int64)

func (*EventQueueStats) SetQueueLargest

func (s *EventQueueStats) SetQueueLargest(count int64)

func (*EventQueueStats) TotalEventsAdd

func (s *EventQueueStats) TotalEventsAdd(n int64)

type HTTPSpanMessage

type HTTPSpanMessage struct {
	Transaction string // transaction name (e.g. controller.action)
	Path        string // the url path which will be processed and used as transaction (if Transaction is empty)
	Status      int    // HTTP status code (e.g. 200, 500, ...)
	Host        string // HTTP-Host
	Method      string // HTTP method (e.g. GET, POST, ...)

HTTPSpanMessage is used for inbound metrics

func (*HTTPSpanMessage) Process

func (s *HTTPSpanMessage) Process(m *Measurements)

Process processes an HttpSpanMessage

type Measurement

type Measurement struct {
	Name      string            // the name of the measurement (e.g. TransactionResponseTime)
	Tags      map[string]string // map of KVs. It may be nil
	Count     int               // count of this measurement
	Sum       float64           // sum for this measurement
	ReportSum bool              // include the sum in the report?

Measurement is a single measurement for reporting

type Measurements

type Measurements struct {
	IsCustom      bool
	FlushInterval int32
	sync.Mutex    // protect access to this collection
	// contains filtered or unexported fields

Measurements are a collection of mutex-protected measurements

func NewMeasurements

func NewMeasurements(isCustom bool, flushInterval int32, maxCount int32) *Measurements

func (*Measurements) Cap

func (m *Measurements) Cap() int32

Cap returns the maximum number of distinct metrics allowed.

func (*Measurements) Clone

func (m *Measurements) Clone() *Measurements

Clone returns a shallow copy

func (*Measurements) CopyAndReset

func (m *Measurements) CopyAndReset(flushInterval int32) *Measurements

CopyAndReset resets the custom metrics and return a copy of the old one.

func (*Measurements) Increment

func (m *Measurements) Increment(name string, opts MetricOptions) error

Increment submits the incremental measurement to the reporter.

func (*Measurements) SetCap

func (m *Measurements) SetCap(cap int32)

SetCap sets the maximum number of distinct metrics allowed.

func (*Measurements) Summary

func (m *Measurements) Summary(name string, value float64, opts MetricOptions) error

Summary submits the summary measurement to the reporter.

type MetricOptions

type MetricOptions struct {
	Count   int
	HostTag bool
	Tags    map[string]string

MetricOptions is a struct for the optional parameters of a measurement.

type RateCounts

type RateCounts struct {
	// contains filtered or unexported fields

RateCounts is the rate counts reported by trace sampler

func (*RateCounts) FlushRateCounts

func (c *RateCounts) FlushRateCounts() *RateCounts

FlushRateCounts reset the counters and returns the current value

func (*RateCounts) Limited

func (c *RateCounts) Limited() int64

func (*RateCounts) LimitedInc

func (c *RateCounts) LimitedInc()

func (*RateCounts) Requested

func (c *RateCounts) Requested() int64

func (*RateCounts) RequestedInc

func (c *RateCounts) RequestedInc()

func (*RateCounts) Sampled

func (c *RateCounts) Sampled() int64

func (*RateCounts) SampledInc

func (c *RateCounts) SampledInc()

func (*RateCounts) Through

func (c *RateCounts) Through() int64

func (*RateCounts) ThroughInc

func (c *RateCounts) ThroughInc()

func (*RateCounts) Traced

func (c *RateCounts) Traced() int64

func (*RateCounts) TracedInc

func (c *RateCounts) TracedInc()

type SpanMessage

type SpanMessage interface {
	Process(m *Measurements)

SpanMessage defines a span message

type TransMap

type TransMap struct {
	// contains filtered or unexported fields

TransMap records the received transaction names in a metrics report cycle. It will refuse new transaction names if reaching the capacity.

func NewTransMap

func NewTransMap(cap int32) *TransMap

NewTransMap initializes a new TransMap struct

func (*TransMap) Cap

func (t *TransMap) Cap() int32

Cap returns the current capacity

func (*TransMap) Clone

func (t *TransMap) Clone() *TransMap

Clone returns a shallow copy

func (*TransMap) IsWithinLimit

func (t *TransMap) IsWithinLimit(name string) bool

IsWithinLimit checks if the transaction name is stored in the TransMap. It will store this new transaction name and return true if not stored before and the map isn't full, or return false otherwise.

func (*TransMap) Overflow

func (t *TransMap) Overflow() bool

Overflow returns true is the transaction map is overflow (reached its limit) or false if otherwise.

func (*TransMap) Reset

func (t *TransMap) Reset()

Reset resets the transaction map to a initialized state. The new capacity got from the server will be used in next metrics reporting cycle after reset.

func (*TransMap) SetCap

func (t *TransMap) SetCap(cap int32)

SetCap sets the capacity of the transaction map

Jump to

Keyboard shortcuts

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